Commits

Armin Rigo committed dbe437d

redirect_call_assembler() fix.

  • Participants
  • Parent commits 3a5a45b
  • Branches jit-simplify-backendintf

Comments (0)

Files changed (2)

pypy/jit/backend/x86/assembler.py

         # we overwrite the instructions at the old _x86_direct_bootstrap_code
         # to start with a JMP to the new _x86_direct_bootstrap_code.
         # Ideally we should rather patch all existing CALLs, but well.
-        oldadr = oldlooptoken._x86_direct_bootstrap_code
-        target = newlooptoken._x86_direct_bootstrap_code
+        oldadr = oldlooptoken._x86_function_addr
+        target = newlooptoken._x86_function_addr
         mc = codebuf.MachineCodeBlockWrapper()
         mc.JMP(imm(target))
+        assert mc.get_relative_pos() <= 13  #keep in sync with consider_label()
         mc.copy_to_raw_memory(oldadr)
 
     def dump(self, text):

pypy/jit/backend/x86/regalloc.py

                 nonfloatlocs[i] = loc
             if isinstance(loc, RegLoc):
                 self.fm.mark_as_free(arg)
+        #
+        # if we are too close to the start of the loop, the label's target may
+        # get overridden by redirect_call_assembler().  (rare case)
+        while self.assembler.mc.get_relative_pos() < 13:
+            self.assembler.mc.NOP()
+        #
         descr._x86_arglocs = nonfloatlocs, floatlocs
         descr._x86_loop_code = self.assembler.mc.get_relative_pos()
         descr._x86_clt = self.assembler.current_clt