Skip to content

Commit

Permalink
Make exceptionHandlers in org.jikesrvm.compilers.opt.ir.BasicBlock pr…
Browse files Browse the repository at this point in the history
…ivate.
  • Loading branch information
erik-brangs committed Mar 1, 2016
1 parent 3d8b9a9 commit 9ba392a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
9 changes: 4 additions & 5 deletions rvm/src/org/jikesrvm/compilers/opt/bc2ir/BBSet.java
Expand Up @@ -510,7 +510,7 @@ void finalPass(boolean inlinedSomething) {
if (DBG_EX || DBG_FLATTEN) {
db("No (local) handlers were actually reachable for " + curr + "; setting to caller");
}
curr.block.exceptionHandlers = curr.block.exceptionHandlers.getCaller();
curr.block.setExceptionHandlers(curr.block.exceptionHandlers().getCaller());
} else {
ExceptionHandlerBasicBlock[] nlh =
new ExceptionHandlerBasicBlock[curr.handlers.length - notGenerated];
Expand All @@ -523,8 +523,7 @@ void finalPass(boolean inlinedSomething) {
}
}
}
curr.block.exceptionHandlers =
new ExceptionHandlerBasicBlockBag(nlh, curr.block.exceptionHandlers.getCaller());
curr.block.setExceptionHandlers(new ExceptionHandlerBasicBlockBag(nlh, curr.block.exceptionHandlers().getCaller()));
}
}
}
Expand Down Expand Up @@ -701,9 +700,9 @@ private void initializeExceptionHandlers(BasicBlockLE bble, Operand[] simLocals)
for (int i = 0; i < bble.handlers.length; i++) {
ehbbs[i] = bble.handlers[i].entryBlock;
}
bble.block.exceptionHandlers = new ExceptionHandlerBasicBlockBag(ehbbs, gc.getEnclosingHandlers());
bble.block.setExceptionHandlers(new ExceptionHandlerBasicBlockBag(ehbbs, gc.getEnclosingHandlers()));
} else {
bble.block.exceptionHandlers = gc.getEnclosingHandlers();
bble.block.setExceptionHandlers(gc.getEnclosingHandlers());
}
}

Expand Down
2 changes: 1 addition & 1 deletion rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java
Expand Up @@ -4697,7 +4697,7 @@ private boolean maybeInlineMethod(InlineDecision inlDec, Instruction callSite) {
// prevent the opt compiler from inlining a method that contains an
// unimplemented magic.
GenerationContext inlinedContext =
Inliner.execute(inlDec, gc, currentBBLE.block.exceptionHandlers, callSite);
Inliner.execute(inlDec, gc, currentBBLE.block.exceptionHandlers(), callSite);

inlinedSomething = true;
// TODO: We're currently not keeping track if any of the
Expand Down
10 changes: 5 additions & 5 deletions rvm/src/org/jikesrvm/compilers/opt/bc2ir/GenerationContext.java
Expand Up @@ -384,9 +384,9 @@ public GenerationContext createChildContext(ExceptionHandlerBasicBlockBag ebag,
// Initialize the child CFG, prologue, and epilogue blocks
child.cfg = new ControlFlowGraph(this.cfg.numberOfNodes());
child.prologue = new BasicBlock(PROLOGUE_BCI, child.inlineSequence, child.cfg);
child.prologue.exceptionHandlers = ebag;
child.prologue.setExceptionHandlers(ebag);
child.epilogue = new BasicBlock(EPILOGUE_BCI, child.inlineSequence, child.cfg);
child.epilogue.exceptionHandlers = ebag;
child.epilogue.setExceptionHandlers(ebag);
child.cfg.addLastInCodeOrder(child.prologue);
child.cfg.addLastInCodeOrder(child.epilogue);

Expand Down Expand Up @@ -487,9 +487,9 @@ public static GenerationContext createSynthetic(GenerationContext parent, Except
// and epilogue don't disappear, it was correct to have the
// parent's position. -- Matt
child.prologue = new BasicBlock(PROLOGUE_BCI, parent.inlineSequence, parent.cfg);
child.prologue.exceptionHandlers = ebag;
child.prologue.setExceptionHandlers(ebag);
child.epilogue = new BasicBlock(EPILOGUE_BCI, parent.inlineSequence, parent.cfg);
child.epilogue.exceptionHandlers = ebag;
child.epilogue.setExceptionHandlers(ebag);
child.cfg.addLastInCodeOrder(child.prologue);
child.cfg.addLastInCodeOrder(child.epilogue);

Expand Down Expand Up @@ -796,7 +796,7 @@ private void completeExceptionHandlers(boolean isOutermost) {
inlineSequence,
new TypeOperand(RVMType.JavaLangThrowableType),
cfg);
rethrow.exceptionHandlers = enclosingHandlers;
rethrow.setExceptionHandlers(enclosingHandlers);
RegisterOperand ceo = temps.makeTemp(TypeReference.JavaLangThrowable);
Instruction s = Nullary.create(GET_CAUGHT_EXCEPTION, ceo);
appendInstruction(rethrow, s, SYNTH_CATCH_BCI);
Expand Down
6 changes: 3 additions & 3 deletions rvm/src/org/jikesrvm/compilers/opt/inlining/Inliner.java
Expand Up @@ -182,7 +182,7 @@ public static GenerationContext execute(InlineDecision inlDec, GenerationContext
// Step 4: Create a block to contain a copy of the original call or an OSR_Yieldpoint
// to cover the case that all predictions fail.
BasicBlock testFailed = new BasicBlock(callSite.getBytecodeIndex(), callSite.position(), parent.getCfg());
testFailed.exceptionHandlers = ebag;
testFailed.setExceptionHandlers(ebag);

if (COUNT_FAILED_GUARDS && Controller.options.INSERT_DEBUGGING_COUNTERS) {
// Get a dynamic count of how many times guards fail at runtime.
Expand Down Expand Up @@ -270,7 +270,7 @@ public static GenerationContext execute(InlineDecision inlDec, GenerationContext
// "logical" test and to share test insertion for interfaces/virtuals.
for (int i = children.length - 1; i >= 0; i--, testFailed = firstIfBlock) {
firstIfBlock = new BasicBlock(callSite.getBytecodeIndex(), callSite.position(), parent.getCfg());
firstIfBlock.exceptionHandlers = ebag;
firstIfBlock.setExceptionHandlers(ebag);
BasicBlock lastIfBlock = firstIfBlock;
RVMMethod target = children[i].getMethod();
Instruction tmp;
Expand Down Expand Up @@ -317,7 +317,7 @@ public static GenerationContext execute(InlineDecision inlDec, GenerationContext
VM.sysWrite("\t\tRequired additional instanceof " + callDeclClass + " test\n");
}
firstIfBlock = new BasicBlock(callSite.getBytecodeIndex(), callSite.position(), parent.getCfg());
firstIfBlock.exceptionHandlers = ebag;
firstIfBlock.setExceptionHandlers(ebag);

RegisterOperand instanceOfResult = parent.getTemps().makeTempInt();
tmp =
Expand Down
10 changes: 9 additions & 1 deletion rvm/src/org/jikesrvm/compilers/opt/ir/BasicBlock.java
Expand Up @@ -120,7 +120,7 @@ public class BasicBlock extends SortedGraphNode {
* May be shared if multiple blocks have exactly the same chain
* of exception handlers.
*/
public ExceptionHandlerBasicBlockBag exceptionHandlers;
private ExceptionHandlerBasicBlockBag exceptionHandlers;

/**
* First instruction of the basic block (LABEL).
Expand Down Expand Up @@ -2034,4 +2034,12 @@ public void discardInstructions() {
end.getPrev().setNext(null);
start.linkWithNext(end);
}

public ExceptionHandlerBasicBlockBag exceptionHandlers() {
return exceptionHandlers;
}

public void setExceptionHandlers(ExceptionHandlerBasicBlockBag exceptionHandlers) {
this.exceptionHandlers = exceptionHandlers;
}
}
Expand Up @@ -1068,11 +1068,11 @@ private void assertThatPrologueAndEpilogueAreWiredCorrectlyForChildContext(
assertThat(child.getPrologue().firstInstruction().getBytecodeIndex(), is(PROLOGUE_BCI));
assertThat(child.getPrologue().firstInstruction().position(), is(child.getInlineSequence()));
assertThat(child.getPrologue().getNumber(), is(nodeNumber));
assertThat(child.getPrologue().exceptionHandlers, is(ebag));
assertThat(child.getPrologue().exceptionHandlers(), is(ebag));
assertThat(child.getEpilogue().firstInstruction().getBytecodeIndex(), is(EPILOGUE_BCI));
assertThat(child.getEpilogue().firstInstruction().position(), is(child.getInlineSequence()));
assertThat(child.getEpilogue().getNumber(), is(nodeNumber + 1));
assertThat(child.getEpilogue().exceptionHandlers, is(ebag));
assertThat(child.getEpilogue().exceptionHandlers(), is(ebag));
int newNodeNumber = nodeNumber + 2;
assertThat(child.getCfg().numberOfNodes(), is(newNodeNumber));
assertThat(child.getCfg().firstInCodeOrder(), is(child.getPrologue()));
Expand Down Expand Up @@ -1495,7 +1495,7 @@ private void assertThatUnlockAndRethrowBlockIsCorrectForInlinedMethod(Generation
ExceptionHandlerBasicBlockBag ehbb = childContext.getEnclosingHandlers();
Enumeration<BasicBlock> enumerator = ehbb.enumerator();

assertThat(childContext.getUnlockAndRethrow().exceptionHandlers, is(parentContext.getEnclosingHandlers()));
assertThat(childContext.getUnlockAndRethrow().exceptionHandlers(), is(parentContext.getEnclosingHandlers()));

ExceptionHandlerBasicBlock rethrow = (ExceptionHandlerBasicBlock) enumerator.nextElement();
assertSame(rethrow, childContext.getUnlockAndRethrow());
Expand Down Expand Up @@ -1708,11 +1708,11 @@ public void contextReturnedByGetSynthethicContextContainsOnlyCFG() throws Except
assertThat(synthethicContext.getPrologue().firstInstruction().getBytecodeIndex(), is(PROLOGUE_BCI));
assertThat(synthethicContext.getPrologue().firstInstruction().position(), is(gc.getInlineSequence()));
assertThat(synthethicContext.getPrologue().getNumber(), is(parentCfgNodeNumber));
assertThat(synthethicContext.getPrologue().exceptionHandlers, is(mockEbag));
assertThat(synthethicContext.getPrologue().exceptionHandlers(), is(mockEbag));
assertThat(synthethicContext.getEpilogue().firstInstruction().getBytecodeIndex(), is(EPILOGUE_BCI));
assertThat(synthethicContext.getEpilogue().firstInstruction().position(), is(gc.getInlineSequence()));
assertThat(synthethicContext.getEpilogue().getNumber(), is(parentCfgNodeNumber + 1));
assertThat(synthethicContext.getEpilogue().exceptionHandlers, is(mockEbag));
assertThat(synthethicContext.getEpilogue().exceptionHandlers(), is(mockEbag));
assertThat(gc.getCfg().numberOfNodes(), is(4));
assertThat(synthethicContext.getCfg().numberOfNodes(), is(synthethicNodeNumber));
assertThat(synthethicContext.getCfg().firstInCodeOrder(), is(synthethicContext.getPrologue()));
Expand Down

0 comments on commit 9ba392a

Please sign in to comment.