mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +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>
|
||||
(codeLength(t, methodCode(t, context->method))))
|
||||
{
|
||||
start = codeLength(t, methodCode(t, context->method)) - 1;
|
||||
}
|
||||
|
||||
while (start >= end and context->visitTable[start] == 0) {
|
||||
-- start;
|
||||
start = codeLength(t, methodCode(t, context->method));
|
||||
} else {
|
||||
while (start >= end and context->visitTable[start] == 0) {
|
||||
-- start;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < end) {
|
||||
@ -6523,7 +6523,8 @@ truncateLineNumberTable(Thread* t, object table, unsigned length)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -6559,14 +6560,16 @@ translateExceptionHandlerTable(MyThread* t, Context* context, intptr_t start)
|
||||
exceptionHandlerStart(oldHandler));
|
||||
|
||||
assert(t, handlerEnd >= 0);
|
||||
assert(t, handlerEnd < static_cast<int>
|
||||
assert(t, handlerEnd <= static_cast<int>
|
||||
(codeLength(t, methodCode(t, context->method))));
|
||||
|
||||
intArrayBody(t, newIndex, ni * 3)
|
||||
= c->machineIp(handlerStart)->value() - start;
|
||||
|
||||
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)
|
||||
= c->machineIp(exceptionHandlerIp(oldHandler))->value() - start;
|
||||
@ -7339,7 +7342,8 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
|
||||
}
|
||||
|
||||
{ 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user