[pypy-svn] r76901 - pypy/branch/jit-bounds/pypy/jit/metainterp/test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Sep 6 18:52:06 CEST 2010


Author: cfbolz
Date: Mon Sep  6 18:52:05 2010
New Revision: 76901

Modified:
   pypy/branch/jit-bounds/pypy/jit/metainterp/test/test_basic.py
Log:
Unfortunately, this test passes nicely


Modified: pypy/branch/jit-bounds/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/jit-bounds/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/jit-bounds/pypy/jit/metainterp/test/test_basic.py	Mon Sep  6 18:52:05 2010
@@ -455,6 +455,31 @@
         # the CALL_PURE is constant-folded away by optimizeopt.py
         self.check_loops(int_sub=1, call=0, call_pure=0)
 
+    def test_pure_function_returning_object(self):
+        myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
+        class V:
+            def __init__(self, x):
+                self.x = x
+        v1 = V(1)
+        v2 = V(2)
+        def externfn(x):
+            if x:
+                return v1
+            else:
+                return v2
+        externfn._pure_function_ = True
+        def f(n, m):
+            while n > 0:
+                myjitdriver.can_enter_jit(n=n, m=m)
+                myjitdriver.jit_merge_point(n=n, m=m)
+                m = V(m).x
+                n -= externfn(m).x + externfn(m + m - m).x
+            return n
+        res = self.meta_interp(f, [21, 5])
+        assert res == -1
+        # the CALL_PURE is constant-folded away by optimizeopt.py
+        self.check_loops(int_sub=1, call=0, call_pure=0, getfield_gc=1)
+
     def test_constant_across_mp(self):
         myjitdriver = JitDriver(greens = [], reds = ['n'])
         class X(object):



More information about the Pypy-commit mailing list