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

arigo at codespeak.net arigo at codespeak.net
Sun Feb 4 10:40:01 CET 2007


Author: arigo
Date: Sun Feb  4 10:39:59 2007
New Revision: 37892

Modified:
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(from pedronis)

Test and fix: don't use PtrRedBox() to build boxes that are not
necessarily pointers.



Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py	Sun Feb  4 10:39:59 2007
@@ -1624,9 +1624,8 @@
 
     def build_portal_arg_helpers(self):
         typedesc = self.gettypedesc()
-        names = unrolling_iterable([(fielddesc.fieldname, j)
-                                    for (fielddesc, j) in
-                                    typedesc.redirected_fielddescs])
+        redirected_fielddescs = unrolling_iterable(
+                                    typedesc.redirected_fielddescs)
         TYPE = self.original_concretetype
         kind = self.hrtyper.RGenOp.kindToken(TYPE)
 
@@ -1634,13 +1633,12 @@
             box = typedesc.factory()
             jitstate.add_virtualizable(box)
             content = box.content
-            assert isinstance(content, rcontainer.VirtualStruct)
+            assert isinstance(content, rcontainer.VirtualizableStruct)
             content_boxes = content.content_boxes
             gv_outside = inputargs_gv[i]
             i += 1
-            for name, j in names:
-                content_boxes[j] = rvalue.PtrRedBox(content_boxes[j].kind,
-                                                    inputargs_gv[i])
+            for fieldesc, j in redirected_fielddescs:
+                content_boxes[j] = fieldesc.makebox(None, inputargs_gv[i])
                 i += 1
             content_boxes[-1] = rvalue.PtrRedBox(content_boxes[-1].kind,
                                                  gv_outside,

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 10:39:59 2007
@@ -1283,3 +1283,47 @@
         res = self.timeshift_from_portal(main, f, [20, 3],
                                          policy=StopAtXPolicy(g))
         assert res == 222
+
+    def test_type_bug(self):
+        class V(object):
+            _virtualizable_ = True
+
+            def __init__(self, v):
+                self.v = v
+
+        def f(x, v):
+            if x:
+                v.v = 0
+            else:
+                pass
+            return x*2, v
+
+        def main(x,y):
+            v = V(y)
+            r, _ = f(x, v)
+            return r
+
+        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):
+            return n * 8
+
+        l = [h2, h1]
+
+        def f(n):
+            h = l[n & 1]
+            n += 10
+            return h(n)      # the result of the call is not in save_locals!!
+
+        P = StopAtXPolicy()
+
+        assert f(-3) == 42
+        res = self.timeshift(f, [-3], [], policy=P)
+        assert res == 42
+        res = self.timeshift(f, [4], [], policy=P)
+        assert res == 112



More information about the Pypy-commit mailing list