Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44839:de1e462f98d8
Date: 2011-06-08 20:20 +0200
http://bitbucket.org/pypy/pypy/changeset/de1e462f98d8/
Log: Tests and fix: "pushl 40(%esp)" pushes the value that was in
40(%esp) before %esp was decremented. Similarly for "popl".
diff --git a/pypy/translator/c/gcc/test/elf/track12.s
b/pypy/translator/c/gcc/test/elf/track12.s
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/gcc/test/elf/track12.s
@@ -0,0 +1,9 @@
+ .type pypy_f, @function
+pypy_f:
+ pushl 4(%esp)
+ call pypy_other
+ ;; expected {4(%esp) | %ebx, %esi, %edi, %ebp | (%esp)}
+ popl %eax
+ /* GCROOT %eax */
+ ret
+ .size pypy_f, .-pypy_f
diff --git a/pypy/translator/c/gcc/test/elf/track13.s
b/pypy/translator/c/gcc/test/elf/track13.s
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/gcc/test/elf/track13.s
@@ -0,0 +1,9 @@
+ .type pypy_f, @function
+pypy_f:
+ call pypy_other
+ ;; expected {(%esp) | %ebx, %esi, %edi, %ebp | 8(%esp)}
+ pushl 8(%esp)
+ popl %eax
+ /* GCROOT %eax */
+ ret
+ .size pypy_f, .-pypy_f
diff --git a/pypy/translator/c/gcc/trackgcroot.py
b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -271,7 +271,8 @@
match = self.r_localvar_esp.match(localvar)
if match:
- if localvar == self.TOP_OF_STACK: # for pushl and popl, by
+ if localvar == self.TOP_OF_STACK_MINUS_WORD:
+ # for pushl and popl, by
hint = None # default ebp addressing is
else: # a bit nicer
hint = 'esp'
@@ -591,10 +592,12 @@
def _visit_push(self, line):
match = self.r_unaryinsn.match(line)
source = match.group(1)
- return [InsnStackAdjust(-self.WORD)] + self.insns_for_copy(source,
self.TOP_OF_STACK)
+ return self.insns_for_copy(source, self.TOP_OF_STACK_MINUS_WORD) + \
+ [InsnStackAdjust(-self.WORD)]
def _visit_pop(self, target):
- return self.insns_for_copy(self.TOP_OF_STACK, target) +
[InsnStackAdjust(+self.WORD)]
+ return [InsnStackAdjust(+self.WORD)] + \
+ self.insns_for_copy(self.TOP_OF_STACK_MINUS_WORD, target)
def _visit_prologue(self):
# for the prologue of functions that use %ebp as frame pointer
@@ -986,15 +989,15 @@
OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
LABEL = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
OFFSET_LABELS = 2**30
- TOP_OF_STACK = '0(%esp)'
+ TOP_OF_STACK_MINUS_WORD = '-4(%esp)'
r_functionstart = re.compile(r"\t.type\s+"+LABEL+",\s*[@]function\s*$")
r_functionend = re.compile(r"\t.size\s+"+LABEL+",\s*[.]-"+LABEL+"\s*$")
- LOCALVAR = r"%eax|%edx|%ecx|%ebx|%esi|%edi|%ebp|\d*[(]%esp[)]"
+ LOCALVAR = r"%eax|%edx|%ecx|%ebx|%esi|%edi|%ebp|-?\d*[(]%esp[)]"
LOCALVARFP = LOCALVAR + r"|-?\d*[(]%ebp[)]"
r_localvarnofp = re.compile(LOCALVAR)
r_localvarfp = re.compile(LOCALVARFP)
- r_localvar_esp = re.compile(r"(\d*)[(]%esp[)]")
+ r_localvar_esp = re.compile(r"(-?\d*)[(]%esp[)]")
r_localvar_ebp = re.compile(r"(-?\d*)[(]%ebp[)]")
r_rel_label = re.compile(r"(\d+):\s*$")
@@ -1047,7 +1050,7 @@
OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
LABEL = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
OFFSET_LABELS = 2**30
- TOP_OF_STACK = '0(%rsp)'
+ TOP_OF_STACK_MINUS_WORD = '-8(%rsp)'
r_functionstart = re.compile(r"\t.type\s+"+LABEL+",\s*[@]function\s*$")
r_functionend = re.compile(r"\t.size\s+"+LABEL+",\s*[.]-"+LABEL+"\s*$")
@@ -1143,7 +1146,7 @@
CALLEE_SAVE_REGISTERS = ['ebx', 'esi', 'edi', 'ebp']
REG2LOC = dict((_reg, LOC_REG | ((_i+1)<<2))
for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS))
- TOP_OF_STACK = 'DWORD PTR [esp]'
+ TOP_OF_STACK_MINUS_WORD = 'DWORD PTR [esp-4]'
OPERAND = r'(?:(:?WORD|DWORD|BYTE) PTR |OFFSET
)?[_\w?:@$]*(?:[-+0-9]+)?(:?\[[-+*\w0-9]+\])?'
LABEL = r'([a-zA-Z_$@.][a-zA-Z0-9_$@.]*)'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit