[pypy-svn] r68423 - in pypy/trunk/pypy/jit/metainterp: . test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Oct 14 11:41:34 CEST 2009
Author: antocuni
Date: Wed Oct 14 11:41:33 2009
New Revision: 68423
Modified:
pypy/trunk/pypy/jit/metainterp/pyjitpl.py
pypy/trunk/pypy/jit/metainterp/test/test_basic.py
pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
generate a guard_class before instanceof when doing isinstance(): this mimics what lltype does and make it possible to remove a lot of guards during the optimization phase
Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py Wed Oct 14 11:41:33 2009
@@ -318,8 +318,12 @@
self.execute(rop.RUNTIMENEW, classbox)
@arguments("box", "descr")
- def opimpl_instanceof(self, box, typedescr):
- self.execute_with_descr(rop.INSTANCEOF, typedescr, box)
+ def opimpl_instanceof(self, objbox, typedescr):
+ frame = self.metainterp.framestack[-1]
+ clsbox = self.cls_of_box(objbox)
+ if isinstance(objbox, Box):
+ self.generate_guard(frame.pc, rop.GUARD_CLASS, objbox, [clsbox])
+ self.execute_with_descr(rop.INSTANCEOF, typedescr, objbox)
@arguments("box", "box")
def opimpl_subclassof(self, box1, box2):
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 Wed Oct 14 11:41:33 2009
@@ -746,6 +746,7 @@
return isinstance(obj, B)
res = self.interp_operations(fn, [0])
assert res
+ self.check_history_(guard_class=1)
res = self.interp_operations(fn, [1])
assert not res
Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py Wed Oct 14 11:41:33 2009
@@ -1799,3 +1799,16 @@
"""
self.optimize_loop(ops, 'Not', expected)
+ def test_instanceof_guard_class(self):
+ ops = """
+ [i0, p0]
+ guard_class(p0, ConstClass(node_vtable)) []
+ i1 = instanceof(p0, descr=nodesize)
+ jump(i1, p0)
+ """
+ expected = """
+ [i0, p0]
+ guard_class(p0, ConstClass(node_vtable)) []
+ jump(1, p0)
+ """
+ self.optimize_loop(ops, 'Not, Not', expected)
More information about the Pypy-commit
mailing list