ensure native method frame always popped in interpret.cpp's invokeNative

If a native method using the fast calling convention throws an
exception, we need to make sure the frame for that method is popped
before handling the exception.
This commit is contained in:
Joel Dice 2011-02-01 19:23:25 -07:00
parent c4ededda83
commit 79247a9885

View File

@ -658,23 +658,25 @@ invokeNative(Thread* t, object method)
if (nativeFast(t, native)) {
pushFrame(t, method);
unsigned footprint = methodParameterFootprint(t, method);
RUNTIME_ARRAY(uintptr_t, args, footprint);
unsigned sp = frameBase(t, t->frame);
unsigned argOffset = 0;
if ((methodFlags(t, method) & ACC_STATIC) == 0) {
RUNTIME_ARRAY_BODY(args)[argOffset++]
= reinterpret_cast<uintptr_t>(peekObject(t, sp++));
uint64_t result;
{ THREAD_RESOURCE0(t, popFrame(static_cast<Thread*>(t)));
unsigned footprint = methodParameterFootprint(t, method);
RUNTIME_ARRAY(uintptr_t, args, footprint);
unsigned sp = frameBase(t, t->frame);
unsigned argOffset = 0;
if ((methodFlags(t, method) & ACC_STATIC) == 0) {
RUNTIME_ARRAY_BODY(args)[argOffset++]
= reinterpret_cast<uintptr_t>(peekObject(t, sp++));
}
marshalArguments
(t, RUNTIME_ARRAY_BODY(args) + argOffset, 0, sp, method, true);
result = reinterpret_cast<FastNativeFunction>
(nativeFunction(t, native))(t, method, RUNTIME_ARRAY_BODY(args));
}
marshalArguments
(t, RUNTIME_ARRAY_BODY(args) + argOffset, 0, sp, method, true);
uint64_t result = reinterpret_cast<FastNativeFunction>
(nativeFunction(t, native))(t, method, RUNTIME_ARRAY_BODY(args));
popFrame(t);
pushResult(t, methodReturnCode(t, method), result, false);
return methodReturnCode(t, method);