[pypy-commit] pypy jit-simplify-backendintf: Fix some tests by using a slightly different logic in non-translated

arigo noreply at buildbot.pypy.org
Wed Oct 26 17:37:15 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-simplify-backendintf
Changeset: r48475:bfb70bc8d71f
Date: 2011-10-26 17:36 +0200
http://bitbucket.org/pypy/pypy/changeset/bfb70bc8d71f/

Log:	Fix some tests by using a slightly different logic in non-translated
	and in translated versions (horror!).

diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1980,15 +1980,37 @@
             else: assert 0
         return ints[:], refs[:], floats[:]
 
-    def raise_continue_running_normally(self, live_arg_boxes):
+    def raise_continue_running_normally(self, live_arg_boxes, loop_token):
         self.history.inputargs = None
         self.history.operations = None
+        # For simplicity, we just raise ContinueRunningNormally here and
+        # ignore the loop_token passed in.  It means that we go back to
+        # interpreted mode, but it should come back very quickly to the
+        # JIT, find probably the same 'loop_token', and execute it.
+        if we_are_translated():
+            num_green_args = self.jitdriver_sd.num_green_args
+            gi, gr, gf = self._unpack_boxes(live_arg_boxes, 0, num_green_args)
+            ri, rr, rf = self._unpack_boxes(live_arg_boxes, num_green_args,
+                                            len(live_arg_boxes))
+            CRN = self.staticdata.ContinueRunningNormally
+            raise CRN(gi, gr, gf, ri, rr, rf)
+        else:
+            # However, in order to keep the existing tests working
+            # (which are based on the assumption that 'loop_token' is
+            # directly used here), a bit of custom non-translatable code...
+            self._nontranslated_run_directly(live_arg_boxes, loop_token)
+            assert 0, "unreachable"
+
+    def _nontranslated_run_directly(self, live_arg_boxes, loop_token):
+        "NOT_RPYTHON"
+        args = []
         num_green_args = self.jitdriver_sd.num_green_args
-        gi, gr, gf = self._unpack_boxes(live_arg_boxes, 0, num_green_args)
-        ri, rr, rf = self._unpack_boxes(live_arg_boxes, num_green_args,
-                                        len(live_arg_boxes))
-        CRN = self.staticdata.ContinueRunningNormally
-        raise CRN(gi, gr, gf, ri, rr, rf)
+        for box in live_arg_boxes[num_green_args:]:
+            if   box.type == history.INT: args.append(box.getint())
+            elif box.type == history.REF: args.append(box.getref_base())
+            elif box.type == history.FLOAT: args.append(box.getfloatstorage())
+            else: assert 0
+        self.jitdriver_sd.warmstate.execute_assembler(loop_token, *args)
 
     def prepare_resume_from_failure(self, opnum, dont_change_position=False):
         frame = self.framestack[-1]
@@ -2051,7 +2073,7 @@
                                               greenkey, start, start_resumedescr)
         if loop_token is not None: # raise if it *worked* correctly
             self.set_compiled_merge_points(greenkey, old_loop_tokens)
-            self.raise_continue_running_normally(live_arg_boxes)
+            self.raise_continue_running_normally(live_arg_boxes, loop_token)
 
         self.history.inputargs = original_inputargs
         self.history.operations.pop()     # remove the JUMP
@@ -2072,7 +2094,8 @@
         finally:
             self.history.operations.pop()     # remove the JUMP
         if target_loop_token is not None: # raise if it *worked* correctly
-            self.raise_continue_running_normally(live_arg_boxes)
+            self.raise_continue_running_normally(live_arg_boxes,
+                                                 target_loop_token)
 
     def compile_bridge_and_loop(self, original_boxes, live_arg_boxes, start,
                                 bridge_arg_boxes, start_resumedescr):
@@ -2108,7 +2131,8 @@
         except RetraceLoop:
             assert False
         assert target_loop_token is not None
-        self.raise_continue_running_normally(live_arg_boxes)
+        self.raise_continue_running_normally(live_arg_boxes,
+                                             old_loop_tokens[0])
 
     def compile_done_with_this_frame(self, exitbox):
         self.gen_store_back_in_virtualizable()
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -12,6 +12,7 @@
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.jit.metainterp import history
 from pypy.jit.codewriter import support, heaptracker, longlong
+from pypy.tool.sourcetools import func_with_new_name
 
 # ____________________________________________________________
 
@@ -294,11 +295,15 @@
         confirm_enter_jit = self.confirm_enter_jit
         range_red_args = unrolling_iterable(
             range(num_green_args, num_green_args + jitdriver_sd.num_red_args))
+        # hack: make a new copy of the method
+        func_execute_token = self.cpu.execute_token.im_func
+        func_execute_token = func_with_new_name(func_execute_token,
+                                                "execute_token_spec")
 
         def execute_assembler(loop_token, *args):
             # Call the backend to run the 'looptoken' with the given
             # input args.
-            fail_descr = self.cpu.execute_token(loop_token, *args)
+            fail_descr = func_execute_token(self.cpu, loop_token, *args)
             #
             # If we have a virtualizable, we have to reset its
             # 'vable_token' field afterwards


More information about the pypy-commit mailing list