[pypy-svn] r52135 - in pypy/branch/jit-refactoring/pypy/jit/rainbow: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Mar 4 10:48:04 CET 2008


Author: cfbolz
Date: Tue Mar  4 10:48:02 2008
New Revision: 52135

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
Log:
translation issues with void args


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Tue Mar  4 10:48:02 2008
@@ -34,7 +34,14 @@
         self.redboxbuilder = rvalue.ll_redboxbuilder(FUNCTYPE.TO.RESULT)
         whatever_return_value = FUNCTYPE.TO.RESULT._defl()
         numargs = len(FUNCTYPE.TO.ARGS)
+        voidargcount = 0
+        for ARG in FUNCTYPE.TO.ARGS:
+            if ARG == lltype.Void:
+                voidargcount += 1
+        if len(voidargs) != voidargcount:
+            voidargs = (None, ) * voidargcount
         argiter = unrolling_iterable(FUNCTYPE.TO.ARGS)
+        RETURN = FUNCTYPE.TO.RESULT
         def green_call(interpreter, fnptr_gv, greenargs):
             fnptr = fnptr_gv.revealconst(FUNCTYPE)
             assert len(greenargs) + len(voidargs) == numargs 
@@ -58,14 +65,15 @@
                     j += 1
             rgenop = interpreter.jitstate.curbuilder.rgenop
             try:
-                result = rgenop.genconst(fnptr(*args))
+                result = fnptr(*args)
             except Exception, e:
                 if not we_are_translated():
                     residual_exception_nontranslated(interpreter.jitstate, e, rtyper)
                 else:
                     interpreter.jitstate.residual_exception(e)
-                result = rgenop.genconst(whatever_return_value)
-            interpreter.green_result(result)
+                result = whatever_return_value
+            if RETURN != lltype.Void:
+                interpreter.green_result(rgenop.genconst(result))
         self.green_call = green_call
 
     def _freeze_(self):

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Tue Mar  4 10:48:02 2008
@@ -592,12 +592,24 @@
         def ll_function(y):
             z = ll_add_one(y)
             z = hint(z, concrete=True)
-            return hint(z, variable=True)
+            return z
 
         res = self.interpret(ll_function, [3], [0])
         assert res == 4
         self.check_insns({})
 
+    def test_green_call_void_return(self):
+        def ll_boring(x):
+            return
+        def ll_function(y):
+            z = ll_boring(y)
+            z = hint(y, concrete=True)
+            return z
+
+        res = self.interpret(ll_function, [3], [0])
+        assert res == 3
+        self.check_insns({})
+
     def test_split_on_green_return(self):
         def ll_two(x):
             if x > 0:
@@ -1840,23 +1852,6 @@
         res = self.interpret(main2, [5, 6], policy=StopAtXPolicy(g))
         assert res == 11
 
-    def test_indirect_call_voidargs(self):
-        class Void(object):
-            def _freeze_(self):
-                return True
-        void = Void()
-        def h1(n, v):
-            return n*2
-        def h2(n, v):
-            return n*4
-        l = [h1, h2]
-        def f(n, x):
-            h = l[n&1]
-            return h(n, void) + x
-
-        res = self.interpret(f, [7, 3])
-        assert res == f(7, 3)
-        self.check_insns(indirect_call=1, direct_call=1)
             
 
 class TestLLType(SimpleTests):

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	Tue Mar  4 10:48:02 2008
@@ -535,3 +535,22 @@
             return indirection(green, red)
         res = self.timeshift_from_portal(portal, portal, [41, 1], policy=P_NOVIRTUAL)
         assert res == 0
+
+
+    def test_indirect_call_voidargs(self):
+        class Void(object):
+            def _freeze_(self):
+                return True
+        void = Void()
+        def h1(n, v):
+            return n*2
+        def h2(n, v):
+            return n*4
+        l = [h1, h2]
+        def f(n, x):
+            h = l[n&1]
+            return h(n, void) + x
+
+        res = self.timeshift_from_portal(f, f, [7, 3])
+        assert res == f(7, 3)
+        self.check_insns(indirect_call=1, direct_call=1)



More information about the Pypy-commit mailing list