[pypy-commit] pypy jit-threshold-hooks: another hint to not trace inside something

fijal noreply at buildbot.pypy.org
Tue Aug 27 11:06:44 CEST 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: jit-threshold-hooks
Changeset: r66356:055e0f71be5c
Date: 2013-08-27 10:06 +0100
http://bitbucket.org/pypy/pypy/changeset/055e0f71be5c/

Log:	another hint to not trace inside something

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
@@ -19,6 +19,7 @@
         'Box': 'interp_resop.WrappedBox',
         'PARAMETER_DOCS': 'space.wrap(rpython.rlib.jit.PARAMETER_DOCS)',
         'set_local_threshold': 'interp_jit.set_local_threshold',
+        'dont_trace_inside': 'interp_jit.dont_trace_inside',
     }
 
     def setup_after_space_initialization(self):
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -168,6 +168,15 @@
     the JIT follow the call.'''
     return space.call_args(w_callable, __args__)
 
+def _jitcell_at(w_code, pos):
+    try:
+        jitcell = w_code.jit_cells[pos << 1]
+    except KeyError:
+        ref = jit_hooks.new_jitcell()
+        jitcell = cast_base_ptr_to_instance(BaseJitCell, ref)
+        w_code.jit_cells[pos << 1] = jitcell
+    return jitcell
+
 @jit.dont_look_inside
 @unwrap_spec(w_code=PyCode, pos=r_uint, value=int)
 def set_local_threshold(space, w_code, pos, value):
@@ -176,10 +185,19 @@
     For testing. Set the threshold for this code object at position pos
     at value given.
     """
-    try:
-        jitcell = w_code.jit_cells[pos << 1]
-    except KeyError:
-        ref = jit_hooks.new_jitcell()
-        jitcell = cast_base_ptr_to_instance(BaseJitCell, ref)
-        w_code.jit_cells[pos << 1] = jitcell
+    jitcell = _jitcell_at(w_code, pos)
     jitcell.counter = value
+
+ at jit.dont_look_inside
+ at unwrap_spec(w_code=PyCode)
+def dont_trace_inside(space, w_code):
+    """ dont trace inside this function
+    """
+    from rpython.rlib.nonconst import NonConstant
+
+    flag = True
+    if NonConstant(0):
+        flag = False # annotation hack to annotate it as real bool
+    jitcell = _jitcell_at(w_code, 0)
+    jitcell.dont_trace_here = flag
+
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
@@ -279,4 +279,5 @@
             pass
 
         pypyjit.set_local_threshold(f.__code__, 0, 0)
+        pypyjit.dont_trace_inside(f.__code__)
         # assert did not crash
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -682,7 +682,7 @@
 # Annotation and rtyping of some of the JitDriver methods
 
 class BaseJitCell(object):
-    __slots__ = ('counter')
+    __slots__ = ('counter', 'dont_trace_here')
 
 
 class ExtEnterLeaveMarker(ExtRegistryEntry):


More information about the pypy-commit mailing list