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

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Feb 29 20:19:46 CET 2008


Author: cfbolz
Date: Fri Feb 29 20:19:45 2008
New Revision: 51966

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
Log:
fix two more tests


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	Fri Feb 29 20:19:45 2008
@@ -685,39 +685,46 @@
         kind, withexc = self.guess_call_kind(op)
         targets = dict(self.graphs_from(op))
         fnptrindex = self.serialize_oparg("red", op.args[0])
-        self.emit("goto_if_constant", fnptrindex, tlabel(("direct call", op)))
+        has_result = (self.varcolor(op.result) != "gray" and
+                      op.result.concretetype != lltype.Void)
+        if targets:
+            self.emit("goto_if_constant", fnptrindex, tlabel(("direct call", op)))
+
         emitted_args = []
         for v in op.args[1:-1]:
             emitted_args.append(self.serialize_oparg("red", v))
         self.emit("red_residual_call")
         calldescindex = self.calldesc_position(op.args[0].concretetype)
-        self.emit(fnptrindex, calldescindex, withexc, kind != "gray")
+        self.emit(fnptrindex, calldescindex, withexc, has_result)
         self.emit(len(emitted_args), *emitted_args)
         self.emit(self.promotiondesc_position(lltype.Signed))
-        self.emit("goto", tlabel(("after indirect call", op)))
-
-        self.emit(label(("direct call", op)))
-        args = targets.values()[0].getargs()
-        emitted_args = self.args_of_call(op.args[1:-1], args)
-        self.emit("indirect_call_const")
-        self.emit(*emitted_args)
-        setdescindex = self.indirectcalldesc_position(targets)
-        self.emit(fnptrindex, setdescindex)
 
-        if kind == "red":
-            self.emit("red_after_direct_call")
-            self.register_redvar(op.result)
-        elif kind == "yellow":
-            self.emit("yellow_after_direct_call")
-            self.emit("yellow_retrieve_result_as_red")
-            self.emit(self.type_position(op.result.concretetype))
+        if has_result:
             self.register_redvar(op.result)
-        elif kind == "gray":
-            self.emit("red_after_direct_call")
-        else:
-            XXX
 
-        self.emit(label(("after indirect call", op)))
+        if targets:
+            self.emit("goto", tlabel(("after indirect call", op)))
+
+            self.emit(label(("direct call", op)))
+            args = targets.values()[0].getargs()
+            emitted_args = self.args_of_call(op.args[1:-1], args)
+            self.emit("indirect_call_const")
+            self.emit(*emitted_args)
+            setdescindex = self.indirectcalldesc_position(targets)
+            self.emit(fnptrindex, setdescindex)
+
+            if kind == "red":
+                self.emit("red_after_direct_call")
+            elif kind == "yellow":
+                self.emit("yellow_after_direct_call")
+                self.emit("yellow_retrieve_result_as_red")
+                self.emit(self.type_position(op.result.concretetype))
+            elif kind == "gray":
+                self.emit("red_after_direct_call")
+            else:
+                XXX
+
+            self.emit(label(("after indirect call", op)))
 
     def handle_oopspec_call(self, op, withexc):
         from pypy.jit.timeshifter.oop import Index

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	Fri Feb 29 20:19:45 2008
@@ -17,8 +17,11 @@
 from pypy.rlib.debug import ll_assert
 from pypy.rlib.jit import hint
 from pypy.rlib.objectmodel import keepalive_until_here
+from pypy.rlib.rarithmetic import ovfcheck
 from pypy import conftest
 
+import sys
+
 P_NOVIRTUAL = HintAnnotatorPolicy(novirtualcontainer=True)
 P_OOPSPEC = HintAnnotatorPolicy(novirtualcontainer=True, oopspec=True)
 P_OOPSPEC_NOVIRTUAL = HintAnnotatorPolicy(oopspec=True,
@@ -1383,7 +1386,6 @@
         assert res == f(7,3)
 
     def test_indirect_residual_red_call(self):
-        py.test.skip("not working yet")
         def h1(n):
             return n*2
         def h2(n):
@@ -1464,39 +1466,31 @@
         self.check_insns({})
 
     def test_manual_marking_of_pure_functions(self):
-        py.test.skip("not working yet")
-        class A(object):
-            pass
-        class B(object):
-            pass
-        a1 = A()
-        a2 = A()
         d = {}
-        def h1(b, s):
+        def h1(s):
             try:
                 return d[s]
             except KeyError:
-                d[s] = r = A()
+                d[s] = r = s * 15
                 return r
         h1._pure_function_ = True
-        b = B()
         def f(n):
             hint(None, global_merge_point=True)
             hint(n, concrete=True)
             if n == 0:
-                s = "abc"
+                s = 123
             else:
-                s = "123"
-            a = h1(b, s)
-            return hint(n, variable=True)
+                s = 567
+            a = h1(s)
+            return hint(a, variable=True)
 
         P = StopAtXPolicy(h1)
         P.oopspec = True
         res = self.interpret(f, [0], [], policy=P)
-        assert res == 0
+        assert res == 123 * 15
         self.check_insns({})
         res = self.interpret(f, [4], [], policy=P)
-        assert res == 4
+        assert res == 567 * 15
         self.check_insns({})
 
 



More information about the Pypy-commit mailing list