Author: fijal
Branch: fix-trace-too-long-heuristic
Changeset: r80803:3fe75b266c8c
Date: 2015-11-20 18:19 +0200
http://bitbucket.org/pypy/pypy/changeset/3fe75b266c8c/

Log:    try to wrap guard operations so we can get their hash

diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -24,6 +24,7 @@
         #'enable_debug': 'interp_resop.enable_debug',
         #'disable_debug': 'interp_resop.disable_debug',
         'ResOperation': 'interp_resop.WrappedOp',
+        'GuardOp': 'interp_resop.GuardOp',
         'DebugMergePoint': 'interp_resop.DebugMergePoint',
         'JitLoopInfo': 'interp_resop.W_JitLoopInfo',
         'PARAMETER_DOCS': 'space.wrap(rpython.rlib.jit.PARAMETER_DOCS)',
diff --git a/pypy/module/pypyjit/interp_resop.py 
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -10,6 +10,7 @@
 from rpython.rtyper.rclass import OBJECT
 #from rpython.jit.metainterp.resoperation import rop
 from rpython.rlib.nonconst import NonConstant
+from rpython.rlib.rarithmetic import r_uint
 from rpython.rlib import jit_hooks
 from rpython.rlib.jit import Counters
 from rpython.rlib.objectmodel import compute_unique_id
@@ -119,6 +120,9 @@
                                        op.getarg(1).getint(),
                                        op.getarg(2).getint(),
                                        w_greenkey))
+        elif op.is_guard():
+            l_w.append(GuardOp(name, ofs, logops.repr_of_resop(op),
+                op.getdescr().get_jitcounter_hash()))
         else:
             l_w.append(WrappedOp(name, ofs, logops.repr_of_resop(op)))
     return l_w
@@ -127,6 +131,10 @@
 def descr_new_resop(space, w_tp, name, offset=-1, repr=''):
     return WrappedOp(name, offset, repr)
 
+@unwrap_spec(offset=int, repr=str, name=str, hash=r_uint)
+def descr_new_guardop(space, w_tp, name, offset=-1, repr='', hash=r_uint(0)):
+    return GuardOp(name, offset, repr, hash)
+
 @unwrap_spec(repr=str, name=str, jd_name=str, call_depth=int, call_id=int)
 def descr_new_dmp(space, w_tp, name, repr, jd_name, call_depth, call_id,
     w_greenkey):
@@ -149,6 +157,11 @@
     def descr_name(self, space):
         return space.wrap(self.name)
 
+class GuardOp(WrappedOp):
+    def __init__(self, name, offset, repr_of_resop, hash):
+        WrappedOp.__init__(self, name, offset, repr_of_resop)
+        self.hash = hash
+
 class DebugMergePoint(WrappedOp):
     """ A class representing Debug Merge Point - the entry point
     to a jitted loop.
@@ -186,6 +199,17 @@
 )
 WrappedOp.typedef.acceptable_as_base_class = False
 
+GuardOp.typedef = TypeDef(
+    'GuardOp',
+    __doc__ = GuardOp.__doc__,
+    __new__ = interp2app(descr_new_guardop),
+    __repr__ = interp2app(GuardOp.descr_repr),
+    name = GetSetProperty(GuardOp.descr_name),
+    offset = interp_attrproperty("offset", cls=GuardOp),
+    hash = interp_attrproperty("hash", cls=GuardOp),
+    )
+GuardOp.typedef.acceptable_as_base_class = False
+
 DebugMergePoint.typedef = TypeDef(
     'DebugMergePoint', WrappedOp.typedef,
     __new__ = interp2app(descr_new_dmp),
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py 
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -65,6 +65,14 @@
             if i != 1:
                 offset[op] = i
 
+        class FailDescr(BasicFailDescr):
+            def get_jitcounter_hash(self):
+                from rpython.rlib.rarithmetic import r_uint
+                return r_uint(13)
+
+        oplist[-1].setdescr(FailDescr())
+        oplist[-2].setdescr(FailDescr())
+
         token = JitCellToken()
         token.number = 0
         di_loop = JitDebugInfo(MockJitDriverSD, logger, token, oplist, 'loop',
@@ -73,7 +81,7 @@
                                         oplist, 'loop', greenkey)
         di_loop.asminfo = AsmInfo(offset, 0x42, 12)
         di_bridge = JitDebugInfo(MockJitDriverSD, logger, JitCellToken(),
-                                 oplist, 'bridge', fail_descr=BasicFailDescr())
+                                 oplist, 'bridge', fail_descr=FailDescr())
         di_bridge.asminfo = AsmInfo(offset, 0, 0)
 
         def interp_on_compile():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to