[pypy-commit] pypy default: Hackish fix for issue978: make sure the virtualizable stays alive

arigo noreply at buildbot.pypy.org
Sat Feb 4 15:01:35 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r52088:4033391a3442
Date: 2012-02-04 14:42 +0100
http://bitbucket.org/pypy/pypy/changeset/4033391a3442/

Log:	Hackish fix for issue978: make sure the virtualizable stays alive
	across the CALL_ASSEMBLER, by giving it as a useless argument to the
	GUARD_NOT_FORCED that follows.

	(Testless checkin, to see if it works...)

diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -174,7 +174,7 @@
     'debug_merge_point': (('ref', 'int'), None),
     'force_token'     : ((), 'int'),
     'call_may_force'  : (('int', 'varargs'), 'intorptr'),
-    'guard_not_forced': ((), None),
+    'guard_not_forced': (('ref',), None),
 }
 
 # ____________________________________________________________
@@ -1053,7 +1053,7 @@
         finally:
             self._may_force = -1
 
-    def op_guard_not_forced(self, descr):
+    def op_guard_not_forced(self, descr, vable_ignored):
         forced = self._forced
         self._forced = False
         if forced:
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
@@ -1346,12 +1346,15 @@
             resbox = self.metainterp.execute_and_record_varargs(
                 rop.CALL_MAY_FORCE, allboxes, descr=descr)
             self.metainterp.vrefs_after_residual_call()
+            vablebox = None
             if assembler_call:
-                self.metainterp.direct_assembler_call(assembler_call_jd)
+                vablebox = self.metainterp.direct_assembler_call(
+                    assembler_call_jd)
             if resbox is not None:
                 self.make_result_of_lastop(resbox)
             self.metainterp.vable_after_residual_call()
-            self.generate_guard(rop.GUARD_NOT_FORCED, None)
+            self.generate_guard(rop.GUARD_NOT_FORCED,
+                                extraargs=[vablebox or history.CONST_NULL])
             self.metainterp.handle_possible_exception()
             return resbox
         else:
@@ -2478,6 +2481,15 @@
         token = warmrunnerstate.get_assembler_token(greenargs)
         op = op.copy_and_change(rop.CALL_ASSEMBLER, args=args, descr=token)
         self.history.operations.append(op)
+        #
+        # To fix an obscure issue, make sure the vable stays alive
+        # longer than the CALL_ASSEMBLER operation.  We stick it
+        # randomly to the GUARD_NOT_FORCED that follows.
+        jd = token.outermost_jitdriver_sd
+        if jd.index_of_virtualizable >= 0:
+            return args[jd.index_of_virtualizable]
+        else:
+            return None
 
 # ____________________________________________________________
 
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -391,7 +391,7 @@
     'GUARD_EXCEPTION/1d',       # may be called with an exception currently set
     'GUARD_NO_OVERFLOW/0d',
     'GUARD_OVERFLOW/0d',
-    'GUARD_NOT_FORCED/0d',      # may be called with an exception currently set
+    'GUARD_NOT_FORCED/1d',      # may be called with an exception currently set
     'GUARD_NOT_INVALIDATED/0d',
     '_GUARD_LAST', # ----- end of guard operations -----
 


More information about the pypy-commit mailing list