[pypy-svn] pypy default: recreated the issue from test_pypy_c_new.test_f1
hakanardo
commits-noreply at bitbucket.org
Sun Mar 13 12:03:15 CET 2011
Author: Hakan Ardo <hakan at debian.org>
Branch:
Changeset: r42554:b7dfa411c360
Date: 2011-03-13 12:02 +0100
http://bitbucket.org/pypy/pypy/changeset/b7dfa411c360/
Log: recreated the issue from test_pypy_c_new.test_f1
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,54 @@
res = self.meta_interp(f, [25, th])
assert res == expected
+ def test_nested_loops_discovered_by_bridge_virtual(self):
+ # Same loop as above, but with virtuals
+ class A:
+ def __init__(self, val):
+ self.val = val
+ def add(self, val):
+ return A(self.val + val)
+ myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'j', 'n', 'x'])
+ bytecode = "IzJxji"
+ def f(nval, threshold):
+ myjitdriver.set_param('threshold', threshold)
+ i, j, x = A(0), A(0), A(0)
+ n = A(nval)
+ pos = 0
+ op = '-'
+ while pos < len(bytecode):
+ myjitdriver.jit_merge_point(pos=pos, i=i, j=j, n=n, x=x)
+ op = bytecode[pos]
+ if op == 'z':
+ j = A(0)
+ elif op == 'i':
+ i = i.add(1)
+ pos = 0
+ myjitdriver.can_enter_jit(pos=pos, i=i, j=j, n=n, x=x)
+ continue
+ elif op == 'j':
+ j = j.add(1)
+ pos = 2
+ myjitdriver.can_enter_jit(pos=pos, i=i, j=j, n=n, x=x)
+ continue
+ elif op == 'I':
+ if not (i.val < n.val):
+ pos = 5
+ elif op == 'J':
+ if not (j.val <= i.val):
+ pos = 4
+ elif op == 'x':
+ x = x.add(i.val & j.val)
+
+ pos += 1
+
+ return x.val
+
+ for th in (5, 3, 1, 2, 4): # Start with the interesting case
+ expected = f(25, th)
+ 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"
diff --git a/pypy/jit/metainterp/test/test_virtual.py b/pypy/jit/metainterp/test/test_virtual.py
--- a/pypy/jit/metainterp/test/test_virtual.py
+++ b/pypy/jit/metainterp/test/test_virtual.py
@@ -740,6 +740,23 @@
return i.value + j.value
assert self.meta_interp(f, []) == 20
+ def test_virtual_skipped_by_bridge(self):
+ myjitdriver = JitDriver(greens = [], reds = ['n', 'm', 'i', 'x'])
+ def f(n, m):
+ x = self._new()
+ x.value = 0
+ i = 0
+ while i < n:
+ myjitdriver.can_enter_jit(n=n, m=m, i=i, x=x)
+ myjitdriver.jit_merge_point(n=n, m=m, i=i, x=x)
+ if i&m != m:
+ newx = self._new()
+ newx.value = x.value + i
+ x = newx
+ i = i + 1
+ return x.value
+ res = self.meta_interp(f, [0x1F, 0x11])
+ assert res == f(0x1F, 0x11)
class VirtualMiscTests:
More information about the Pypy-commit
mailing list