Author: Armin Rigo <[email protected]>
Branch: stacklet
Changeset: r46348:9a91bafa2aa7
Date: 2011-08-07 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/9a91bafa2aa7/
Log: Fix: missed a case in which asmgcroot reads the stack, which must be
mapped through translateptr() in _stacklet_asmgcc.
diff --git a/pypy/rlib/_stacklet_asmgcc.py b/pypy/rlib/_stacklet_asmgcc.py
--- a/pypy/rlib/_stacklet_asmgcc.py
+++ b/pypy/rlib/_stacklet_asmgcc.py
@@ -15,7 +15,7 @@
return _stackletrootwalker
from pypy.rpython.memory.gctransform.asmgcroot import (
- WALKFRAME, CALLEE_SAVED_REGS, sizeofaddr)
+ WALKFRAME, CALLEE_SAVED_REGS, INDEX_OF_EBP, sizeofaddr)
assert _asmstackrootwalker is not None, "should have been monkey-patched"
basewalker = _asmstackrootwalker
@@ -83,11 +83,15 @@
# not really a loop, but kept this way for similarity
# with asmgcroot:
callee = self.curframe
+ ebp_in_caller = callee.regs_stored_at[INDEX_OF_EBP]
+ ebp_in_caller = self.translateptr(ebp_in_caller)
+ ebp_in_caller = ebp_in_caller.address[0]
while True:
location = basewalker._shape_decompressor.next()
if location == 0:
break
- addr = basewalker.getlocation(callee, location)
+ addr = basewalker.getlocation(callee, ebp_in_caller,
+ location)
# yield the translated addr of the next GCREF in the stack
return self.translateptr(addr)
#
@@ -96,12 +100,15 @@
reg = CALLEE_SAVED_REGS - 1
while reg >= 0:
location = basewalker._shape_decompressor.next()
- addr = basewalker.getlocation(callee, location)
+ addr = basewalker.getlocation(callee, ebp_in_caller,
+ location)
caller.regs_stored_at[reg] = addr # non-translated
reg -= 1
location = basewalker._shape_decompressor.next()
- caller.frame_address = basewalker.getlocation(callee, location)
+ caller.frame_address = basewalker.getlocation(callee,
+ ebp_in_caller,
+ location)
# ^^^ non-translated
if caller.frame_address == llmemory.NULL:
return self.teardown() # completely done with this stack
diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py
b/pypy/rpython/memory/gctransform/asmgcroot.py
--- a/pypy/rpython/memory/gctransform/asmgcroot.py
+++ b/pypy/rpython/memory/gctransform/asmgcroot.py
@@ -366,12 +366,13 @@
# found! Enumerate the GC roots in the caller frame
#
collect_stack_root = self.gcdata._gc_collect_stack_root
+ ebp_in_caller = callee.regs_stored_at[INDEX_OF_EBP].address[0]
gc = self.gc
while True:
location = self._shape_decompressor.next()
if location == 0:
break
- addr = self.getlocation(callee, location)
+ addr = self.getlocation(callee, ebp_in_caller, location)
if gc.points_to_valid_gc_object(addr):
collect_stack_root(gc, addr)
#
@@ -381,12 +382,13 @@
reg = CALLEE_SAVED_REGS - 1
while reg >= 0:
location = self._shape_decompressor.next()
- addr = self.getlocation(callee, location)
+ addr = self.getlocation(callee, ebp_in_caller, location)
caller.regs_stored_at[reg] = addr
reg -= 1
location = self._shape_decompressor.next()
- caller.frame_address = self.getlocation(callee, location)
+ caller.frame_address = self.getlocation(callee, ebp_in_caller,
+ location)
# we get a NULL marker to mean "I'm the frame
# of the entry point, stop walking"
return caller.frame_address != llmemory.NULL
@@ -434,7 +436,7 @@
return
llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
- def getlocation(self, callee, location):
+ def getlocation(self, callee, ebp_in_caller, location):
"""Get the location in the 'caller' frame of a variable, based
on the integer 'location' that describes it. All locations are
computed based on information saved by the 'callee'.
@@ -452,10 +454,8 @@
esp_in_caller = callee.frame_address + sizeofaddr
return esp_in_caller + offset
elif kind == LOC_EBP_PLUS: # in the caller stack frame at N(%ebp)
- ebp_in_caller = callee.regs_stored_at[INDEX_OF_EBP].address[0]
return ebp_in_caller + offset
else: # kind == LOC_EBP_MINUS: at -N(%ebp)
- ebp_in_caller = callee.regs_stored_at[INDEX_OF_EBP].address[0]
return ebp_in_caller - offset
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit