[pypy-svn] pypy jit-short-preamble: restored original test and added a simpler one

hakanardo commits-noreply at bitbucket.org
Fri Jan 21 12:16:25 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short-preamble
Changeset: r41116:9379e01311ab
Date: 2011-01-20 19:25 +0100
http://bitbucket.org/pypy/pypy/changeset/9379e01311ab/

Log:	restored original test and added a simpler one

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_basic.py
--- a/pypy/jit/metainterp/test/test_basic.py
+++ b/pypy/jit/metainterp/test/test_basic.py
@@ -1908,22 +1908,50 @@
                     x = z
             return res
         def g(x, y):
-            #a1 = f(A(x), y, A(x))
-            #a2 = f(A(x), y, A(x))
-            #assert a1.val == a2.val
-            #return a1.val
-            #b1 = f(B(x), y, B(x))
-            #b2 = f(B(x), y, B(x))
-            #assert b1.val == b2.val
-            #return a1.val + b1.val
+            a1 = f(A(x), y, A(x))
+            a2 = f(A(x), y, A(x))
+            assert a1.val == a2.val
+            b1 = f(B(x), y, B(x))
+            b2 = f(B(x), y, B(x))
+            assert b1.val == b2.val
+            c1 = f(B(x), y, A(x))
+            c2 = f(B(x), y, A(x))
+            assert c1.val == c2.val
+            d1 = f(A(x), y, B(x))
+            d2 = f(A(x), y, B(x))
+            assert d1.val == d2.val
+            return a1.val + b1.val + c1.val + d1.val
+        res = self.meta_interp(g, [3, 14])
+        assert res == g(3, 14)
+
+    def test_failing_inlined_guard(self):
+        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'z', 'res'])
+        class Base:
+            def __init__(self, val):
+                self.val = val
+            def getval(self):
+                return self.val
+        class A(Base):
+            def binop(self, other):
+                return A(self.getval() + other.getval())
+        class B(Base):
+            def binop(self, other):
+                return B(self.getval() * other.getval())
+        def f(x, y, z):
+            res = x
+            while y > 0:
+                myjitdriver.can_enter_jit(y=y, x=x, z=z, res=res)
+                myjitdriver.jit_merge_point(y=y, x=x, z=z, res=res)
+                res = res.binop(x)
+                y -= 1
+                if y < 7:
+                    x = z
+            return res
+        def g(x, y):
             c1 = f(B(x), y, A(x))
             c2 = f(B(x), y, A(x))
             assert c1.val == c2.val
             return c1.val
-            d1 = f(A(x), y, B(x))
-            d2 = f(A(x), y, B(x))
-            assert d1.val == d2.val
-            return a1.val + b1.val + c1.val + d1.val
         res = self.meta_interp(g, [3, 14])
         assert res == g(3, 14)
 


More information about the Pypy-commit mailing list