Commits

Maciej Fijalkowski committed 0513eb2

dmp creation

  • Participants
  • Parent commits 31b1dba
  • Branches better-jit-hooks-2

Comments (0)

Files changed (4)

File pypy/module/pypyjit/__init__.py

         'set_optimize_hook': 'interp_resop.set_optimize_hook',
         'set_abort_hook': 'interp_resop.set_abort_hook',
         'ResOperation': 'interp_resop.WrappedOp',
+        'DebugMergePoint': 'interp_resop.DebugMergePoint',
         'Box': 'interp_resop.WrappedBox',
     }
 

File pypy/module/pypyjit/interp_resop.py

 
-from pypy.interpreter.typedef import TypeDef, GetSetProperty
+from pypy.interpreter.typedef import TypeDef, GetSetProperty,\
+     interp_attrproperty
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.gateway import unwrap_spec, interp2app, NoneNotWrapped
 from pypy.interpreter.pycode import PyCode
         llres = res.llbox
     return WrappedOp(jit_hooks.resop_new(num, args, llres), offset, repr)
 
+@unwrap_spec(repr=str, pycode=PyCode, bytecode_no=int)
+def descr_new_dmp(space, w_tp, w_args, repr, pycode, bytecode_no):
+    args = [space.interp_w(WrappedBox, w_arg).llbox for w_arg in
+            space.listview(w_args)]
+    num = rop.DEBUG_MERGE_POINT
+    return DebugMergePoint(jit_hooks.resop_new(num, args, jit_hooks.emptyval()),
+                           repr, pycode, bytecode_no)
+
 class WrappedOp(Wrappable):
     """ A class representing a single ResOperation, wrapped nicely
     """
         box = space.interp_w(WrappedBox, w_box)
         jit_hooks.resop_setresult(self.op, box.llbox)
 
+class DebugMergePoint(WrappedOp):
+    def __init__(self, op, repr_of_resop, pycode, bytecode_no):
+        WrappedOp.__init__(self, op, -1, repr_of_resop)
+        self.pycode = pycode
+        self.bytecode_no = bytecode_no
+
+    def get_bytecode_no(self, space):
+        if self.pycode is None:
+            return space.w_None
+        return space.wrap(self.bytecode_no)
+
 WrappedOp.typedef = TypeDef(
     'ResOperation',
     __doc__ = WrappedOp.__doc__,
                             WrappedOp.descr_setresult)
 )
 WrappedOp.acceptable_as_base_class = False
+
+DebugMergePoint.typedef = TypeDef(
+    'DebugMergePoint', WrappedOp.typedef,
+    __new__ = interp2app(descr_new_dmp),
+    pycode = interp_attrproperty('pycode', cls=DebugMergePoint),
+    bytecode_no = GetSetProperty(DebugMergePoint.get_bytecode_no),
+)
+DebugMergePoint.acceptable_as_base_class = False
+
+                   

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

         cls.w_on_compile_bridge = space.wrap(interp2app(interp_on_compile_bridge))
         cls.w_on_abort = space.wrap(interp2app(interp_on_abort))
         cls.w_int_add_num = space.wrap(rop.INT_ADD)
+        cls.w_dmp_num = space.wrap(rop.DEBUG_MERGE_POINT)
         cls.w_on_optimize = space.wrap(interp2app(interp_on_optimize))
         cls.orig_oplist = oplist
 
         assert op.getarg(0).getint() == 4
         op.result = box
         assert op.result.getint() == 1
+
+    def test_creation_dmp(self):
+        from pypyjit import DebugMergePoint, Box
+
+        def f():
+            pass
+
+        op = DebugMergePoint([Box(0)], '', f.func_code, 0)
+        assert op.bytecode_no == 0
+        assert op.pycode is f.func_code
+        assert op.num == self.dmp_num

File pypy/rlib/jit_hooks.py

     from pypy.jit.metainterp.history import ResOperation
 
     args = [_cast_to_box(llargs[i]) for i in range(len(llargs))]
-    res = _cast_to_box(llres)
+    if llres:
+        res = _cast_to_box(llres)
+    else:
+        res = None
     return _cast_to_gcref(ResOperation(no, args, res))
 
 @register_helper(annmodel.SomePtr(llmemory.GCREF))