[pypy-svn] r37844 - in pypy/branch/jit-virtual-world/pypy: jit/timeshifter jit/timeshifter/test translator/c
arigo at codespeak.net
arigo at codespeak.net
Sat Feb 3 01:15:58 CET 2007
Author: arigo
Date: Sat Feb 3 01:15:36 2007
New Revision: 37844
Modified:
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
pypy/branch/jit-virtual-world/pypy/translator/c/exceptiontransform.py
Log:
(pedronis, arigo)
When an exception is raised by the original graphs, the timeshifted
graphs now assert that the exception cannot be None. See test.
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py Sat Feb 3 01:15:36 2007
@@ -1233,6 +1233,19 @@
[v_jitstate , v_box , c_desc],
annmodel.SomeBool())
+ def translate_op_rpyexc_raise(self, hop):
+ EXCTYPE = originalconcretetype(hop.args_s[0])
+ EXCVALUE = originalconcretetype(hop.args_s[1])
+ [v_exctype, v_excvalue] = hop.inputargs(self.getredrepr(EXCTYPE),
+ self.getredrepr(EXCVALUE))
+ v_exctype = hop.llops.as_ptrredbox(v_exctype)
+ v_excvalue = hop.llops.as_ptrredbox(v_excvalue)
+ v_jitstate = hop.llops.getjitstate()
+ return hop.llops.genmixlevelhelpercall(rtimeshift.setexception,
+ [self.s_JITState, self.s_PtrRedBox, self.s_PtrRedBox],
+ [v_jitstate , v_exctype , v_excvalue ],
+ annmodel.s_None)
+
# handling of the various kinds of calls
def translate_op_oopspec_call(self, hop):
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py Sat Feb 3 01:15:36 2007
@@ -478,6 +478,12 @@
def setexcvaluebox(jitstate, box):
jitstate.exc_value_box = box
+def setexception(jitstate, typebox, valuebox):
+ typebox.known_nonzero = True
+ valuebox.known_nonzero = True
+ jitstate.exc_type_box = typebox
+ jitstate.exc_value_box = valuebox
+
def save_return(jitstate):
# add 'jitstate' to the chain of return-jitstates
jitstate.pause()
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py Sat Feb 3 01:15:36 2007
@@ -334,3 +334,39 @@
res = self.timeshift(ll_function, ["oe", 1], [],
policy=StopAtXPolicy(w))
res == 1
+
+ def test_raise_result_mixup_some_more(self):
+ def w(x):
+ if x > 1000:
+ return None
+ else:
+ return E(x)
+ class E(Exception):
+ def __init__(self, x):
+ self.x = x
+ def o(x):
+ if x < 0:
+ e = w(x)
+ raise e
+ return x
+ def ll_function(c, x):
+ i = 0
+ while True:
+ hint(None, global_merge_point=True)
+ op = c[i]
+ hint(op, concrete=True)
+ if op == 'e':
+ break
+ elif op == 'o':
+ x = o(x)
+ x = hint(x, promote=True)
+ i = x
+ r = hint(i, variable=True)
+ return r
+ ll_function.convert_arguments = [LLSupport.to_rstr, int]
+
+ assert ll_function("oe", 1) == 1
+
+ res = self.timeshift(ll_function, ["oe", 1], [],
+ policy=StopAtXPolicy(w))
+ res == 1
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py Sat Feb 3 01:15:36 2007
@@ -495,6 +495,8 @@
if spaceop.opname == 'direct_call':
c_func = spaceop.args[0]
fnobj = c_func.value._obj
+ if hasattr(fnobj, 'jitcallkind'):
+ return fnobj.jitcallkind
if (hasattr(fnobj._callable, 'oopspec') and
self.hannotator.policy.oopspec):
if fnobj._callable.oopspec.startswith('vable.'):
@@ -663,7 +665,13 @@
args = op.args[1:]
args.insert(1, Constant(name, lltype.Void))
block.operations[pos] = SpaceOperation(opname, args, op.result)
-
+
+ def handle_rpyexc_raise_call(self, block, pos):
+ op = block.operations[pos]
+ assert op.opname == 'direct_call'
+ op.opname = 'rpyexc_raise'
+ op.args = op.args[1:]
+
def handle_green_call(self, block, pos):
# green-returning call, for now (XXX) we assume it's an
# all-green function that we can just call
Modified: pypy/branch/jit-virtual-world/pypy/translator/c/exceptiontransform.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/translator/c/exceptiontransform.py (original)
+++ pypy/branch/jit-virtual-world/pypy/translator/c/exceptiontransform.py Sat Feb 3 01:15:36 2007
@@ -138,7 +138,9 @@
self.rpyexc_raise_ptr = Constant(lltype.functionptr(
RPYEXC_RAISE, "RPyRaiseException",
graph=rpyexc_raise_graph,
- exception_policy="exc_helper"),
+ exception_policy="exc_helper",
+ jitcallkind='rpyexc_raise', # for the JIT
+ ),
lltype.Ptr(RPYEXC_RAISE))
mixlevelannotator.finish()
More information about the Pypy-commit
mailing list