[pypy-commit] pypy default: Add a test similar to test_unerased_pointers_in_short_preamble,

arigo noreply at buildbot.pypy.org
Sat Aug 6 20:59:18 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r46334:3ad1fe3d9b69
Date: 2011-08-06 21:00 +0200
http://bitbucket.org/pypy/pypy/changeset/3ad1fe3d9b69/

Log:	Add a test similar to test_unerased_pointers_in_short_preamble, but
	using only regular pointers. Note that neither test appears to be
	failing right now, unlike the comment in 2ca138be14a7...

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
@@ -800,6 +800,38 @@
 
         res = self.meta_interp(f, [200])
 
+    def test_regular_pointers_in_short_preamble(self):
+        from pypy.rpython.lltypesystem import lltype
+        class Base(object):
+            pass
+        class A(Base):
+            def __init__(self, val):
+                self.val = val
+        class B(Base):
+            def __init__(self, charval):
+                self.charval = charval
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'm', 'i', 'j', 'sa', 'p'])
+        def f(n, m, j):
+            i = sa = 0
+            p = A(7)
+            while i < n:
+                myjitdriver.jit_merge_point(n=n, m=m, i=i, j=j, sa=sa, p=p)
+                if i < m:
+                    assert isinstance(p, A)
+                    sa += p.val
+                elif i == m:
+                    p = B('x')
+                    p.charval = 'y'
+                else:
+                    assert isinstance(p, B)
+                    sa += ord(p.charval)
+                sa += A(i).val
+                assert n>0 and m>0
+                i += j
+            return sa
+        expected = f(20, 10, 1)
+        res = self.meta_interp(f, [20, 10, 1])
+        assert res == expected
 
     def test_unerased_pointers_in_short_preamble(self):
         from pypy.rlib.rerased import new_erasing_pair


More information about the pypy-commit mailing list