[pypy-svn] r36383 - in pypy/dist/pypy/jit/timeshifter: . test

pedronis at codespeak.net pedronis at codespeak.net
Tue Jan 9 18:57:29 CET 2007


Author: pedronis
Date: Tue Jan  9 18:57:26 2007
New Revision: 36383

Modified:
   pypy/dist/pypy/jit/timeshifter/rcontainer.py
   pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(arre, pedronis)

let virtualizable struct be constructed in timeshifted code, with test.



Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py	Tue Jan  9 18:57:26 2007
@@ -85,6 +85,8 @@
         if TYPE._hints.get('virtualizable', False):
             self.__class__ = VirtualizableStructTypeDesc
             self.VStructCls = VirtualizableStruct
+            outside_null = self.PTRTYPE._defl()
+            self.gv_defl_outside = RGenOp.constPrebuiltGlobal(outside_null)
         else:
             self.VStructCls = VirtualStruct
             
@@ -129,8 +131,8 @@
         vstruct = VirtualizableStruct(self)
         vstruct.content_boxes = [desc.redboxcls(desc.kind, desc.gv_default)
                                  for desc in self.fielddescs]
-        outsidebox = rvalue.PtrRedBox(self.innermostdesc.ptrkind)
-        # xxx set outsidebox.genvar
+        outsidebox = rvalue.PtrRedBox(self.innermostdesc.ptrkind,
+                                      self.gv_defl_outside)
         vstruct.content_boxes.append(outsidebox)
         box = rvalue.PtrRedBox(self.innermostdesc.ptrkind)
         box.content = vstruct

Modified: pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py	Tue Jan  9 18:57:26 2007
@@ -189,3 +189,28 @@
         assert res == 23
         self.check_insns(getfield=0)
 
+    def test_simple_explicit_construct_no_escape(self):
+   
+        def f(x, y):
+            xy = lltype.malloc(XY)
+            xy.access = lltype.nullptr(XY_ACCESS)
+            xy.x = x
+            xy.y = y
+            xy_access = xy.access
+            if xy_access:
+                x = xy_access.get_x(xy)
+            else:
+                x = xy.x
+            xy_access = xy.access
+            if xy_access:
+                y = xy_access.get_y(xy)
+            else:
+                y = xy.y
+            return x+y
+
+        def main(x, y):
+            return f(x, y)
+
+        res = self.timeshift_from_portal(main, f, [20, 22], policy=P_NOVIRTUAL)
+        assert res == 42
+        self.check_insns(getfield=0)



More information about the Pypy-commit mailing list