fix parameter offset calculation in invokeNative2

This commit is contained in:
Joel Dice 2009-02-28 12:33:26 -07:00
parent 8ecd6a0394
commit f22ce3f996

View File

@ -89,13 +89,18 @@ class MyThread: public Thread {
Assembler::Architecture* arch; Assembler::Architecture* arch;
}; };
unsigned
parameterOffset(MyThread* t, object method)
{
return methodParameterFootprint(t, method)
+ t->arch->frameFooterSize()
+ t->arch->frameReturnAddressSize() - 1;
}
object 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)[parameterOffset(t, method)];
[methodParameterFootprint(t, method)
+ t->arch->frameFooterSize()
+ t->arch->frameReturnAddressSize() - 1];
} }
object object
@ -4161,7 +4166,11 @@ finish(MyThread* t, Allocator* allocator, Context* context)
(&byteArrayBody(t, methodName(t, context->method), 0)), (&byteArrayBody(t, methodName(t, context->method), 0)),
"main") == 0) "main") == 0)
{ {
#ifdef __POWERPC__
asm("trap");
#else
asm("int3"); asm("int3");
#endif
} }
return start; return start;
@ -4390,7 +4399,7 @@ invokeNative2(MyThread* t, object method)
types[typeOffset++] = POINTER_TYPE; types[typeOffset++] = POINTER_TYPE;
uintptr_t* sp = static_cast<uintptr_t*>(t->stack) uintptr_t* sp = static_cast<uintptr_t*>(t->stack)
+ methodParameterFootprint(t, method) + t->arch->frameFooterSize(); + parameterOffset(t, method);
if (methodFlags(t, method) & ACC_STATIC) { if (methodFlags(t, method) & ACC_STATIC) {
args[argOffset++] = reinterpret_cast<uintptr_t>(&class_); args[argOffset++] = reinterpret_cast<uintptr_t>(&class_);