mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix special case of exception handler table translation
scalac may generate bytecode such that an exception is thrown within the bounds of a handler for that exception such that the throw is the last instruction in the method, which we weren't handling properly.
This commit is contained in:
parent
a18452f6c9
commit
023787d121
@ -6459,11 +6459,11 @@ resolveIpBackwards(Context* context, int start, int end)
|
|||||||
if (start >= static_cast<int>
|
if (start >= static_cast<int>
|
||||||
(codeLength(t, methodCode(t, context->method))))
|
(codeLength(t, methodCode(t, context->method))))
|
||||||
{
|
{
|
||||||
start = codeLength(t, methodCode(t, context->method)) - 1;
|
start = codeLength(t, methodCode(t, context->method));
|
||||||
}
|
} else {
|
||||||
|
while (start >= end and context->visitTable[start] == 0) {
|
||||||
while (start >= end and context->visitTable[start] == 0) {
|
-- start;
|
||||||
-- start;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < end) {
|
if (start < end) {
|
||||||
@ -6523,7 +6523,8 @@ truncateLineNumberTable(Thread* t, object table, unsigned length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
object
|
object
|
||||||
translateExceptionHandlerTable(MyThread* t, Context* context, intptr_t start)
|
translateExceptionHandlerTable(MyThread* t, Context* context, intptr_t start,
|
||||||
|
intptr_t end)
|
||||||
{
|
{
|
||||||
avian::codegen::Compiler* c = context->compiler;
|
avian::codegen::Compiler* c = context->compiler;
|
||||||
|
|
||||||
@ -6559,14 +6560,16 @@ translateExceptionHandlerTable(MyThread* t, Context* context, intptr_t start)
|
|||||||
exceptionHandlerStart(oldHandler));
|
exceptionHandlerStart(oldHandler));
|
||||||
|
|
||||||
assert(t, handlerEnd >= 0);
|
assert(t, handlerEnd >= 0);
|
||||||
assert(t, handlerEnd < static_cast<int>
|
assert(t, handlerEnd <= static_cast<int>
|
||||||
(codeLength(t, methodCode(t, context->method))));
|
(codeLength(t, methodCode(t, context->method))));
|
||||||
|
|
||||||
intArrayBody(t, newIndex, ni * 3)
|
intArrayBody(t, newIndex, ni * 3)
|
||||||
= c->machineIp(handlerStart)->value() - start;
|
= c->machineIp(handlerStart)->value() - start;
|
||||||
|
|
||||||
intArrayBody(t, newIndex, (ni * 3) + 1)
|
intArrayBody(t, newIndex, (ni * 3) + 1)
|
||||||
= c->machineIp(handlerEnd)->value() - start;
|
= (handlerEnd == static_cast<int>
|
||||||
|
(codeLength(t, methodCode(t, context->method)))
|
||||||
|
? end : c->machineIp(handlerEnd)->value()) - start;
|
||||||
|
|
||||||
intArrayBody(t, newIndex, (ni * 3) + 2)
|
intArrayBody(t, newIndex, (ni * 3) + 2)
|
||||||
= c->machineIp(exceptionHandlerIp(oldHandler))->value() - start;
|
= c->machineIp(exceptionHandlerIp(oldHandler))->value() - start;
|
||||||
@ -7339,7 +7342,8 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ object newExceptionHandlerTable = translateExceptionHandlerTable
|
{ object newExceptionHandlerTable = translateExceptionHandlerTable
|
||||||
(t, context, reinterpret_cast<intptr_t>(start));
|
(t, context, reinterpret_cast<intptr_t>(start),
|
||||||
|
reinterpret_cast<intptr_t>(start) + codeSize);
|
||||||
|
|
||||||
PROTECT(t, newExceptionHandlerTable);
|
PROTECT(t, newExceptionHandlerTable);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user