mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
fix handling of unusual exception handler layout
Scala sometimes generates bytecode such that the scope of an exception handler starts at another exception handler, e.g.: Exception table: from to target type 290 372 382 any 382 451 451 any 290 372 451 any Avian's compiler was incorrectly initializing the stack frame for the second handler in this case. This commit fixes the problem.
This commit is contained in:
parent
75f5921b3e
commit
67fd707254
@ -672,6 +672,8 @@ class Event {
|
||||
|
||||
virtual bool allExits() { return false; }
|
||||
|
||||
virtual Local* locals() { return localsBefore; }
|
||||
|
||||
Event* next;
|
||||
Stack* stackBefore;
|
||||
Local* localsBefore;
|
||||
@ -5183,8 +5185,9 @@ appendSaveLocals(Context* c)
|
||||
|
||||
class DummyEvent: public Event {
|
||||
public:
|
||||
DummyEvent(Context* c):
|
||||
Event(c)
|
||||
DummyEvent(Context* c, Local* locals):
|
||||
Event(c),
|
||||
locals_(locals)
|
||||
{ }
|
||||
|
||||
virtual const char* name() {
|
||||
@ -5192,6 +5195,12 @@ class DummyEvent: public Event {
|
||||
}
|
||||
|
||||
virtual void compile(Context*) { }
|
||||
|
||||
virtual Local* locals() {
|
||||
return locals_;
|
||||
}
|
||||
|
||||
Local* locals_;
|
||||
};
|
||||
|
||||
void
|
||||
@ -5204,7 +5213,7 @@ appendDummy(Context* c)
|
||||
c->stack = i->stack;
|
||||
c->locals = i->locals;
|
||||
|
||||
append(c, new(c->zone) DummyEvent(c));
|
||||
append(c, new(c->zone) DummyEvent(c, locals));
|
||||
|
||||
c->stack = stack;
|
||||
c->locals = locals;
|
||||
@ -6449,14 +6458,14 @@ class MyCompiler: public Compiler {
|
||||
|
||||
Event* e = c.logicalCode[logicalIp]->firstEvent;
|
||||
for (int i = 0; i < static_cast<int>(c.localFootprint); ++i) {
|
||||
Local* local = e->localsBefore + i;
|
||||
Local* local = e->locals() + i;
|
||||
if (local->value) {
|
||||
initLocal
|
||||
(1, i, local->value->type == ValueGeneral ? IntegerType : FloatType);
|
||||
}
|
||||
}
|
||||
|
||||
linkLocals(&c, e->localsBefore, newLocals);
|
||||
linkLocals(&c, e->locals(), newLocals);
|
||||
}
|
||||
|
||||
virtual void storeLocal(unsigned footprint, Operand* src, unsigned index) {
|
||||
|
Loading…
Reference in New Issue
Block a user