[pypy-svn] r63636 - pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86

fijal at codespeak.net fijal at codespeak.net
Sat Apr 4 23:45:33 CEST 2009


Author: fijal
Date: Sat Apr  4 23:45:30 2009
New Revision: 63636

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py
Log:
implement patching of old loops


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	Sat Apr  4 23:45:30 2009
@@ -181,8 +181,6 @@
         self._compute_longest_fail_op(tree.operations)
         self.make_sure_mc_exists()
         inputargs = tree.inputargs
-        op0 = tree.operations[0]
-        op0.position = self.mc.tell()
         self.eventually_log_operations(tree)
         regalloc = RegAlloc(self, tree, self.cpu.translate_support_code)
         if not we_are_translated():
@@ -524,10 +522,16 @@
 
     def make_merge_point(self, tree, locs, stacklocs):
         pos = self.mc.tell()
-        tree.position = pos
+        tree._x86_compiled = pos
         #tree.comeback_bootstrap_addr = self.assemble_comeback_bootstrap(pos,
         #                                                locs, stacklocs)
 
+    def patch_jump(self, old_pos, new_pos, oldlocs, newlocs):
+        if not we_are_translated():
+            assert str(oldlocs) == str(newlocs)
+        mc = codebuf.InMemoryCodeBuilder(old_pos, MachineCodeStack.MC_SIZE)
+        mc.JMP(rel32(new_pos))
+
 #     def genop_discard_return(self, op, locs):
 #         if op.args:
 #             loc = locs[0]
@@ -548,7 +552,7 @@
 
     def genop_discard_jump(self, op, locs):
         targetmp = op.jump_target
-        self.mc.JMP(rel32(targetmp.position))
+        self.mc.JMP(rel32(targetmp._x86_compiled))
 
     def genop_guard_guard_true(self, op, ign_1, addr, locs, ign_2):
         loc = locs[0]

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py	Sat Apr  4 23:45:30 2009
@@ -22,6 +22,8 @@
 PTR = 1
 INT = 2
 
+history.TreeLoop._x86_compiled = 0
+
 class ConstDescr3(AbstractDescr):
     def __init__(self, v):
         # XXX don't use a tuple! that's yet another indirection...
@@ -184,7 +186,16 @@
         self.assembler._exception_bck[1] = ovf_inst
 
     def compile_operations(self, tree):
+        old_loop = tree._x86_compiled
+        if old_loop:
+            oldlocs = tree.arglocs
+        else:
+            oldlocs = None
         self.assembler.assemble(tree)
+        newlocs = tree.arglocs
+        if old_loop != 0:
+            self.assembler.patch_jump(old_loop, tree._x86_compiled,
+                                      oldlocs, newlocs)
 
     def get_bootstrap_code(self, loop):
         # key is locations of arguments
@@ -291,7 +302,7 @@
         res = 0
         try:
             self.caught_exception = None
-            res = func(loop.position, values_as_int)
+            res = func(loop._x86_compiled, values_as_int)
             self.reraise_caught_exception()
         finally:
             if not self.translate_support_code:



More information about the Pypy-commit mailing list