[pypy-svn] r69126 - in pypy/trunk/pypy/jit: backend/cli metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Nov 10 17:50:33 CET 2009
Author: antocuni
Date: Tue Nov 10 17:50:32 2009
New Revision: 69126
Modified:
pypy/trunk/pypy/jit/backend/cli/method.py
pypy/trunk/pypy/jit/metainterp/test/test_basic.py
Log:
add a test for guard_nonnull and guard_isnull, and implement them in the cli backend
Modified: pypy/trunk/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/cli/method.py (original)
+++ pypy/trunk/pypy/jit/backend/cli/method.py Tue Nov 10 17:50:32 2009
@@ -471,6 +471,12 @@
def emit_op_guard_false(self, op):
self.emit_guard_bool(op, OpCodes.Brtrue)
+ def emit_op_guard_nonnull(self, op):
+ self.emit_guard_bool(op, OpCodes.Brfalse)
+
+ def emit_op_guard_isnull(self, op):
+ self.emit_guard_bool(op, OpCodes.Brtrue)
+
def emit_op_guard_value(self, op):
assert len(op.args) == 2
il_label = self.newbranch(op)
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 Tue Nov 10 17:50:32 2009
@@ -1049,6 +1049,35 @@
res = self.meta_interp(f, [20], listops=True)
self.check_loops(getfield_gc=1, getarrayitem_gc=0)
+ def test_guard_isnull_nonnull(self):
+ myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
+ class A(object):
+ pass
+
+ @dont_look_inside
+ def create(x):
+ if x >= -40:
+ return A()
+ return None
+
+ def f(x):
+ res = 0
+ while x > 0:
+ myjitdriver.can_enter_jit(x=x, res=res)
+ myjitdriver.jit_merge_point(x=x, res=res)
+ obj = create(x-1)
+ if obj is not None:
+ res += 1
+ obj2 = create(x-1000)
+ if obj2 is None:
+ res += 1
+ x -= 1
+ return res
+ res = self.meta_interp(f, [21])
+ assert res == 42
+ self.check_loops(guard_nonnull=1, guard_isnull=1)
+
+
class TestOOtype(BasicTests, OOJitMixin):
def test_oohash(self):
More information about the Pypy-commit
mailing list