Skip to content

Commit 026778b

Browse files
committed
Ensure the operand stack is cleared when an exception is caught
1 parent 80db138 commit 026778b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ private CodeExecutableElement createCreateBranchLabelMapping() {
20072007
b.statement("HashMap<Integer, OperationLabel> result = new HashMap<>()");
20082008
b.startFor().string("OperationLabel lbl : unresolvedLabels.keySet()").end().startBlock();
20092009
b.startFor().startGroup().type(bytecodeLocation.asType()).string(" site : unresolvedLabels.get(lbl)").end(2).startBlock();
2010-
b.statement("assert !result.containsKey(site)");
2010+
b.statement("assert !result.containsKey(site.bci)");
20112011
b.statement("result.put(site.bci, lbl)");
20122012
b.end(2);
20132013
b.startReturn().string("result").end();
@@ -3896,7 +3896,12 @@ private List<CodeExecutableElement> createContinueAt() {
38963896
b.startIf().string("handlers[idx] > bci").end().startBlock().statement("continue").end();
38973897
b.startIf().string("handlers[idx + 1] <= bci").end().startBlock().statement("continue").end();
38983898
b.statement("bci = handlers[idx + 2]");
3899-
b.statement("sp = handlers[idx + 3] + $this.numLocals");
3899+
b.statement("int handlerSp = handlers[idx + 3] + $this.numLocals");
3900+
b.statement("assert sp >= handlerSp");
3901+
b.startWhile().string("sp > handlerSp").end().startBlock();
3902+
b.statement(clearFrame("--sp"));
3903+
b.end();
3904+
39003905
b.statement(setFrameObject(localFrame(), "handlers[idx + 4]", "ex"));
39013906

39023907
b.statement("continue loop");

0 commit comments

Comments
 (0)