use of org.graalvm.compiler.java.BciBlockMapping.ExceptionDispatchBlock in project graal by oracle.
the class BytecodeParser method checkLoopExit.
private Target checkLoopExit(FixedNode target, BciBlock targetBlock, FrameStateBuilder state) {
if (currentBlock != null) {
long exits = currentBlock.loops & ~targetBlock.loops;
if (exits != 0) {
LoopExitNode firstLoopExit = null;
LoopExitNode lastLoopExit = null;
int pos = 0;
ArrayList<BciBlock> exitLoops = new ArrayList<>(Long.bitCount(exits));
do {
long lMask = 1L << pos;
if ((exits & lMask) != 0) {
exitLoops.add(blockMap.getLoopHeader(pos));
exits &= ~lMask;
}
pos++;
} while (exits != 0);
Collections.sort(exitLoops, new Comparator<BciBlock>() {
@Override
public int compare(BciBlock o1, BciBlock o2) {
return Long.bitCount(o2.loops) - Long.bitCount(o1.loops);
}
});
int bci = targetBlock.startBci;
if (targetBlock instanceof ExceptionDispatchBlock) {
bci = ((ExceptionDispatchBlock) targetBlock).deoptBci;
}
FrameStateBuilder newState = state.copy();
for (BciBlock loop : exitLoops) {
LoopBeginNode loopBegin = (LoopBeginNode) getFirstInstruction(loop);
LoopExitNode loopExit = graph.add(new LoopExitNode(loopBegin));
if (lastLoopExit != null) {
lastLoopExit.setNext(loopExit);
}
if (firstLoopExit == null) {
firstLoopExit = loopExit;
}
lastLoopExit = loopExit;
debug.log("Target %s Exits %s, scanning framestates...", targetBlock, loop);
newState.clearNonLiveLocals(targetBlock, liveness, true);
newState.insertLoopProxies(loopExit, getEntryState(loop));
loopExit.setStateAfter(newState.create(bci, loopExit));
}
lastLoopExit.setNext(target);
return new Target(firstLoopExit, newState);
}
}
return new Target(target, state);
}
use of org.graalvm.compiler.java.BciBlockMapping.ExceptionDispatchBlock in project graal by oracle.
the class BytecodeParser method setMergeStateAfter.
private void setMergeStateAfter(BciBlock block, FixedWithNextNode firstInstruction) {
AbstractMergeNode abstractMergeNode = (AbstractMergeNode) firstInstruction;
if (abstractMergeNode.stateAfter() == null) {
int bci = block.startBci;
if (block instanceof ExceptionDispatchBlock) {
bci = ((ExceptionDispatchBlock) block).deoptBci;
}
abstractMergeNode.setStateAfter(createFrameState(bci, abstractMergeNode));
}
}
use of org.graalvm.compiler.java.BciBlockMapping.ExceptionDispatchBlock in project graal by oracle.
the class BytecodeParser method processBlock.
@SuppressWarnings("try")
protected void processBlock(BciBlock block) {
// Ignore blocks that have no predecessors by the time their bytecodes are parsed
FixedWithNextNode firstInstruction = getFirstInstruction(block);
if (firstInstruction == null) {
debug.log("Ignoring block %s", block);
return;
}
try (Indent indent = debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, firstInstruction, block.isLoopHeader)) {
lastInstr = firstInstruction;
frameState = getEntryState(block);
setCurrentFrameState(frameState);
currentBlock = block;
if (block != blockMap.getUnwindBlock() && !(block instanceof ExceptionDispatchBlock)) {
frameState.setRethrowException(false);
}
if (firstInstruction instanceof AbstractMergeNode) {
setMergeStateAfter(block, firstInstruction);
}
if (block == blockMap.getUnwindBlock()) {
handleUnwindBlock((ExceptionDispatchBlock) block);
} else if (block instanceof ExceptionDispatchBlock) {
createExceptionDispatch((ExceptionDispatchBlock) block);
} else {
iterateBytecodesForBlock(block);
}
}
}
Aggregations