[pypy-svn] r69080 - in pypy/trunk/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Mon Nov 9 11:16:02 CET 2009
Author: fijal
Date: Mon Nov 9 11:16:01 2009
New Revision: 69080
Modified:
pypy/trunk/pypy/jit/metainterp/pyjitpl.py
pypy/trunk/pypy/jit/metainterp/test/test_basic.py
Log:
(arigo, fijal) Fix instanceof with test
Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py Mon Nov 9 11:16:01 2009
@@ -320,12 +320,11 @@
def opimpl_runtimenew(self, classbox):
self.execute(rop.RUNTIMENEW, classbox)
- @arguments("box", "descr")
- def opimpl_instanceof(self, objbox, typedescr):
- frame = self.metainterp.framestack[-1]
+ @arguments("orgpc", "box", "descr")
+ def opimpl_instanceof(self, pc, objbox, typedescr):
clsbox = self.cls_of_box(objbox)
if isinstance(objbox, Box):
- self.generate_guard(frame.pc, rop.GUARD_CLASS, objbox, [clsbox])
+ self.generate_guard(pc, rop.GUARD_CLASS, objbox, [clsbox])
self.execute_with_descr(rop.INSTANCEOF, typedescr, objbox)
@arguments("box", "box")
Modified: pypy/trunk/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_basic.py Mon Nov 9 11:16:01 2009
@@ -757,6 +757,31 @@
res = self.interp_operations(fn, [1])
assert not res
+ def test_isinstance_2(self):
+ driver = JitDriver(greens = [], reds = ['x', 'n', 'sum'])
+ class A:
+ pass
+ class B(A):
+ pass
+ class C(B):
+ pass
+
+ def main():
+ return f(5, B()) * 10 + f(5, C()) + f(5, A()) * 100
+
+ def f(n, x):
+ sum = 0
+ while n > 0:
+ driver.can_enter_jit(x=x, n=n, sum=sum)
+ driver.jit_merge_point(x=x, n=n, sum=sum)
+ if isinstance(x, B):
+ sum += 1
+ n -= 1
+ return sum
+
+ res = self.meta_interp(main, [])
+ assert res == 55
+
def test_assert_isinstance(self):
class A:
pass
More information about the Pypy-commit
mailing list