mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
restore state from subroutine after jsr to avoid later confusion determining basic block boundaries
This commit is contained in:
parent
5f6f8039e6
commit
d12b441aa1
@ -1480,7 +1480,7 @@ class Frame {
|
||||
}
|
||||
|
||||
void endSubroutine(unsigned nextIndexIndex) {
|
||||
c->cleanLocals();
|
||||
c->linkSubroutine(subroutine->handle);
|
||||
|
||||
poppedInt();
|
||||
|
||||
|
@ -4952,9 +4952,14 @@ class MyCompiler: public Compiler {
|
||||
}
|
||||
|
||||
virtual void endSubroutine(Subroutine* subroutine) {
|
||||
appendCleanLocals(&c);
|
||||
static_cast<MySubroutine*>(subroutine)->forkState = ::saveState(&c);
|
||||
}
|
||||
|
||||
virtual void linkSubroutine(Subroutine* subroutine) {
|
||||
restoreState(static_cast<MySubroutine*>(subroutine)->forkState);
|
||||
}
|
||||
|
||||
virtual void init(unsigned logicalCodeLength, unsigned parameterFootprint,
|
||||
unsigned localFootprint, unsigned alignedFrameSize)
|
||||
{
|
||||
@ -5372,10 +5377,6 @@ class MyCompiler: public Compiler {
|
||||
appendSaveLocals(&c);
|
||||
}
|
||||
|
||||
virtual void cleanLocals() {
|
||||
appendCleanLocals(&c);
|
||||
}
|
||||
|
||||
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
||||
Operand* index, intptr_t handler)
|
||||
{
|
||||
|
@ -43,6 +43,7 @@ class Compiler {
|
||||
|
||||
virtual Subroutine* startSubroutine() = 0;
|
||||
virtual void endSubroutine(Subroutine* subroutine) = 0;
|
||||
virtual void linkSubroutine(Subroutine* subroutine) = 0;
|
||||
|
||||
virtual void init(unsigned logicalCodeSize, unsigned parameterFootprint,
|
||||
unsigned localFootprint, unsigned alignedFrameSize) = 0;
|
||||
@ -95,7 +96,6 @@ class Compiler {
|
||||
unsigned index) = 0;
|
||||
virtual Operand* loadLocal(unsigned footprint, unsigned index) = 0;
|
||||
virtual void saveLocals() = 0;
|
||||
virtual void cleanLocals() = 0;
|
||||
|
||||
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
||||
Operand* index, intptr_t handler) = 0;
|
||||
|
@ -113,6 +113,31 @@ public class Subroutine {
|
||||
}
|
||||
}
|
||||
|
||||
private static long test4(int path) {
|
||||
try {
|
||||
try {
|
||||
switch (path) {
|
||||
case 1:
|
||||
return 42L;
|
||||
|
||||
case 2: {
|
||||
int a = 42;
|
||||
return 52L;
|
||||
}
|
||||
|
||||
case 3:
|
||||
throw new DummyException();
|
||||
}
|
||||
} finally {
|
||||
System.gc();
|
||||
}
|
||||
return 0L;
|
||||
} catch (DummyException e) {
|
||||
e.printStackTrace();
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(false, false);
|
||||
test(false, true);
|
||||
@ -157,6 +182,10 @@ public class Subroutine {
|
||||
String.valueOf(test3(1, 3, 3));
|
||||
String.valueOf(test3(2, 3, 3));
|
||||
String.valueOf(test3(3, 3, 3));
|
||||
|
||||
String.valueOf(test4(1));
|
||||
String.valueOf(test4(2));
|
||||
String.valueOf(test4(3));
|
||||
}
|
||||
|
||||
private static class DummyException extends RuntimeException { }
|
||||
|
Loading…
Reference in New Issue
Block a user