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

ac at codespeak.net ac at codespeak.net
Thu Jan 25 12:12:31 CET 2007


Author: ac
Date: Thu Jan 25 12:12:30 2007
New Revision: 37321

Modified:
   pypy/dist/pypy/jit/timeshifter/hrtyper.py
   pypy/dist/pypy/jit/timeshifter/rcontainer.py
   pypy/dist/pypy/jit/timeshifter/rtimeshift.py
   pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
   pypy/dist/pypy/jit/timeshifter/transform.py
Log:
(pedronis, arre) Fix a test for a virtualizable escaping as a returnvalue
and fix the uncovered bug.
Add a test for a virtualizable escaping as an argument to a residual call.



Modified: pypy/dist/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/hrtyper.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/hrtyper.py	Thu Jan 25 12:12:30 2007
@@ -1381,13 +1381,6 @@
     def translate_op_residual_gray_call(self, hop):
         self.translate_op_residual_red_call(hop, color='gray')
 
-    def translate_op_prepare_residual_call(self, hop):
-        v_jitstate = hop.llops.getjitstate()        
-        return hop.llops.genmixlevelhelpercall(rtimeshift.prepare_residual_call,
-                                               [self.s_JITState],
-                                               [v_jitstate],
-                                               annmodel.s_None)
-
     def translate_op_after_residual_call(self, hop):
         v_jitstate = hop.llops.getjitstate()        
         return hop.llops.genmixlevelhelpercall(rtimeshift.after_residual_call,

Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py	Thu Jan 25 12:12:30 2007
@@ -638,12 +638,16 @@
 
     def getgenvar(self, jitstate):
         typedesc = self.typedesc
-        builder = jitstate.curbuilder
         gv_outside = self.content_boxes[-1].genvar
         if gv_outside is typedesc.gv_null:
+            assert isinstance(typedesc, VirtualizableStructTypeDesc)
+            builder = jitstate.curbuilder
             gv_outside = builder.genop_malloc_fixedsize(typedesc.alloctoken)
             self.content_boxes[-1].genvar = gv_outside
             jitstate.add_virtualizable(self.ownbox)
+            access_token = typedesc.access_desc.fieldtoken            
+            gv_access_null = typedesc.access_desc.gv_default
+            builder.genop_setfield(access_token, gv_outside, gv_access_null)
         return gv_outside
 
     def store_back(self, jitstate):

Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py	Thu Jan 25 12:12:30 2007
@@ -466,12 +466,10 @@
     gv_funcbox = funcbox.getgenvar(jitstate)
     argboxes = jitstate.frame.local_boxes
     args_gv = [argbox.getgenvar(jitstate) for argbox in argboxes]
+    jitstate.prepare_for_residual_call()
     gv_result = builder.genop_call(calldesc.sigtoken, gv_funcbox, args_gv)
     return calldesc.redboxbuilder(calldesc.result_kind, gv_result)
 
-def prepare_residual_call(jitstate):
-    jitstate.prepare_for_residual_call()
-
 def after_residual_call(jitstate):
     return jitstate.after_residual_call()
 

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	Thu Jan 25 12:12:30 2007
@@ -282,7 +282,7 @@
 
         def main(x, y):
             xy = f(x, y)
-            return xy.x+xy.y
+            return xy_get_x(xy)+xy_get_y(xy)
 
         res = self.timeshift_from_portal(main, f, [20, 22], policy=P_OOPSPEC)
         assert res == 42
@@ -670,7 +670,31 @@
                                          policy=StopAtXPolicy(g))
         assert res == 42 + 140 + 10
 
+    def test_virtualizable_escaped_as_argument_to_red_call(self):
+        def g(xy):
+            x = xy_get_x(xy)
+            y = xy_get_y(xy)
+            return y*2 + x
+
+        def f(x, y):
+            hint(None, global_merge_point=True)
+            xy = lltype.malloc(XY)
+            xy.vable_access = lltype.nullptr(XY_ACCESS)
+            xy.x = x
+            xy.y = y
+            r = g(xy)
+            x = xy_get_x(xy)
+            y = xy_get_y(xy)
+            return r
+        
+        def main(x, y):
+            return f(x,y)
+        
+        res = self.timeshift_from_portal(main, f, [20, 11],
+                                         policy=StopAtXPolicy(g))
 
+        assert res == 42
+        
 class TestVirtualizableImplicit(PortalTest):
 
     def test_simple(self):

Modified: pypy/dist/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/transform.py	Thu Jan 25 12:12:30 2007
@@ -742,7 +742,6 @@
         # pseudo-obscure: the arguments for the call go in save_locals
         args_v = [v for v in args_v if v.concretetype is not lltype.Void]
         self.genop(newops, 'save_locals', args_v)
-        self.genop(newops, 'prepare_residual_call', [])
         call_index = len(newops)
         v_res = self.genop(newops, 'residual_%s_call' % (color,),
                            [op.args[0]], result_like = op.result)



More information about the Pypy-commit mailing list