[pypy-svn] r67996 - in pypy/branch/floats-via-sse2/pypy/jit/backend: llsupport x86
arigo at codespeak.net
arigo at codespeak.net
Tue Sep 29 19:23:12 CEST 2009
Author: arigo
Date: Tue Sep 29 19:23:11 2009
New Revision: 67996
Modified:
pypy/branch/floats-via-sse2/pypy/jit/backend/llsupport/regalloc.py
pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
Log:
More fixes and comments and bugs showing up because of extra asserts.
I suppose I will stop there :-)
Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/llsupport/regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/llsupport/regalloc.py (original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/llsupport/regalloc.py Tue Sep 29 19:23:11 2009
@@ -39,6 +39,7 @@
class RegisterManager(object):
""" Class that keeps track of register allocations
"""
+ box_types = None # or a list of acceptable types
all_regs = []
no_lower_byte_regs = []
save_around_call_regs = []
@@ -58,11 +59,16 @@
def next_instruction(self, incr=1):
self.position += incr
+ def _check_type(self, v):
+ if not we_are_translated() and self.box_types is not None:
+ assert isinstance(v, TempBox) or v.type in self.box_types
+
def possibly_free_var(self, v):
""" If v is stored in a register and v is not used beyond the
current position, then free it. Must be called at some
point for all variables that might be in registers.
"""
+ self._check_type(v)
if isinstance(v, Const) or v not in self.reg_bindings:
return
if v not in self.longevity or self.longevity[v][1] <= self.position:
@@ -97,6 +103,7 @@
returns allocated register or None, if not possible.
"""
+ self._check_type(v)
assert not isinstance(v, Const)
if selected_reg is not None:
res = self.reg_bindings.get(v, None)
@@ -173,6 +180,7 @@
Will not spill a variable from 'forbidden_vars'.
"""
+ self._check_type(v)
if isinstance(v, TempBox):
self.longevity[v] = (self.position, self.position)
loc = self.try_allocate_reg(v, selected_reg,
@@ -190,6 +198,7 @@
def loc(self, box):
""" Return the location of 'box'.
"""
+ self._check_type(box)
if isinstance(box, Const):
return self.convert_to_imm(box)
try:
@@ -204,6 +213,7 @@
a register. See 'force_allocate_reg' for the meaning of 'selected_reg'
and 'forbidden_vars'.
"""
+ self._check_type(v)
assert isinstance(v, Const)
if selected_reg or not imm_fine:
# this means we cannot have it in IMM, eh
@@ -226,6 +236,7 @@
register. Return the register. See 'return_constant' and
'force_allocate_reg' for the meaning of the optional arguments.
"""
+ self._check_type(v)
if isinstance(v, Const):
return self.return_constant(v, forbidden_vars, selected_reg,
imm_fine)
@@ -257,6 +268,8 @@
The variable v is copied away if it's further used. The meaning
of 'forbidden_vars' is the same as in 'force_allocate_reg'.
"""
+ self._check_type(result_v)
+ self._check_type(v)
if isinstance(v, Const):
loc = self.make_sure_var_in_reg(v, forbidden_vars,
imm_fine=False)
@@ -312,6 +325,7 @@
which is in variable v.
"""
if v is not None:
+ self._check_type(v)
r = self.call_result_location(v)
self.reg_bindings[v] = r
self.free_regs = [fr for fr in self.free_regs if fr is not r]
Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py Tue Sep 29 19:23:11 2009
@@ -28,6 +28,7 @@
class X86RegisterManager(RegisterManager):
+ box_types = [INT, REF]
all_regs = [eax, ecx, edx, ebx, esi, edi]
no_lower_byte_regs = [esi, edi]
save_around_call_regs = [eax, edx, ecx]
@@ -53,6 +54,7 @@
class X86XMMRegisterManager(RegisterManager):
+ box_types = [FLOAT]
all_regs = [xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7]
# we never need lower byte I hope
save_around_call_regs = all_regs
@@ -201,6 +203,7 @@
if reg not in used:
self.rm.free_regs.append(reg)
self.rm._check_invariants()
+ self.xrm._check_invariants()
def Perform(self, op, arglocs, result_loc):
if not we_are_translated():
@@ -260,6 +263,7 @@
while i < len(operations):
op = operations[i]
self.rm.position = i
+ # XXX ^^^ and also self.xrm.position = i.... :-(
if op.has_no_side_effect() and op.result not in self.longevity:
i += 1
self.rm.possibly_free_vars(op.args)
@@ -269,10 +273,13 @@
i += 1
else:
oplist[op.opnum](self, op, None)
- self.rm.possibly_free_var(op.result)
+ if op.result is not None:
+ self.rm.possibly_free_var(op.result)
self.rm._check_invariants()
+ self.xrm._check_invariants()
i += 1
assert not self.rm.reg_bindings
+ assert not self.xrm.reg_bindings
def _compute_vars_longevity(self, inputargs, operations):
# compute a dictionary that maps variables to index in
More information about the Pypy-commit
mailing list