Alex Gaynor avatar Alex Gaynor committed 3242596

expose the current call depth on DebugMergePoint

Comments (0)

Files changed (2)

pypy/module/pypyjit/interp_resop.py

             l_w.append(DebugMergePoint(space, jit_hooks._cast_to_gcref(op),
                                        logops.repr_of_resop(op),
                                        jd_sd.jitdriver.name,
+                                       op.getarg(1).getint(),
                                        w_greenkey))
         else:
             l_w.append(WrappedOp(jit_hooks._cast_to_gcref(op), ofs,
         llres = res.llbox
     return WrappedOp(jit_hooks.resop_new(num, args, llres), offset, repr)
 
-@unwrap_spec(repr=str, jd_name=str)
-def descr_new_dmp(space, w_tp, w_args, repr, jd_name, w_greenkey):
+@unwrap_spec(repr=str, jd_name=str, call_depth=int)
+def descr_new_dmp(space, w_tp, w_args, repr, jd_name, call_depth, w_greenkey):
     args = [space.interp_w(WrappedBox, w_arg).llbox for w_arg in
             space.listview(w_args)]
     num = rop.DEBUG_MERGE_POINT
     return DebugMergePoint(space,
                            jit_hooks.resop_new(num, args, jit_hooks.emptyval()),
-                           repr, jd_name, w_greenkey)
+                           repr, jd_name, call_depth, w_greenkey)
 
 class WrappedOp(Wrappable):
     """ A class representing a single ResOperation, wrapped nicely
         jit_hooks.resop_setresult(self.op, box.llbox)
 
 class DebugMergePoint(WrappedOp):
-    def __init__(self, space, op, repr_of_resop, jd_name, w_greenkey):
+    def __init__(self, space, op, repr_of_resop, jd_name, call_depth, w_greenkey):
         WrappedOp.__init__(self, op, -1, repr_of_resop)
+        self.jd_name = jd_name
+        self.call_depth = call_depth
         self.w_greenkey = w_greenkey
-        self.jd_name = jd_name
 
     def get_pycode(self, space):
         if self.jd_name == pypyjitdriver.name:
     greenkey = interp_attrproperty_w("w_greenkey", cls=DebugMergePoint),
     pycode = GetSetProperty(DebugMergePoint.get_pycode),
     bytecode_no = GetSetProperty(DebugMergePoint.get_bytecode_no),
+    call_depth = interp_attrproperty("call_depth", cls=DebugMergePoint),
     jitdriver_name = GetSetProperty(DebugMergePoint.get_jitdriver_name),
 )
 DebugMergePoint.acceptable_as_base_class = False

pypy/module/pypyjit/test/test_jit_hook.py

         assert isinstance(dmp, pypyjit.DebugMergePoint)
         assert dmp.pycode is self.f.func_code
         assert dmp.greenkey == (self.f.func_code, 0, False)
-        #assert int_add.name == 'int_add'
+        assert dmp.call_depth == 0
+        assert int_add.name == 'int_add'
         assert int_add.num == self.int_add_num
         self.on_compile_bridge()
         assert len(all) == 2
         def f():
             pass
 
-        op = DebugMergePoint([Box(0)], 'repr', 'pypyjit', (f.func_code, 0, 0))
+        op = DebugMergePoint([Box(0)], 'repr', 'pypyjit', 2, (f.func_code, 0, 0))
         assert op.bytecode_no == 0
         assert op.pycode is f.func_code
         assert repr(op) == 'repr'
         assert op.jitdriver_name == 'pypyjit'
         assert op.num == self.dmp_num
-        op = DebugMergePoint([Box(0)], 'repr', 'notmain', ('str',))
+        assert op.call_depth == 2
+        op = DebugMergePoint([Box(0)], 'repr', 'notmain', 5, ('str',))
         raises(AttributeError, 'op.pycode')
+        assert op.call_depth == 5
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.