fix stack offset calculation for powerpc

This may break x86, in which case we'll iterate until they both work.
This commit is contained in:
Joel Dice 2009-02-26 18:54:25 -07:00
parent 73aa499371
commit 4999c08e32

View File

@ -27,7 +27,7 @@ vmCall();
namespace { namespace {
const bool DebugCompile = false; const bool DebugCompile = true;
const bool DebugNatives = false; const bool DebugNatives = false;
const bool DebugCallTable = false; const bool DebugCallTable = false;
const bool DebugMethodTree = false; const bool DebugMethodTree = false;
@ -93,7 +93,9 @@ object
resolveThisPointer(MyThread* t, void* stack, object method) resolveThisPointer(MyThread* t, void* stack, object method)
{ {
return reinterpret_cast<object*>(stack) return reinterpret_cast<object*>(stack)
[methodParameterFootprint(t, method) + t->arch->frameFooterSize()]; [methodParameterFootprint(t, method)
+ t->arch->frameFooterSize()
+ t->arch->frameReturnAddressSize() - 1];
} }
object object
@ -349,9 +351,15 @@ alignedFrameSize(MyThread* t, object method)
} }
unsigned unsigned
alignedFrameSizeWithParameters(MyThread* t, object method) usableFrameSize(MyThread* t, object method)
{ {
return methodParameterFootprint(t, method) + alignedFrameSize(t, method); return alignedFrameSize(t, method) - t->arch->frameFooterSize();
}
unsigned
usableFrameSizeWithParameters(MyThread* t, object method)
{
return methodParameterFootprint(t, method) + usableFrameSize(t, method);
} }
int int
@ -363,12 +371,11 @@ localOffset(MyThread* t, int v, object method)
int offset = ((v < parameterFootprint) ? int offset = ((v < parameterFootprint) ?
(frameSize (frameSize
+ parameterFootprint + parameterFootprint
+ (t->arch->frameFooterSize() * 2) + t->arch->frameFooterSize()
+ t->arch->frameHeaderSize() + t->arch->frameHeaderSize()
- v - 1) : - v - 1) :
(frameSize (frameSize
+ parameterFootprint + parameterFootprint
+ t->arch->frameFooterSize()
- v - 1)) * BytesPerWord; - v - 1)) * BytesPerWord;
assert(t, offset >= 0); assert(t, offset >= 0);
@ -452,7 +459,7 @@ enum Event {
unsigned unsigned
frameMapSizeInWords(MyThread* t, object method) frameMapSizeInWords(MyThread* t, object method)
{ {
return ceiling(alignedFrameSizeWithParameters(t, method), BitsPerWord) return ceiling(usableFrameSizeWithParameters(t, method), BitsPerWord)
* BytesPerWord; * BytesPerWord;
} }
@ -1248,21 +1255,17 @@ findUnwindTarget(MyThread* t, void** targetIp, void** targetBase,
void* handler = findExceptionHandler(t, method, ip); void* handler = findExceptionHandler(t, method, ip);
if (handler) { if (handler) {
unsigned parameterFootprint = methodParameterFootprint(t, method); void** sp = static_cast<void**>(stack)
unsigned localFootprint = localSize(t, method); + t->arch->frameReturnAddressSize();
static_cast<void**>(stack) sp[localOffset(t, localSize(t, method), method) / BytesPerWord]
[alignedFrameSize(t, method) - t->arch->frameHeaderSize()
- (localFootprint - parameterFootprint - 1)
+ t->arch->frameReturnAddressSize()]
= t->exception; = t->exception;
t->exception = 0; t->exception = 0;
*targetIp = handler; *targetIp = handler;
*targetBase = base; *targetBase = base;
*targetStack = static_cast<void**>(stack) *targetStack = sp;
+ t->arch->frameReturnAddressSize();
} else { } else {
if (methodFlags(t, method) & ACC_SYNCHRONIZED) { if (methodFlags(t, method) & ACC_SYNCHRONIZED) {
object lock; object lock;
@ -3951,7 +3954,7 @@ compareTraceElementPointers(const void* va, const void* vb)
unsigned unsigned
frameObjectMapSize(MyThread* t, object method, object map) frameObjectMapSize(MyThread* t, object method, object map)
{ {
int size = alignedFrameSizeWithParameters(t, method); int size = usableFrameSizeWithParameters(t, method);
return ceiling(intArrayLength(t, map) * size, 32 + size); return ceiling(intArrayLength(t, map) * size, 32 + size);
} }
@ -4077,7 +4080,7 @@ finish(MyThread* t, Allocator* allocator, Context* context)
qsort(elements, context->traceLogCount, sizeof(TraceElement*), qsort(elements, context->traceLogCount, sizeof(TraceElement*),
compareTraceElementPointers); compareTraceElementPointers);
unsigned size = alignedFrameSizeWithParameters(t, context->method); unsigned size = usableFrameSizeWithParameters(t, context->method);
object map = makeIntArray object map = makeIntArray
(t, context->traceLogCount (t, context->traceLogCount
+ ceiling(context->traceLogCount * size, 32), + ceiling(context->traceLogCount * size, 32),
@ -4567,7 +4570,7 @@ frameMapIndex(MyThread* t, object method, int32_t offset)
if (offset == v) { if (offset == v) {
return (indexSize * 32) return (indexSize * 32)
+ (alignedFrameSizeWithParameters(t, method) * middle); + (usableFrameSizeWithParameters(t, method) * middle);
} else if (offset < v) { } else if (offset < v) {
top = middle; top = middle;
} else { } else {
@ -4584,9 +4587,9 @@ visitStackAndLocals(MyThread* t, Heap::Visitor* v, void* stack, object method,
{ {
unsigned count; unsigned count;
if (calleeStack) { if (calleeStack) {
count = alignedFrameSizeWithParameters(t, method) - argumentFootprint; count = usableFrameSizeWithParameters(t, method) - argumentFootprint;
} else { } else {
count = alignedFrameSizeWithParameters(t, method); count = usableFrameSizeWithParameters(t, method);
} }
if (count) { if (count) {