[pypy-svn] pypy jit-virtual_state: make sure we dont mix up target and source loop tokens

hakanardo commits-noreply at bitbucket.org
Wed Feb 9 08:15:36 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-virtual_state
Changeset: r41720:ee08b4b4c98f
Date: 2011-02-09 08:13 +0100
http://bitbucket.org/pypy/pypy/changeset/ee08b4b4c98f/

Log:	make sure we dont mix up target and source loop tokens

diff --git a/pypy/jit/metainterp/test/test_loop.py b/pypy/jit/metainterp/test/test_loop.py
--- a/pypy/jit/metainterp/test/test_loop.py
+++ b/pypy/jit/metainterp/test/test_loop.py
@@ -400,6 +400,51 @@
             res = self.meta_interp(f, [25, th])
             assert res == expected
 
+    def test_two_bridged_loops(self):
+        myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'n', 's', 'x'])
+        bytecode = "zI7izI8i"
+        def f(n, s):
+            i = x = 0
+            pos = 0
+            op = '-'
+            while pos < len(bytecode):
+                myjitdriver.jit_merge_point(pos=pos, i=i, n=n, s=s, x=x)
+                op = bytecode[pos]
+                if op == 'z':
+                    i = 0
+                if op == 'i':
+                    i += 1
+                    pos -= 2
+                    myjitdriver.can_enter_jit(pos=pos, i=i, n=n, s=s, x=x)
+                    continue
+                elif op == 'I':
+                    if not (i < n):
+                        pos += 2
+                elif op == '7':
+                    if s==1: 
+                        x = x + 7
+                    else:
+                        x = x + 2
+                elif op == '8':
+                    if s==1: 
+                        x = x + 8
+                    else:
+                        x = x + 3
+
+                pos += 1
+            return x
+        
+        def g(n, s):
+            sa = 0
+            for i in range(7):
+                sa += f(n, s)
+            return sa
+        assert self.meta_interp(g, [25, 1]) == 7 * 25 * (7 + 8) 
+
+        def h(n):
+            return g(n, 1) + g(n, 2)
+        assert self.meta_interp(h, [25]) == 7 * 25 * (7 + 8 + 2 + 3) 
+        
     def test_three_nested_loops(self):
         myjitdriver = JitDriver(greens = ['i'], reds = ['x'])
         bytecode = ".+357"


More information about the Pypy-commit mailing list