Author: Maciej Fijalkowski <[email protected]>
Branch: jit-threshold-hooks
Changeset: r65440:965c645286ae
Date: 2013-07-17 15:20 +0200
http://bitbucket.org/pypy/pypy/changeset/965c645286ae/

Log:    Start a branch to manually manipulate jit parameters per function

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
@@ -18,6 +18,8 @@
         'JitLoopInfo': 'interp_resop.W_JitLoopInfo',
         'Box': 'interp_resop.WrappedBox',
         'PARAMETER_DOCS': 'space.wrap(rpython.rlib.jit.PARAMETER_DOCS)',
+        'set_local_threshold': 'interp_jit.set_local_threshold',
+        'set_local_bridge_threshold': 'interp_jit.set_local_bridge_threshold',
     }
 
     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
@@ -13,6 +13,7 @@
 from pypy.interpreter.pycode import PyCode, CO_GENERATOR
 from pypy.interpreter.pyframe import PyFrame
 from pypy.interpreter.pyopcode import ExitFrame
+from pypy.interpreter.gateway import unwrap_spec
 from opcode import opmap
 
 PyFrame._virtualizable2_ = ['last_instr', 'pycode',
@@ -51,11 +52,15 @@
     greens = ['next_instr', 'is_being_profiled', 'pycode']
     virtualizables = ['frame']
 
+def start_bridge_threshold(next_instr, is_being_profiled, bytecode):
+    return bytecode.bridge_init_threshold
+
 pypyjitdriver = PyPyJitDriver(get_printable_location = get_printable_location,
                               get_jitcell_at = get_jitcell_at,
                               set_jitcell_at = set_jitcell_at,
                               should_unroll_one_iteration =
                               should_unroll_one_iteration,
+                              start_bridge_threshold=start_bridge_threshold,
                               name='pypyjit')
 
 class __extend__(PyFrame):
@@ -117,6 +122,7 @@
     def _initialize(self):
         PyCode__initialize(self)
         self.jit_cells = {}
+        self.bridge_init_threshold = 0
 
     def _cleanup_(self):
         self.jit_cells = {}
@@ -162,3 +168,16 @@
     '''For testing.  Invokes callable(...), but without letting
     the JIT follow the call.'''
     return space.call_args(w_callable, __args__)
+
+@unwrap_spec(w_code=PyCode, pos=int, value=int)
+def set_local_threshold(space, w_code, pos, value):
+    """ set_local_threshold(code, pos, value)
+
+    For testing. Set the threshold for this code object at position pos
+    at value given.
+    """
+    w_code.jit_cells[pos << 1] = value # we ignore the profiling case
+
+@unwrap_spec(w_code=PyCode, value=int)
+def set_local_bridge_threshold(space, w_code, value):
+    w_code.bridge_init_threshold = value
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -481,6 +481,7 @@
                  get_jitcell_at=None, set_jitcell_at=None,
                  get_printable_location=None, confirm_enter_jit=None,
                  can_never_inline=None, should_unroll_one_iteration=None,
+                 start_bridge_threshold=None,
                  name='jitdriver', check_untranslated=True):
         if greens is not None:
             self.greens = greens
@@ -517,6 +518,7 @@
         self.can_never_inline = can_never_inline
         self.should_unroll_one_iteration = should_unroll_one_iteration
         self.check_untranslated = check_untranslated
+        self.start_bridge_threshold = start_bridge_threshold
 
     def _freeze_(self):
         return True
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to