[pypy-svn] r54091 - in pypy/branch/jit-hotpath/pypy/jit/rainbow: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Apr 24 15:31:17 CEST 2008


Author: antocuni
Date: Thu Apr 24 15:31:17 2008
New Revision: 54091

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py
Log:
yet another kind of oosend, for the case in which the self is green
and thus the bytecode is known at compile time



Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py	Thu Apr 24 15:31:17 2008
@@ -1540,6 +1540,9 @@
                 return 'oopspec', self.can_raise(spaceop)
             if not SELFTYPE._lookup_graphs(methname):
                 return 'builtin', self.can_raise(spaceop)
+            hs_self = self.hannotator.binding(spaceop.args[1])
+            if hs_self.is_green():
+                return 'direct', self.can_raise(spaceop)
         if self.hannotator.bookkeeper.is_green_call(spaceop):
             return 'green', None
         withexc = self.can_raise(spaceop)
@@ -1787,6 +1790,23 @@
         if has_result:
             self.register_redvar(op.result)
 
+    def handle_direct_oosend(self, op, withexc):
+        SELFTYPE, name, opargs = self.decompose_oosend(op)
+        has_result = self.has_result(op)
+        _, meth = SELFTYPE._lookup(name)
+        graph2tsgraph = dict(self.graphs_from(op))
+        targetgraph = graph2tsgraph[meth.graph]
+        graphindex = self.graph_position(targetgraph)
+        bytecode = self.all_graphs[targetgraph]
+        args = targetgraph.getargs()
+        emitted_args = self.args_of_call(op.args[1:], args)
+        assert not self.hannotator.policy.hotpath, 'TODO'
+        self.emit('direct_oosend')
+        self.emit(*emitted_args)
+        self.emit(graphindex)
+        if has_result:
+            self.register_redvar(op.result)
+
     def handle_yellow_oosend(self, op, withexc):
         self.handle_red_oosend(op, withexc)
         self.emit("yellow_retrieve_result_as_red")

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py	Thu Apr 24 15:31:17 2008
@@ -1093,6 +1093,11 @@
         self.run(self.jitstate, bytecode, greenargs, redargs,
                  start_bytecode_loop=False)
 
+    @arguments("green_varargs", "red_varargs", "bytecode")
+    def opimpl_direct_oosend(self, greenargs, redargs, targetbytecode):
+        self.run(self.jitstate, targetbytecode, greenargs, redargs,
+                 start_bytecode_loop=False)
+
     @arguments("methdesc", "green_varargs")
     def opimpl_green_oosend(self, methdesc, greenargs):
         # we pass None as fnptr, since it's not needed/used

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	Thu Apr 24 15:31:17 2008
@@ -1013,6 +1013,21 @@
         assert res == 9
         self.check_insns({})
 
+    def test_direct_oosend_with_green_self(self):
+        class Foo:
+            def __init__(self, x):
+                self.data = [x]
+            def getitem(self, i):
+                return self.data[i]
+
+        obj = Foo(42)
+        def fn(x):
+            obj1 = hint(obj, deepfreeze=True)
+            return obj1.getitem(0)
+        res = self.interpret(fn, [42], [])
+        assert res == 42
+        self.check_insns({'direct_call': 1})
+
     def test_residual_red_call(self):
         def g(x):
             return x+1

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py	Thu Apr 24 15:31:17 2008
@@ -610,7 +610,6 @@
     def _skip(self):
         py.test.skip('in progress')
 
-    test_dfa_compile3 = _skip
     test_method_call_nonpromote = _skip
     test_method_call_promote = _skip
     test_float_promote = _skip



More information about the Pypy-commit mailing list