Commits

Amaury Forgeot d'Arc  committed d2433ae

pypyjit hooks: Expose address, length, offsets in generated machine code.

  • Participants
  • Parent commits ad51c32

Comments (0)

Files changed (2)

File pypy/module/pypyjit/interp_resop.py

     getarg = interp2app(WrappedOp.descr_getarg),
     setarg = interp2app(WrappedOp.descr_setarg),
     result = GetSetProperty(WrappedOp.descr_getresult,
-                            WrappedOp.descr_setresult)
+                            WrappedOp.descr_setresult),
+    offset = interp_attrproperty("offset", cls=WrappedOp),
 )
 WrappedOp.acceptable_as_base_class = False
 
                                doc="bridge number (if a bridge)"),
     type = interp_attrproperty('type', cls=W_JitLoopInfo,
                                doc="Loop type"),
+    asmaddr = interp_attrproperty('asmaddr', cls=W_JitLoopInfo,
+                                  doc="Address of machine code"),
+    asmlen = interp_attrproperty('asmlen', cls=W_JitLoopInfo,
+                                  doc="Length of machine code"),
     __repr__ = interp2app(W_JitLoopInfo.descr_repr),
 )
 W_JitLoopInfo.acceptable_as_base_class = False

File pypy/module/pypyjit/test/test_jit_hook.py

                    greenkey)
         di_loop_optimize = JitDebugInfo(MockJitDriverSD, logger, JitCellToken(),
                                         oplist, 'loop', greenkey)
-        di_loop.asminfo = AsmInfo(offset, 0, 0)
+        di_loop.asminfo = AsmInfo(offset, 0x42, 12)
         di_bridge = JitDebugInfo(MockJitDriverSD, logger, JitCellToken(),
                                  oplist, 'bridge', fail_descr=BasicFailDescr())
         di_bridge.asminfo = AsmInfo(offset, 0, 0)
         assert info.greenkey[2] == False
         assert info.loop_no == 0
         assert info.type == 'loop'
+        assert info.asmaddr == 0x42
+        assert info.asmlen == 12
         raises(TypeError, 'info.bridge_no')
         assert len(info.operations) == 4
         int_add = info.operations[0]
         assert dmp.greenkey == (self.f.func_code, 0, False)
         assert dmp.call_depth == 0
         assert dmp.call_id == 0
+        assert dmp.offset == -1
         assert int_add.name == 'int_add'
         assert int_add.num == self.int_add_num
+        assert int_add.offset == 0
         self.on_compile_bridge()
         expected = ('<JitLoopInfo pypyjit, 4 operations, starting at '
                     '<(%s, 0, False)>>' % repr(self.f.func_code))