[pypy-svn] r52410 - in pypy/branch/jit-hotpath/pypy/jit/rainbow: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Mar 12 12:29:54 CET 2008
Author: arigo
Date: Wed Mar 12 12:29:54 2008
New Revision: 52410
Modified:
pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py
Log:
Plug the merging logic onto the 'jit_merge_point' operation.
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py Wed Mar 12 12:29:54 2008
@@ -471,14 +471,7 @@
for arg in self.sort_by_color(block.inputargs)[1]:
TYPE = arg.concretetype
key += (TYPE, )
- if not key:
- keyindex = -1 # use prebuilt empty_key
- elif key not in self.keydesc_positions:
- keyindex = len(self.keydesc_positions)
- self.keydesc_positions[key] = keyindex
- self.keydescs.append(KeyDesc(self.RGenOp, *key))
- else:
- keyindex = self.keydesc_positions[key]
+ keyindex = self.keydesc_position(key)
kind = self.mergepoint_set[block]
if kind == "global":
@@ -619,6 +612,17 @@
self.type_positions[TYPE] = result
return result
+ def keydesc_position(self, key): # key is a tuple of TYPEs
+ if not key:
+ keyindex = -1 # use prebuilt empty_key
+ elif key not in self.keydesc_positions:
+ keyindex = len(self.keydesc_positions)
+ self.keydesc_positions[key] = keyindex
+ self.keydescs.append(KeyDesc(self.RGenOp, *key))
+ else:
+ keyindex = self.keydesc_positions[key]
+ return keyindex
+
def structtypedesc_position(self, TYPE):
if TYPE in self.structtypedesc_positions:
return self.structtypedesc_positions[TYPE]
@@ -1391,12 +1395,14 @@
numreds = op.args[1].value
greens_v = op.args[2:2+numgreens]
reds_v = op.args[2+numgreens:2+numgreens+numreds]
+ key = ()
for i, v in enumerate(greens_v):
if self.varcolor(v) != "green":
raise Exception("computed color does not match declared color:"
" %s is %s, but jit_merge_point() declares it"
" as green" % (v, self.varcolor(v)))
assert self.green_position(v) == i
+ key += (v.concretetype,)
for i, v in enumerate(reds_v):
if self.varcolor(v) != "red":
raise Exception("computed color does not match declared color:"
@@ -1404,6 +1410,7 @@
" as red" % (v, self.varcolor(v)))
assert self.redvar_position(v) == i
self.emit('jit_merge_point')
+ self.emit(self.keydesc_position(key))
def serialize_op_can_enter_jit(self, op):
return # no need to put anything in the bytecode here
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py Wed Mar 12 12:29:54 2008
@@ -2,6 +2,7 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import we_are_translated, CDefinedIntSymbolic
from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.jit.timeshifter.greenkey import empty_key, GreenKey
from pypy.jit.rainbow.interpreter import SIGN_EXTEND2, arguments
@@ -210,12 +211,14 @@
def opimpl_red_direct_call(self, greenargs, redargs, targetbytecode):
assert not greenargs # XXX for now
calldesc = targetbytecode.owncalldesc
- gv_res = calldesc.perform_call(self.rgenop,
- targetbytecode.gv_ownfnptr,
- redargs)
+ try:
+ gv_res = calldesc.perform_call(self.rgenop,
+ targetbytecode.gv_ownfnptr,
+ redargs)
+ except Exception, e:
+ XXX
if gv_res is not None:
self.red_result(gv_res)
- # XXX what occurs with exceptions raised by the called graph?
# exceptions
@@ -258,8 +261,8 @@
# hotpath-specific operations
- @arguments()
- def opimpl_jit_merge_point(self):
+ @arguments("greenkey")
+ def opimpl_jit_merge_point(self, key):
raise self.ContinueRunningNormally(self.local_green + self.local_red)
@arguments("red", "jumptarget")
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py Wed Mar 12 12:29:54 2008
@@ -209,6 +209,7 @@
self.portalstate = None
self.num_global_mergepoints = -1
self.global_state_dicts = None
+ self.jit_merge_point_state_dict = newgreendict()
if DEBUG_JITCODES:
self.find_opcode("trace") # force it to be compiled in
@@ -828,10 +829,16 @@
# ____________________________________________________________
# opcodes used by the 'hotpath' policy
- @arguments()
- def opimpl_jit_merge_point(self):
- # xxx in-progress
- pass
+ @arguments("greenkey")
+ def opimpl_jit_merge_point(self, key):
+ states_dic = self.jit_merge_point_state_dict
+ global_resumer = RainbowResumer(self, self.frame)
+ done = rtimeshift.retrieve_jitstate_for_merge(states_dic,
+ self.jitstate,
+ key, None)
+ if done:
+ self.newjitstate(None)
+ return STOP
@arguments("red", "jumptarget")
def opimpl_red_hot_goto_iftrue(self, switchbox, target):
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py Wed Mar 12 12:29:54 2008
@@ -27,6 +27,8 @@
def leave_graph(interp):
jitstate = interp.jitstate
+ if jitstate is None:
+ return
exceptiondesc = interp.exceptiondesc
builder = jitstate.curbuilder
#for virtualizable_box in jitstate.virtualizables:
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 Wed Mar 12 12:29:54 2008
@@ -33,8 +33,11 @@
self.rtyper, exc_data_ptr=self.writer.exceptiondesc.exc_data_ptr)
return llinterp.eval_graph(graph, main_args)
+ def check_traces(self, expected):
+ py.test.skip("traces in progress")
+
+
def test_simple_loop(self):
- py.test.skip("in-progress")
# there are no greens in this test
def ll_function(n):
n1 = n * 2
More information about the Pypy-commit
mailing list