[pypy-svn] r63674 - pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86
fijal at codespeak.net
fijal at codespeak.net
Sun Apr 5 18:05:39 CEST 2009
Author: fijal
Date: Sun Apr 5 18:05:36 2009
New Revision: 63674
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
Log:
fix a stupid bug and add a couple of assertions. It just begs for some kind
of optimization, but not right now.
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 Sun Apr 5 18:05:36 2009
@@ -615,7 +615,7 @@
guard_op.suboperations[-1].exc = exc
if ovf or exc: # we need to think what to do otherwise
assert guard_op.suboperations[-1].opnum == rop.FAIL
- regalloc._walk_operations(guard_op.suboperations)
+ regalloc.walk_guard_ops(guard_op.inputargs, guard_op.suboperations)
self.mcstack.give_mc_back(self.mc2)
self.mc2 = self.mc
self.mc = oldmc
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 Sun Apr 5 18:05:36 2009
@@ -78,6 +78,8 @@
self.reg_bindings[arg] = regalloc.reg_bindings[arg]
if arg in regalloc.stack_bindings:
self.stack_bindings[arg] = regalloc.stack_bindings[arg]
+ else:
+ assert arg in self.reg_bindings
if arg in regalloc.dirty_stack:
self.dirty_stack[arg] = regalloc.dirty_stack[arg]
allocated_regs = self.reg_bindings.values()
@@ -94,7 +96,6 @@
self._create_jump_reg_candidates(jump_or_fail)
def _create_jump_reg_candidates(self, jump):
-
self.jump_reg_candidates = {}
for i in range(len(jump.args)):
arg = jump.args[i]
@@ -185,6 +186,8 @@
self.longevity[v][1] > self.position and
self.longevity[v][0] <= self.position):
assert not v in self.dirty_stack
+ else:
+ assert len(self.reg_bindings) + len(self.free_regs) == len(REGS)
def Load(self, v, from_loc, to_loc):
if not we_are_translated():
@@ -233,6 +236,10 @@
return False
if self.longevity[op.result][1] > i + 1:
return False
+ if op.result in operations[i + 1].inputargs:
+ # XXX implement optimization that replace var with a const
+ # not right now
+ return False
return True
def walk_operations(self, tree):
@@ -243,6 +250,13 @@
self.process_inputargs(tree)
self._walk_operations(operations)
+ def walk_guard_ops(self, inputargs, operations):
+ for arg in inputargs:
+ if arg not in self.reg_bindings:
+ assert arg in self.stack_bindings
+ assert arg not in self.dirty_stack
+ self._walk_operations(operations)
+
def _walk_operations(self, operations):
i = 0
while i < len(operations):
@@ -573,7 +587,6 @@
tree.arglocs = locs
tree.stacklocs = range(len(inputargs))
self.assembler.make_merge_point(tree, locs, tree.stacklocs)
- # XXX be a bit smarter and completely ignore such vars
self.eventually_free_vars(inputargs)
def regalloc_for_guard(self, guard_op):
@@ -608,9 +621,9 @@
box = TempBox()
loc = self.force_allocate_reg(box, [])
regalloc = self.regalloc_for_guard(op)
+ self.perform_guard(op, regalloc, [loc], None)
self.eventually_free_vars(op.inputargs)
self.eventually_free_var(box)
- self.perform_guard(op, regalloc, [loc], None)
def consider_guard_exception(self, op, ignored):
loc = self.make_sure_var_in_reg(op.args[0], [])
More information about the Pypy-commit
mailing list