[pypy-svn] r65547 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86

fijal at codespeak.net fijal at codespeak.net
Wed Jun 3 01:44:51 CEST 2009


Author: fijal
Date: Wed Jun  3 01:44:48 2009
New Revision: 65547

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py
Log:
Use ebp instead of esp for a basis of frame computations. Simplifies some
stuff, but no big win so far. Expect more to come :-)


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	Wed Jun  3 01:44:48 2009
@@ -177,8 +177,7 @@
             mc.ADD(esp, imm32(tree._x86_stack_depth * WORD))
             mc.done()
         for op, pos in self.jumps_to_look_at:
-            if op.jump_target._x86_stack_depth < tree._x86_stack_depth:
-                # XXX do a dumb thing
+            if op.jump_target._x86_stack_depth != tree._x86_stack_depth:
                 tl = op.jump_target
                 self.patch_jump(pos, tl._x86_compiled, tl.arglocs, tl.arglocs,
                                 tree._x86_stack_depth, tl._x86_stack_depth)
@@ -197,9 +196,9 @@
     def assemble_bootstrap_code(self, jumpaddr, arglocs, framesize):
         self.make_sure_mc_exists()
         addr = self.mc.tell()
-        if self.gcrootmap:
-            self.mc.PUSH(ebp)
-            self.mc.MOV(ebp, esp)
+        #if self.gcrootmap:
+        self.mc.PUSH(ebp)
+        self.mc.MOV(ebp, esp)
         self.mc.SUB(esp, imm(framesize * WORD))
         # This uses XCHG to put zeroes in fail_boxes after reading them,
         # just in case they are pointers.
@@ -606,51 +605,17 @@
                 locs = [loc.position for loc in newlocs if isinstance(loc, MODRM)]
                 assert locs == sorted(locs)
         #
-        if newdepth != olddepth:
-            mc2 = self.mcstack.next_mc()
-            pos = mc2.tell()
-            diff = olddepth - newdepth
-            for loc in newlocs:
-                if isinstance(loc, MODRM):
-                    has_modrm = True
-                    break
-            else:
-                has_modrm = False
-            if diff > 0:
-                if has_modrm:
-                    extra_place = stack_pos(olddepth - 1) # this is unused
-                    mc2.MOV(extra_place, eax)
-                    for i in range(len(newlocs) -1, -1, -1):
-                        loc = newlocs[i]
-                        if isinstance(loc, MODRM):
-                            mc2.MOV(eax, loc)
-                            mc2.MOV(stack_pos(loc.position + diff), eax)
-                    mc2.MOV(eax, extra_place)
-                mc2.ADD(esp, imm32((diff) * WORD))
-            else:
-                mc2.SUB(esp, imm32((-diff) * WORD))
-                if has_modrm:
-                    extra_place = stack_pos(newdepth - 1) # this is unused
-                    mc2.MOV(extra_place, eax)
-                    for i in range(len(newlocs)):
-                        loc = newlocs[i]
-                        if isinstance(loc, MODRM):
-                            # diff is negative!
-                            mc2.MOV(eax, stack_pos(loc.position - diff))
-                            mc2.MOV(loc, eax)
-                    mc2.MOV(eax, extra_place)
-            mc2.JMP(rel32(new_pos))
-            self.mcstack.give_mc_back(mc2)
-        else:
-            pos = new_pos
         mc = codebuf.InMemoryCodeBuilder(old_pos, old_pos +
                                          MachineCodeBlockWrapper.MC_SIZE)
-        mc.JMP(rel32(pos))
+        mc.SUB(esp, imm(WORD * (newdepth - olddepth)))
+        mc.JMP(rel32(new_pos))
         mc.done()
 
     def genop_discard_jump(self, op, locs):
         targetmp = op.jump_target
-        self.jumps_to_look_at.append((op, self.mc.tell()))
+        if op.jump_target is not self.tree:
+            self.jumps_to_look_at.append((op, self.mc.tell()))
+            self.mc.ADD(esp, imm(0))
         self.mc.JMP(rel32(targetmp._x86_compiled))
 
     def genop_guard_guard_true(self, op, ign_1, addr, locs, ign_2):
@@ -745,8 +710,8 @@
         self.mc.ADD(esp, imm32(0))
         guard_index = self.cpu.make_guard_index(op)
         self.mc.MOV(eax, imm(guard_index))
-        if self.gcrootmap:
-            self.mc.POP(ebp)
+        #if self.gcrootmap:
+        self.mc.POP(ebp)
         self.mc.RET()
 
     def generate_ovf_set(self):
@@ -784,14 +749,14 @@
                 self.mc.PUSH(loc)
             else:
                 # we need to add a bit, ble
-                self.mc.PUSH(stack_pos(loc.position + extra_on_stack))
+                self.mc.PUSH(stack_pos(loc.position))
             extra_on_stack += 1
         if isinstance(op.args[0], Const):
             x = rel32(op.args[0].getint())
         else:
             x = arglocs[0]
             if isinstance(x, MODRM):
-                x = stack_pos(x.position + extra_on_stack)
+                x = stack_pos(x.position)
         self.mc.CALL(x)
         self.mark_gc_roots(extra_on_stack)
         self.mc.ADD(esp, imm(WORD * extra_on_stack))

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py	Wed Jun  3 01:44:48 2009
@@ -315,9 +315,9 @@
             i += 1
         assert not self.reg_bindings
         jmp = operations[-1]
-        if jmp.opnum == rop.JUMP and jmp.jump_target is not self.tree:
-            self.max_stack_depth = max(jmp.jump_target._x86_stack_depth,
-                                       self.max_stack_depth)
+        #if jmp.opnum == rop.JUMP and jmp.jump_target is not self.tree:
+        #    self.max_stack_depth = max(jmp.jump_target._x86_stack_depth,
+        #                               self.max_stack_depth)
         self.max_stack_depth = max(self.max_stack_depth,
                                    self.current_stack_depth + 1)
 
@@ -1155,9 +1155,9 @@
             # write the code that moves the correct value into 'res', in two
             # steps: generate a pair PUSH (immediately) / POP (later)
             if isinstance(src, MODRM):
-                src = stack_pos(src.position + extra_on_stack)
+                src = stack_pos(src.position)
             if isinstance(res, MODRM):
-                res = stack_pos(res.position + extra_on_stack)
+                res = stack_pos(res.position)
             self.assembler.regalloc_push(src)
             later_pops.append(res)
             extra_on_stack += 1
@@ -1180,7 +1180,7 @@
         oplist[num] = value
 
 def stack_pos(i):
-    res = mem(esp, WORD * i)
+    res = mem(ebp, -WORD * (1 + i))
     res.position = i
     return res
 



More information about the Pypy-commit mailing list