[pypy-commit] pypy stmgc-c4: attempt to fix for trying to patch the JMP target of a guard twice

Raemi noreply at buildbot.pypy.org
Sat Oct 12 18:23:50 CEST 2013


Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r67335:6e93c32df66d
Date: 2013-10-12 18:22 +0200
http://bitbucket.org/pypy/pypy/changeset/6e93c32df66d/

Log:	attempt to fix for trying to patch the JMP target of a guard twice

diff --git a/rpython/jit/backend/llsupport/llmodel.py b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -205,6 +205,13 @@
         deadframe = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, deadframe)
         return deadframe.jf_savedata
 
+    def guard_already_patched(self, faildescr):
+        # returns True if the guard jump target is already patched
+        # to point to a bridge
+        raise NotImplemented
+
+
+
     def free_loop_and_bridges(self, compiled_loop_token):
         AbstractCPU.free_loop_and_bridges(self, compiled_loop_token)
         blocks = compiled_loop_token.asmmemmgr_blocks
diff --git a/rpython/jit/backend/x86/runner.py b/rpython/jit/backend/x86/runner.py
--- a/rpython/jit/backend/x86/runner.py
+++ b/rpython/jit/backend/x86/runner.py
@@ -104,6 +104,11 @@
                                               original_loop_token, log=log,
                                               logger=logger)
 
+    def guard_already_patched(self, faildescr):
+        # only needed for STM so far
+        return faildescr._x86_adr_jump_offset == 0
+
+        
     def clear_latest_values(self, count):
         setitem = self.assembler.fail_boxes_ptr.setitem
         null = lltype.nullptr(llmemory.GCREF.TO)
diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -573,7 +573,16 @@
         with stm_ignored:
             approx_counter = self._counter + 1
             self._counter = approx_counter
-        return approx_counter >= trace_eagerness and not self.rd_stm_busy
+
+        # The call to guard_already_patched is necessary because it is 
+        # possible that the current transaction didn't see the 
+        # patched JMP yet, but already sees rd_stm_busy as False (because
+        # the patching is in raw-memory).
+        # Thus it may try to compile a trace too and also patch the assembler.
+        # However, this would trigger the assertion in 
+        #     x86.assembler.patch_jump_for_descr.
+        return (approx_counter >= trace_eagerness and not self.rd_stm_busy
+                and not metainterp_sd.cpu.guard_already_patched(self))
 
     def must_compile_nonstm(self, deadframe, metainterp_sd, jitdriver_sd):
         trace_eagerness = jitdriver_sd.warmstate.trace_eagerness


More information about the pypy-commit mailing list