[pypy-svn] r70729 - in pypy/branch/direct-assembler-call/pypy/jit: backend/llgraph backend/x86/test metainterp metainterp/test

fijal at codespeak.net fijal at codespeak.net
Wed Jan 20 16:28:53 CET 2010


Author: fijal
Date: Wed Jan 20 16:28:52 2010
New Revision: 70729

Modified:
   pypy/branch/direct-assembler-call/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/direct-assembler-call/pypy/jit/backend/x86/test/test_recursive.py
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmspot.py
Log:
(pedronis, fijal) Hack a bit to make forcing work as expected.


Modified: pypy/branch/direct-assembler-call/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/backend/llgraph/llimpl.py	Wed Jan 20 16:28:52 2010
@@ -818,26 +818,34 @@
 
     def op_call_assembler(self, loop_token, *args):
         global _last_exception
-        #assert not self._forced
-        #self._may_force = self.opindex
-        inpargs = _from_opaque(loop_token._llgraph_compiled_version).inputargs
-        for i, inparg in enumerate(inpargs):
-            TYPE = inparg.concretetype
-            if TYPE is lltype.Signed:
-                set_future_value_int(i, args[i])
-            elif isinstance(TYPE, lltype.Ptr):
-                set_future_value_ref(i, args[i])
-            elif TYPE is lltype.Float:
-                set_future_value_float(i, args[i])
-            else:
-                raise Exception("Nonsense type %s" % TYPE)
-        
-        failindex = self.cpu._execute_token(loop_token)
+        assert not self._forced
+        self._may_force = self.opindex
         try:
-            return self.cpu.assembler_helper_ptr(failindex)
-        except LLException, lle:
-            assert _last_exception is None, "exception left behind"
-            _last_exception = lle
+            inpargs = _from_opaque(loop_token._llgraph_compiled_version).inputargs
+            for i, inparg in enumerate(inpargs):
+                TYPE = inparg.concretetype
+                if TYPE is lltype.Signed:
+                    set_future_value_int(i, args[i])
+                elif isinstance(TYPE, lltype.Ptr):
+                    set_future_value_ref(i, args[i])
+                elif TYPE is lltype.Float:
+                    set_future_value_float(i, args[i])
+                else:
+                    raise Exception("Nonsense type %s" % TYPE)
+
+            failindex = self.cpu._execute_token(loop_token)
+            try:
+                if self.cpu.index_of_virtualizable != -1:
+                    return self.cpu.assembler_helper_ptr(failindex,
+                        args[self.cpu.index_of_virtualizable])
+                else:
+                    return self.cpu.assembler_helper_ptr(failindex,
+                        lltype.nullptr(llmemory.GCREF.TO))
+            except LLException, lle:
+                assert _last_exception is None, "exception left behind"
+                _last_exception = lle
+        finally:
+            self._may_force = -1
 
     def op_guard_not_forced(self, descr):
         forced = self._forced
@@ -1124,7 +1132,8 @@
     assert frame._may_force >= 0
     call_op = frame.loop.operations[frame._may_force]
     guard_op = frame.loop.operations[frame._may_force+1]
-    assert call_op.opnum == rop.CALL_MAY_FORCE
+    opnum = call_op.opnum
+    assert opnum == rop.CALL_MAY_FORCE or opnum == rop.CALL_ASSEMBLER
     frame._populate_fail_args(guard_op, skip=call_op.result)
     return frame.fail_index
 

Modified: pypy/branch/direct-assembler-call/pypy/jit/backend/x86/test/test_recursive.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/backend/x86/test/test_recursive.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/backend/x86/test/test_recursive.py	Wed Jan 20 16:28:52 2010
@@ -3,4 +3,6 @@
 from pypy.jit.backend.x86.test.test_basic import Jit386Mixin
 
 class TestRecursive(Jit386Mixin, RecursiveTests):
+    # for the individual tests see
+    # ====> ../../../metainterp/test/test_recursive.py
     pass

Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	Wed Jan 20 16:28:52 2010
@@ -789,6 +789,9 @@
 
         somewhere_else = SomewhereElse()
 
+        def change(newthing):
+            somewhere_else.frame.thing = newthing
+
         def main(codeno):
             frame = Frame()
             somewhere_else.frame = frame
@@ -807,13 +810,14 @@
                     subframe.thing = Thing(nextval)
                     nextval = portal(1, subframe)
                 elif frame.thing.val > 40:
-                    somewhere_else.frame.thing = Thing(13)
+                    change(Thing(13))
                     nextval = 13
                 frame.thing = Thing(nextval + 1)
                 i += 1
             return frame.thing.val
 
-        res = self.meta_interp(main, [0], inline=True)
+        res = self.meta_interp(main, [0], inline=True,
+                               policy=StopAtXPolicy(change))
         assert res == main(0)
 
 class TestLLtype(RecursiveTests, LLJitMixin):

Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmspot.py	Wed Jan 20 16:28:52 2010
@@ -444,7 +444,7 @@
         (self.PORTAL_FUNCTYPE,
          self.PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
         (_, self.PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(
-            [lltype.Signed], RESTYPE)
+            [lltype.Signed, llmemory.GCREF], RESTYPE)
 
     def rewrite_can_enter_jit(self):
         FUNC = self.JIT_ENTER_FUNCTYPE
@@ -562,10 +562,16 @@
         self.portal_runner_ptr = self.helper_func(self.PTR_PORTAL_FUNCTYPE,
                                                   ll_portal_runner)
 
-        def assembler_call_helper(failindex):
+        vinfo = self.metainterp_sd.virtualizable_info
+
+        def assembler_call_helper(failindex, virtualizable):
             fail_descr = self.cpu.get_fail_descr_from_number(failindex)
             while True:
                 try:
+                    if vinfo is not None:
+                        virtualizable = lltype.cast_opaque_ptr(
+                            vinfo.VTYPEPTR, virtualizable)
+                        vinfo.reset_vable_token(virtualizable)
                     loop_token = fail_descr.handle_fail(self.metainterp_sd)
                     fail_descr = self.cpu.execute_token(loop_token)
                 except self.ContinueRunningNormally, e:
@@ -598,6 +604,12 @@
         self.cpu.assembler_helper_ptr = self.helper_func(
             self.PTR_ASSEMBLER_HELPER_FUNCTYPE,
             assembler_call_helper)
+        # XXX a bit ugly sticking
+        if vinfo is not None:
+            self.cpu.index_of_virtualizable = (vinfo.index_of_virtualizable -
+                                               self.num_green_args)
+        else:
+            self.cpu.index_of_virtualizable = -1
 
         # ____________________________________________________________
         # Now mutate origportalgraph to end with a call to portal_runner_ptr



More information about the Pypy-commit mailing list