[pypy-svn] r37895 - in pypy/branch/jit-virtual-world/pypy/jit/timeshifter: . test

arigo at codespeak.net arigo at codespeak.net
Sun Feb 4 12:49:14 CET 2007


Author: arigo
Date: Sun Feb  4 12:48:55 2007
New Revision: 37895

Modified:
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
Log:
(pedronis, arigo)

Test and fix for a save_locals() that didn't include most of the variables it should.


Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py	Sun Feb  4 12:48:55 2007
@@ -1306,24 +1306,35 @@
         res = self.timeshift_from_portal(main, f, [20, 3], policy=P_OOPSPEC)
         assert res == 40
 
-    def test_indirect_call(self):
-        py.test.skip("test in progress")
-        def h1(n):
-            return n * 6   # force some virtualizable stuff here
-        def h2(n):
+    def test_indirect_residual_call(self):
+        class V(object):
+            _virtualizable_ = True
+
+            def __init__(self, v):
+                self.v = v
+
+        def g(v, n):
+            v.v.append(n)      # force the virtualizable arg here
+        def h1(v, n):
+            g(v, n)
+            return n * 6
+        def h2(v, n):
             return n * 8
 
         l = [h2, h1]
 
         def f(n):
+            hint(None, global_merge_point=True)
+            v = V([100])
             h = l[n & 1]
             n += 10
-            return h(n)      # the result of the call is not in save_locals!!
+            res = h(v, n)
+            return res - v.v.pop()
 
-        P = StopAtXPolicy()
+        P = StopAtXPolicy(g)
 
-        assert f(-3) == 42
-        res = self.timeshift(f, [-3], [], policy=P)
-        assert res == 42
-        res = self.timeshift(f, [4], [], policy=P)
-        assert res == 112
+        assert f(-3) == 35
+        res = self.timeshift_from_portal(f, f, [-3], policy=P)
+        assert res == 35
+        res = self.timeshift_from_portal(f, f, [4], policy=P)
+        assert res == 12

Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py	Sun Feb  4 12:48:55 2007
@@ -8,7 +8,6 @@
 from pypy.translator.unsimplify import varoftype, copyvar
 from pypy.translator.unsimplify import split_block, split_block_at_start
 from pypy.translator.backendopt.ssa import SSA_to_SSI
-from pypy.translator.unsimplify import split_block
 
 
 class MergePointFamily(object):
@@ -628,15 +627,17 @@
         postconstantblock.recloseblock(Link([], resumeblock))
 
         if nonconstantblock is not None:
+            nonconstantblock.recloseblock(Link(linkargs, nextblock))
             v_res, nonconstantblock2 = self.handle_residual_call_details(
                                             nonconstantblock, 0, op,
-                                            color, preserve_res = False)
+                                            color, preserve_res =
+                                            (color == 'red'))
 
-            if color == 'red':
-                linkargs[0] = v_res
+            #if color == 'red':
+            #    linkargs[0] = v_res
 
             blockset[nonconstantblock2] = False            
-            nonconstantblock2.recloseblock(Link(linkargs, nextblock))
+            
 
         blockset[block] = True     # reachable from outside
         blockset[nextblock] = True # reachable from outside



More information about the Pypy-commit mailing list