[pypy-svn] r67842 - in pypy/trunk/pypy/translator/c/gcc: . test
afa at codespeak.net
afa at codespeak.net
Tue Sep 22 15:37:24 CEST 2009
Author: afa
Date: Tue Sep 22 15:37:23 2009
New Revision: 67842
Modified:
pypy/trunk/pypy/translator/c/gcc/test/test_trackgcroot.py
pypy/trunk/pypy/translator/c/gcc/trackgcroot.py
Log:
Another change for mingw32 which generates statements like
leal 2(%esp), %esp
Modified: pypy/trunk/pypy/translator/c/gcc/test/test_trackgcroot.py
==============================================================================
--- pypy/trunk/pypy/translator/c/gcc/test/test_trackgcroot.py (original)
+++ pypy/trunk/pypy/translator/c/gcc/test/test_trackgcroot.py Tue Sep 22 15:37:23 2009
@@ -151,6 +151,33 @@
tracker = FunctionGcRootTracker(lines, format='mingw32')
tracker.computegcmaptable(verbose=sys.maxint)
+def test_leal_esp():
+ # "leal 2(%esp), %esp" is equivalent to "addl $2, %esp"
+ source = """\
+\t.text
+\t.globl _someFunction
+_someFunction:
+\tpushl %ebp
+\tmovl %esp, %ebp
+\tsubl $40, %esp
+\tmovl $10, -4(%ebp)
+\tcmpb $0, -26(%ebp)
+\tje L7816
+\tleal 2(%esp), %esp
+\tjmp L7817
+L7816:
+\taddl $2, %esp
+L7817:
+\tmovl -4(%ebp), %eax
+\t/* GCROOT %eax */
+\tcall\t_someFunction
+"""
+ lines = source.splitlines(True)
+ parts = list(GcRootTracker(format='mingw32').find_functions(iter(lines)))
+ lines = parts[1][1]
+ tracker = FunctionGcRootTracker(lines, format='mingw32')
+ tracker.computegcmaptable(verbose=sys.maxint)
+
def test_computegcmaptable():
tests = []
for format in ('elf', 'darwin'):
Modified: pypy/trunk/pypy/translator/c/gcc/trackgcroot.py
==============================================================================
--- pypy/trunk/pypy/translator/c/gcc/trackgcroot.py (original)
+++ pypy/trunk/pypy/translator/c/gcc/trackgcroot.py Tue Sep 22 15:37:23 2009
@@ -664,20 +664,21 @@
match = r_binaryinsn.match(line)
target = match.group(2)
if target == '%esp':
- # only for leal -12(%ebp), %esp in function epilogues
source = match.group(1)
match = r_localvar_ebp.match(source)
- if not match:
- framesize = None # strange instruction
- else:
+ # leal -12(%ebp), %esp in function epilogues
+ if match:
if not self.uses_frame_pointer:
raise UnrecognizedOperation('epilogue without prologue')
ofs_from_ebp = int(match.group(1) or '0')
assert ofs_from_ebp <= 0
framesize = 4 - ofs_from_ebp
- return InsnEpilogue(framesize)
- else:
- return self.binary_insn(line)
+ return InsnEpilogue(framesize)
+ match = r_localvar_esp.match(source)
+ # leal 12(%esp), %esp
+ if match:
+ return InsnStackAdjust(int(match.group(1)))
+ return self.binary_insn(line)
def insns_for_copy(self, source, target):
if source == '%esp' or target == '%esp':
More information about the Pypy-commit
mailing list