use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class ReentrantBlockIterator method processMultipleSuccessors.
private static <StateT> Block processMultipleSuccessors(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, EconomicMap<FixedNode, StateT> states, StateT state, Block[] successors) {
assert successors.length > 1;
for (int i = 1; i < successors.length; i++) {
Block successor = successors[i];
blockQueue.addFirst(successor);
states.put(successor.getBeginNode(), closure.cloneState(state));
}
return successors[0];
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class GuardLoweringPhase method run.
@Override
protected void run(StructuredGraph graph, MidTierContext context) {
if (graph.getGuardsStage().allowsFloatingGuards()) {
SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
schedulePhase.apply(graph);
ScheduleResult schedule = graph.getLastSchedule();
for (Block block : schedule.getCFG().getBlocks()) {
processBlock(block, schedule);
}
graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
}
assert assertNoGuardsLeft(graph);
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class LoweringPhase method processBlockBounded.
public static void processBlockBounded(final Frame<?> rootFrame) {
ProcessBlockState state = ST_PROCESS;
Frame<?> f = rootFrame;
while (f != null) {
ProcessBlockState nextState;
if (state == ST_PROCESS || state == ST_PROCESS_ALWAYS_REACHED) {
f.preprocess();
nextState = state == ST_PROCESS_ALWAYS_REACHED ? ST_ENTER : ST_ENTER_ALWAYS_REACHED;
} else if (state == ST_ENTER_ALWAYS_REACHED) {
if (f.alwaysReachedBlock != null && f.alwaysReachedBlock.getDominator() == f.block) {
Frame<?> continueRecur = f.enterAlwaysReached(f.alwaysReachedBlock);
if (continueRecur == null) {
// stop recursion here
f.postprocess();
f = f.parent;
state = ST_ENTER;
continue;
}
f = continueRecur;
nextState = ST_PROCESS;
} else {
nextState = ST_ENTER;
}
} else if (state == ST_ENTER) {
if (f.dominated != null) {
Block n = f.dominated;
f.dominated = n.getDominatedSibling();
if (n == f.alwaysReachedBlock) {
if (f.dominated != null) {
n = f.dominated;
f.dominated = n.getDominatedSibling();
} else {
n = null;
}
}
if (n == null) {
nextState = ST_LEAVE;
} else {
Frame<?> continueRecur = f.enter(n);
if (continueRecur == null) {
// stop recursion here
f.postprocess();
f = f.parent;
state = ST_ENTER;
continue;
}
f = continueRecur;
nextState = ST_PROCESS;
}
} else {
nextState = ST_LEAVE;
}
} else if (state == ST_LEAVE) {
f.postprocess();
f = f.parent;
nextState = ST_ENTER;
} else {
throw GraalError.shouldNotReachHere();
}
state = nextState;
}
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class LoweringPhase method processBlock.
/**
* This state-machine resembles the following recursion:
*
* <pre>
* void processBlock(Block block) {
* preprocess();
* // Process always reached block first.
* Block alwaysReachedBlock = block.getPostdominator();
* if (alwaysReachedBlock != null && alwaysReachedBlock.getDominator() == block) {
* processBlock(alwaysReachedBlock);
* }
*
* // Now go for the other dominators.
* for (Block dominated : block.getDominated()) {
* if (dominated != alwaysReachedBlock) {
* assert dominated.getDominator() == block;
* processBlock(dominated);
* }
* }
* postprocess();
* }
* </pre>
*
* This is necessary, as the recursive implementation quickly exceed the stack depth on SPARC.
*
* @param rootFrame contains the starting block.
*/
public static void processBlock(final Frame<?> rootFrame) {
ProcessBlockState state = ST_PROCESS;
Frame<?> f = rootFrame;
while (f != null) {
ProcessBlockState nextState;
if (state == ST_PROCESS || state == ST_PROCESS_ALWAYS_REACHED) {
f.preprocess();
nextState = state == ST_PROCESS_ALWAYS_REACHED ? ST_ENTER : ST_ENTER_ALWAYS_REACHED;
} else if (state == ST_ENTER_ALWAYS_REACHED) {
if (f.alwaysReachedBlock != null && f.alwaysReachedBlock.getDominator() == f.block) {
f = f.enterAlwaysReached(f.alwaysReachedBlock);
nextState = ST_PROCESS;
} else {
nextState = ST_ENTER;
}
} else if (state == ST_ENTER) {
if (f.dominated != null) {
Block n = f.dominated;
f.dominated = n.getDominatedSibling();
if (n == f.alwaysReachedBlock) {
if (f.dominated != null) {
n = f.dominated;
f.dominated = n.getDominatedSibling();
} else {
n = null;
}
}
if (n == null) {
nextState = ST_LEAVE;
} else {
f = f.enter(n);
assert f.block.getDominator() == f.parent.block;
nextState = ST_PROCESS;
}
} else {
nextState = ST_LEAVE;
}
} else if (state == ST_LEAVE) {
f.postprocess();
f = f.parent;
nextState = ST_ENTER;
} else {
throw GraalError.shouldNotReachHere();
}
state = nextState;
}
}
Aggregations