[pypy-svn] r64774 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Apr 28 15:58:38 CEST 2009
Author: antocuni
Date: Tue Apr 28 15:58:36 2009
New Revision: 64774
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py
Log:
a failing test and the corresponding fix for handle_residual_oosend
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Tue Apr 28 15:58:36 2009
@@ -754,7 +754,7 @@
def op_oosend(self, descr, obj, *args):
METH = descr.METH
- obj = ootype.cast_from_object(METH.SELFTYPE, obj)
+ obj = ootype.cast_from_object(descr.SELFTYPE, obj)
meth = getattr(obj, descr.methname)
newargs = cast_call_args(METH.ARGS, args, self.memocast)
res = call_maybe_on_top_of_llinterp(meth, newargs)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Tue Apr 28 15:58:36 2009
@@ -562,6 +562,7 @@
def __init__(self, SELFTYPE, methname):
_, meth = SELFTYPE._lookup(methname)
METH = ootype.typeOf(meth)
+ self.SELFTYPE = SELFTYPE
self.METH = METH
self.methname = methname
RESULT = METH.RESULT
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Tue Apr 28 15:58:36 2009
@@ -918,6 +918,7 @@
self.register_var(op.result)
def handle_regular_oosend(self, op):
+ self.minimize_variables()
methname = op.args[0].value
v_obj = op.args[1]
INSTANCE = v_obj.concretetype
@@ -1077,6 +1078,7 @@
return v_posindex
def handle_builtin_oosend(self, op):
+ self.minimize_variables()
oopspec_name, args = support.decode_builtin_call(op)
SELFTYPE, methname, meth = support.lookup_oosend_method(op)
assert SELFTYPE.oopspec_name is not None
@@ -1096,7 +1098,16 @@
self.emit(self.get_position(methdescr))
self.emit_varargs(op.args[1:])
self.register_var(op.result)
-
+
+ def handle_residual_oosend(self, op):
+ self.minimize_variables()
+ SELFTYPE, methname, meth = support.lookup_oosend_method(op)
+ methdescr = self.codewriter.get_methdescr(SELFTYPE, methname, False)
+ self.emit('residual_oosend_canraise')
+ self.emit(self.get_position(methdescr))
+ self.emit_varargs(op.args[1:])
+ self.register_var(op.result)
+
def serialize_op_debug_assert(self, op):
pass # for now
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py Tue Apr 28 15:58:36 2009
@@ -456,6 +456,37 @@
res = self.meta_interp(f, [20, 0])
assert hlstr(res) == "string"
+ def test_residual_oosend(self):
+ myjitdriver = JitDriver(greens=[], reds = ['i', 'obj'])
+ class A:
+ def foo(self):
+ return 41
+ class B(A):
+ def foo(self):
+ return 42
+ def new(n):
+ if n:
+ return A()
+ else:
+ return B()
+ def fn(n, i):
+ res = 0
+ obj = new(n)
+ while i > 0:
+ myjitdriver.can_enter_jit(i=i, obj=obj)
+ myjitdriver.jit_merge_point(i=i, obj=obj)
+ res = obj.foo()
+ i-=1
+ return res
+
+ policy = StopAtXPolicy(new, A.foo.im_func, B.foo.im_func)
+ res = self.meta_interp(fn, [0, 20], policy=policy)
+ assert res == 42
+ if self.type_system == 'ootype':
+ self.check_loops(oosend=1)
+ else:
+ self.check_loops(call=1)
+
class TestOOtype(SendTests, OOJitMixin):
pass
More information about the Pypy-commit
mailing list