[pypy-svn] pypy default: Fix another corner case (no specific test written): what if we
arigo
commits-noreply at bitbucket.org
Mon Mar 14 22:20:23 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42651:440b11884461
Date: 2011-03-14 17:19 -0400
http://bitbucket.org/pypy/pypy/changeset/440b11884461/
Log: Fix another corner case (no specific test written): what if we have
to move an xmm stack location from (6,7) to (7,8)? The problem is
completely avoided by always aligning such locations to multiples of
2.
diff --git a/pypy/jit/backend/llsupport/regalloc.py b/pypy/jit/backend/llsupport/regalloc.py
--- a/pypy/jit/backend/llsupport/regalloc.py
+++ b/pypy/jit/backend/llsupport/regalloc.py
@@ -26,16 +26,24 @@
res = self.get(box)
if res is not None:
return res
+ size = self.frame_size(box.type)
+ self.frame_depth += ((-self.frame_depth) & (size-1))
+ # ^^^ frame_depth is rounded up to a multiple of 'size', assuming
+ # that 'size' is a power of two. The reason for doing so is to
+ # avoid obscure issues in jump.py with stack locations that try
+ # to move from position (6,7) to position (7,8).
newloc = self.frame_pos(self.frame_depth, box.type)
self.frame_bindings[box] = newloc
- # Objects returned by frame_pos must support frame_size()
- self.frame_depth += newloc.frame_size()
+ self.frame_depth += size
return newloc
# abstract methods that need to be overwritten for specific assemblers
@staticmethod
def frame_pos(loc, type):
raise NotImplementedError("Purely abstract")
+ @staticmethod
+ def frame_size(type):
+ return 1
class RegisterManager(object):
""" Class that keeps track of register allocations
diff --git a/pypy/jit/backend/llsupport/test/test_regalloc.py b/pypy/jit/backend/llsupport/test/test_regalloc.py
--- a/pypy/jit/backend/llsupport/test/test_regalloc.py
+++ b/pypy/jit/backend/llsupport/test/test_regalloc.py
@@ -34,16 +34,15 @@
self.pos = pos
self.box_type = box_type
- def frame_size(self):
- if self.box_type == FLOAT:
+class TFrameManager(FrameManager):
+ def frame_pos(self, i, box_type):
+ return FakeFramePos(i, box_type)
+ def frame_size(self, box_type):
+ if box_type == FLOAT:
return 2
else:
return 1
-class TFrameManager(FrameManager):
- def frame_pos(self, i, box_type):
- return FakeFramePos(i, box_type)
-
class MockAsm(object):
def __init__(self):
self.moves = []
diff --git a/pypy/jit/backend/x86/regloc.py b/pypy/jit/backend/x86/regloc.py
--- a/pypy/jit/backend/x86/regloc.py
+++ b/pypy/jit/backend/x86/regloc.py
@@ -46,9 +46,6 @@
# One of INT, REF, FLOAT
self.type = type
- def frame_size(self):
- return self.width // WORD
-
def __repr__(self):
return '%d(%%ebp)' % (self.value,)
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -110,6 +110,12 @@
return StackLoc(i, get_ebp_ofs(i+1), 2, box_type)
else:
return StackLoc(i, get_ebp_ofs(i), 1, box_type)
+ @staticmethod
+ def frame_size(box_type):
+ if IS_X86_32 and box_type == FLOAT:
+ return 2
+ else:
+ return 1
class RegAlloc(object):
More information about the Pypy-commit
mailing list