Commits

Maciej Fijalkowski committed 1674d1d

make the key available

Comments (0)

Files changed (2)

pypy/module/pypyjit/interp_resop.py

             return space.wrap(self.bridge_no)
         raise OperationError(space.w_TypeError, space.wrap("not a bridge"))
 
+    def descr_get_key(self, space):
+        if space.is_none(self.w_green_key):
+            return space.newtuple([space.wrap(self.type), space.wrap(
+                self.bridge_no)])
+        return space.newtuple([space.wrap(self.type), space.wrap(self.loop_no)])
+                              
+
 @unwrap_spec(loopno=int, asmaddr=int, asmlen=int, loop_no=int,
              type=str, jd_name=str, bridge_no=int)
 def descr_new_jit_loop_info(space, w_subtype, w_greenkey, w_ops, loopno,
                                doc="bridge number (if a bridge)"),
     type = interp_attrproperty('type', cls=W_JitLoopInfo,
                                doc="Loop type"),
+    key = GetSetProperty(W_JitLoopInfo.descr_get_key,
+                         doc="bridge key in counters"),
     __repr__ = interp2app(W_JitLoopInfo.descr_repr),
 )
 W_JitLoopInfo.acceptable_as_base_class = False

pypy/module/pypyjit/test/test_jit_hook.py

         assert info.loop_no == 0
         assert info.type == 'loop'
         raises(TypeError, 'info.bridge_no')
+        assert info.key == ('loop', 0)
         assert len(info.operations) == 4
         int_add = info.operations[0]
         dmp = info.operations[1]