[pypy-svn] r51916 - in pypy/branch/jit-refactoring/pypy/jit: rainbow rainbow/test timeshifter/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Feb 28 15:55:29 CET 2008
Author: cfbolz
Date: Thu Feb 28 15:55:28 2008
New Revision: 51916
Modified:
pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_portal.py
Log:
move over more tests and fix one of them.
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py Thu Feb 28 15:55:28 2008
@@ -25,7 +25,8 @@
self.PortalState = make_state_class(
self.args_specification, self.RESIDUAL_FUNCTYPE, self.sigtoken,
self.codewriter.all_graphs[self.portalgraph],
- self.rtyper)
+ self.rtyper,
+ self.codewriter)
self.make_state_instance()
self.mutate_origportalgraph()
@@ -97,7 +98,7 @@
def make_state_class(args_specification, RESIDUAL_FUNCTYPE, sigtoken,
- portal_jitcode, rtyper):
+ portal_jitcode, rtyper, codewriter):
args_specification = unrolling_iterable(args_specification)
class PortalState(object):
def __init__(self, interpreter, portalbytecode):
@@ -154,7 +155,8 @@
fn = gv_generated.revealconst(lltype.Ptr(RESIDUAL_FUNCTYPE))
if not we_are_translated():
# run the generated code on top of the llinterp for testing
- llinterp = LLInterpreter(rtyper)
+ exc_data_ptr = codewriter.exceptiondesc.exc_data_ptr
+ llinterp = LLInterpreter(rtyper, exc_data_ptr=exc_data_ptr)
res = llinterp.eval_graph(fn._obj.graph, residualargs)
return res
else:
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py Thu Feb 28 15:55:28 2008
@@ -59,12 +59,13 @@
backendoptimize=backendoptimize)
self.main_args = main_args
self.main_is_portal = main is portal
- llinterp = LLInterpreter(self.rtyper)
+ llinterp = LLInterpreter(self.rtyper,
+ exc_data_ptr=
+ self.writer.exceptiondesc.exc_data_ptr)
res = llinterp.eval_graph(self.maingraph, main_args)
return res
def get_residual_graph(self):
- llinterp = LLInterpreter(self.rtyper)
portalstate = self.rewriter.state
if self.main_is_portal:
residual_graph = portalstate.readportal(*self.main_args)._obj.graph
@@ -375,3 +376,52 @@
policy=StopAtXPolicy(ll_make))
assert res == ord('2')
self.check_insns(indirect_call=0, malloc=0)
+
+
+ def test_residual_red_call_with_promoted_exc(self):
+ def h(x):
+ if x > 0:
+ return x+1
+ else:
+ raise ValueError
+
+ def g(x):
+ return 2*h(x)
+
+ def f(x):
+ hint(None, global_merge_point=True)
+ try:
+ return g(x)
+ except ValueError:
+ return 7
+
+ stop_at_h = StopAtXPolicy(h)
+ res = self.timeshift_from_portal(f, f, [20], policy=stop_at_h)
+ assert res == 42
+ self.check_insns(int_add=0)
+
+ res = self.timeshift_from_portal(f, f, [-20], policy=stop_at_h)
+ assert res == 7
+ self.check_insns(int_add=0)
+
+ def test_residual_oop_raising(self):
+ py.test.skip("not working yet")
+ def g(x):
+ lst = []
+ if x > 10:
+ lst.append(x)
+ return lst
+ def f(x):
+ hint(None, global_merge_point=True)
+ lst = g(x)
+ try:
+ return lst[0]
+ except IndexError:
+ return -42
+
+ res = self.timeshift_from_portal(f, f, [5], policy=P_OOPSPEC)
+ assert res == -42
+
+ res = self.timeshift_from_portal(f, f, [15], policy=P_OOPSPEC)
+ assert res == 15
+
Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_portal.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_portal.py Thu Feb 28 15:55:28 2008
@@ -141,10 +141,6 @@
return calls
class TestPortal(PortalTest):
-
-
-
-
def test_simple_recursive_portal_call(self):
def main(code, x):
@@ -216,52 +212,6 @@
assert res == 11
- def test_residual_red_call_with_promoted_exc(self):
- def h(x):
- if x > 0:
- return x+1
- else:
- raise ValueError
-
- def g(x):
- return 2*h(x)
-
- def f(x):
- hint(None, global_merge_point=True)
- try:
- return g(x)
- except ValueError:
- return 7
-
- stop_at_h = StopAtXPolicy(h)
- res = self.timeshift_from_portal(f, f, [20], policy=stop_at_h)
- assert res == 42
- self.check_insns(int_add=0)
-
- res = self.timeshift_from_portal(f, f, [-20], policy=stop_at_h)
- assert res == 7
- self.check_insns(int_add=0)
-
- def test_residual_oop_raising(self):
- def g(x):
- lst = []
- if x > 10:
- lst.append(x)
- return lst
- def f(x):
- hint(None, global_merge_point=True)
- lst = g(x)
- try:
- return lst[0]
- except IndexError:
- return -42
-
- res = self.timeshift_from_portal(f, f, [5], policy=P_OOPSPEC)
- assert res == -42
-
- res = self.timeshift_from_portal(f, f, [15], policy=P_OOPSPEC)
- assert res == 15
-
def test_portal_returns_none(self):
py.test.skip("portal returning None is not supported")
def g(x):
More information about the Pypy-commit
mailing list