[pypy-svn] r52984 - in pypy/branch/jit-hotpath/pypy: jit/hintannotator jit/rainbow/test jit/tl module/pypyjit rlib
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 27 10:36:19 CET 2008
Author: arigo
Date: Thu Mar 27 10:36:17 2008
New Revision: 52984
Modified:
pypy/branch/jit-hotpath/pypy/jit/hintannotator/hotpath.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py
pypy/branch/jit-hotpath/pypy/jit/tl/tiny2_hotpath.py
pypy/branch/jit-hotpath/pypy/module/pypyjit/interp_jit.py
pypy/branch/jit-hotpath/pypy/rlib/jit.py
Log:
Change the signature of on_enter_jit(). It is more natural this way
because the greens arrive directly as greens, and it removes the
ambiguity of what occurs if 'self.somegreen' is modified.
Add an 'invariants' argument (in-progress).
Modified: pypy/branch/jit-hotpath/pypy/jit/hintannotator/hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/hintannotator/hotpath.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/hintannotator/hotpath.py Thu Mar 27 10:36:17 2008
@@ -5,6 +5,7 @@
from pypy.jit.hintannotator.annotator import HintAnnotator
from pypy.jit.hintannotator.model import SomeLLAbstractConstant, OriginFlags
from pypy.annotation import model as annmodel
+from pypy.rpython.rmodel import inputconst
from pypy.rpython.rtyper import LowLevelOpList
from pypy.rpython.lltypesystem import lltype
from pypy.rlib.jit import JitHintError
@@ -137,14 +138,16 @@
num_greens = len(drivercls.greens)
num_reds = len(drivercls.reds)
assert len(allvars) == num_greens + num_reds
- for name, v_value in zip(drivercls.greens + drivercls.reds, allvars):
+ for name, v_value in zip(drivercls.reds, allvars[num_greens:]):
r_instance.setfield(v_self, name, v_value, llops)
- # generate a call to on_enter_jit(self)
+ # generate a call to on_enter_jit(self, invariants, *greens)
on_enter_jit_func = drivercls.on_enter_jit.im_func
s_func = rtyper.annotator.bookkeeper.immutablevalue(on_enter_jit_func)
r_func = rtyper.getrepr(s_func)
c_func = r_func.get_unique_llfn()
- llops.genop('direct_call', [c_func, v_self])
+ v_invariants = inputconst(lltype.Void, None)
+ vlist = allvars[:num_greens]
+ llops.genop('direct_call', [c_func, v_self, v_invariants] + vlist)
# generate ops to reload the 'reds' variables from 'self'
# XXX Warning! the 'greens' variables are not reloaded. This is
# a bit of a mess color-wise, and probably not useful.
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py Thu Mar 27 10:36:17 2008
@@ -358,7 +358,7 @@
class MyJitDriver(JitDriver):
greens = []
reds = ['n']
- def on_enter_jit(self):
+ def on_enter_jit(self, invariants):
self.n += 100 # doesn't make sense, just for testing
def ll_function(n):
@@ -378,10 +378,8 @@
class MyJitDriver(JitDriver):
greens = ['void1', 'm']
reds = ['void2', 'n']
- def on_enter_jit(self):
- self.n += self.m # doesn't make sense, just for testing
- # note that the green 'self.m' cannot be modified
- # (changes would not be reloaded into the 'm' var currently)
+ def on_enter_jit(self, invariants, void1, m):
+ self.n += m # doesn't make sense, just for testing
def ll_function(n, m):
MyJitDriver.jit_merge_point(n=n, m=m, void1=None, void2=None)
@@ -397,6 +395,17 @@
"run_machine_code 200 2",
])
+ def test_on_enter_jit_args_are_green(self):
+ class MyJitDriver(JitDriver):
+ greens = ['m']
+ reds = []
+ def on_enter_jit(self, invariants, m):
+ hint(m, concrete=True)
+ def ll_function(m):
+ MyJitDriver.jit_merge_point(m=m)
+ MyJitDriver.can_enter_jit(m=m)
+ self.run(ll_function, [2], threshold=1, small=True)
+
def test_hp_tlr(self):
from pypy.jit.tl import tlr
Modified: pypy/branch/jit-hotpath/pypy/jit/tl/tiny2_hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/tl/tiny2_hotpath.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/tl/tiny2_hotpath.py Thu Mar 27 10:36:17 2008
@@ -103,7 +103,7 @@
reds = ['args', 'loops', 'stack']
greens = ['bytecode', 'pos']
- def on_enter_jit(self):
+ def on_enter_jit(self, invariants, bytecode, pos):
# Now some strange code that makes a copy of the 'args' list in
# a complicated way... this is a workaround forcing the whole 'args'
# list to be virtual. It is a way to tell the JIT compiler that it
Modified: pypy/branch/jit-hotpath/pypy/module/pypyjit/interp_jit.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/module/pypyjit/interp_jit.py (original)
+++ pypy/branch/jit-hotpath/pypy/module/pypyjit/interp_jit.py Thu Mar 27 10:36:17 2008
@@ -23,11 +23,9 @@
class PyPyJitDriver(JitDriver):
reds = ['frame', 'ec']
greens = ['next_instr', 'pycode']
- def on_enter_jit(self):
+ def on_enter_jit(self, invariants, next_instr, pycode):
# *loads* of nonsense for now
frame = self.frame
- pycode = self.pycode
- pycode = hint(pycode, promote=True) # xxx workaround
pycode = hint(pycode, deepfreeze=True)
fastlocals_w = [None] * pycode.co_nlocals
Modified: pypy/branch/jit-hotpath/pypy/rlib/jit.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rlib/jit.py (original)
+++ pypy/branch/jit-hotpath/pypy/rlib/jit.py Thu Mar 27 10:36:17 2008
@@ -182,20 +182,23 @@
def _emulate_method_calls(cls, bookkeeper, livevars_s):
# annotate "cls.on_enter_jit()" if it is defined
- # on_enter_jit(self) is called with a copy of the value of the
- # red and green variables. The red variables can be modified
- # in order to give hints to the JIT about the redboxes. The
- # green variables should not be changed.
+ # on_enter_jit(self, invariants, *greenvars) is called with a copy
+ # of the value of the red variables on self. The red variables
+ # can be modified in order to give hints to the JIT about the
+ # redboxes.
from pypy.annotation import model as annmodel
if hasattr(cls, 'on_enter_jit'):
classdef = bookkeeper.getuniqueclassdef(cls)
- s_arg = annmodel.SomeInstance(classdef)
- for name, s_value in livevars_s.items():
- assert name.startswith('s_')
- name = name[2:]
- s_arg.setattr(bookkeeper.immutablevalue(name), s_value)
+ s_self = annmodel.SomeInstance(classdef)
+ args_s = [s_self, annmodel.s_None]
+ for name in cls.greens:
+ s_value = livevars_s['s_' + name]
+ args_s.append(s_value)
+ for name in cls.reds:
+ s_value = livevars_s['s_' + name]
+ s_self.setattr(bookkeeper.immutablevalue(name), s_value)
key = "rlib.jit.JitDriver.on_enter_jit"
s_func = bookkeeper.immutablevalue(cls.on_enter_jit.im_func)
- s_result = bookkeeper.emulate_pbc_call(key, s_func, [s_arg])
+ s_result = bookkeeper.emulate_pbc_call(key, s_func, args_s)
assert annmodel.s_None.contains(s_result)
_emulate_method_calls = classmethod(_emulate_method_calls)
More information about the Pypy-commit
mailing list