[pypy-svn] r63858 - pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86
fijal at codespeak.net
fijal at codespeak.net
Wed Apr 8 18:20:43 CEST 2009
Author: fijal
Date: Wed Apr 8 18:20:42 2009
New Revision: 63858
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
Log:
Hack differently (in progress), so all code statically known to jump
to each other keeps the same framesize.
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 Wed Apr 8 18:20:42 2009
@@ -239,9 +239,9 @@
self.mc.done()
self.mc2.done()
tree._x86_stack_depth = regalloc.max_stack_depth
- for place, offset in self.places_to_patch_framesize:
+ for place in self.places_to_patch_framesize:
mc = codebuf.InMemoryCodeBuilder(place, 128)
- mc.ADD(esp, imm32((tree._x86_stack_depth - offset) * WORD))
+ mc.ADD(esp, imm32(tree._x86_stack_depth * WORD))
mc.done()
def sanitize_tree(self, operations):
@@ -619,7 +619,7 @@
self.cpu.translate_support_code)
self.mc.MOVZX(resloc, addr8_add(base_loc, ofs_loc, basesize))
- def make_merge_point(self, tree, locs, stacklocs):
+ def make_merge_point(self, tree, locs):
pos = self.mc.tell()
tree._x86_compiled = pos
#tree.comeback_bootstrap_addr = self.assemble_comeback_bootstrap(pos,
@@ -632,6 +632,7 @@
if not we_are_translated():
assert str(oldlocs) == str(newlocs)
if newdepth != olddepth:
+ xxx
mc2 = self.mcstack.next_mc()
pos = mc2.tell()
mc2.ADD(esp, imm32((olddepth - newdepth) * WORD))
@@ -663,10 +664,6 @@
def genop_discard_jump(self, op, locs):
targetmp = op.jump_target
- if targetmp is not self.tree:
- targetdepth = targetmp._x86_stack_depth
- self.places_to_patch_framesize.append((self.mc.tell(), targetdepth))
- self.mc.ADD(esp, imm32(0))
self.mc.JMP(rel32(targetmp._x86_compiled))
def genop_guard_guard_true(self, op, ign_1, addr, locs, ign_2):
@@ -784,7 +781,7 @@
# clean up the original exception, we don't want
# to enter more rpython code with exc set
self.mc.MOV(heap(self._exception_addr), imm(0))
- self.places_to_patch_framesize.append((self.mc.tell(), 0))
+ self.places_to_patch_framesize.append(self.mc.tell())
self.mc.ADD(esp, imm32(0))
self.mc.MOV(eax, imm(guard_index))
self.mc.RET()
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py Wed Apr 8 18:20:42 2009
@@ -154,7 +154,7 @@
def _compute_loop_consts(self, inputargs, jump):
self.jump_reg_candidates = {}
- if jump.opnum != rop.JUMP:
+ if jump.opnum != rop.JUMP or jump.jump_target is not self.tree:
loop_consts = {}
else:
loop_consts = {}
@@ -255,8 +255,6 @@
self.position = -1
self.process_inputargs(tree)
self._walk_operations(operations)
- self.max_stack_depth = max(self.max_stack_depth,
- self.current_stack_depth)
def walk_guard_ops(self, inputargs, operations):
for arg in inputargs:
@@ -264,8 +262,6 @@
assert arg in self.stack_bindings
assert arg not in self.dirty_stack
self._walk_operations(operations)
- self.max_stack_depth = max(self.max_stack_depth,
- self.current_stack_depth)
def _walk_operations(self, operations):
i = 0
@@ -294,6 +290,12 @@
self.eventually_free_vars(op.args)
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)
+ self.max_stack_depth = max(self.max_stack_depth,
+ self.current_stack_depth)
def _compute_vars_longevity(self, inputargs, operations):
# compute a dictionary that maps variables to index in
@@ -591,8 +593,6 @@
arg = inputargs[i]
assert not isinstance(arg, Const)
reg = None
- loc = stack_pos(i)
- self.stack_bindings[arg] = loc
if arg not in self.loop_consts and self.longevity[arg][1] > -1:
reg = self.try_allocate_reg(arg)
if reg:
@@ -604,11 +604,12 @@
jarg = jump.args[i]
self.jump_reg_candidates[jarg] = reg
else:
+ loc = stack_pos(i)
+ self.stack_bindings[arg] = loc
locs[i] = loc
# otherwise we have it saved on stack, so no worry
tree.arglocs = locs
- tree.stacklocs = range(len(inputargs))
- self.assembler.make_merge_point(tree, locs, tree.stacklocs)
+ self.assembler.make_merge_point(tree, locs)
self.eventually_free_vars(inputargs)
def regalloc_for_guard(self, guard_op):
@@ -1116,8 +1117,11 @@
break
if free_reg is None:
# a very rare case
- v = self.reg_bindings.keys()[0]
- free_reg = self.reg_bindings[v]
+ if self.free_regs:
+ free_reg = self.free_regs.pop()
+ else:
+ v = self.reg_bindings.keys()[0]
+ free_reg = self.reg_bindings[v]
self.Store(v, self.loc(v), self.stack_loc(v))
later_loads.insert(0, (v, self.stack_loc(v), self.loc(v)))
for v, from_l, to_l in reloaded:
More information about the Pypy-commit
mailing list