use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.
the class IterativeConditionalEliminationPhase method run.
@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph, PhaseContext context) {
HashSetNodeEventListener listener = new HashSetNodeEventListener().exclude(NODE_ADDED);
int count = 0;
while (true) {
try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
new ConditionalEliminationPhase(fullSchedule).apply(graph, context);
}
if (listener.getNodes().isEmpty()) {
break;
}
for (Node node : graph.getNodes()) {
if (node instanceof Simplifiable) {
listener.getNodes().add(node);
}
}
canonicalizer.applyIncremental(graph, context, listener.getNodes());
listener.getNodes().clear();
if (++count > MAX_ITERATIONS) {
throw new RetryableBailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds %d", MAX_ITERATIONS);
}
}
}
use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.
the class ReentrantBlockIterator method apply.
public static <StateT> EconomicMap<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Predicate<Block> stopAtBlock) {
Deque<Block> blockQueue = new ArrayDeque<>();
/*
* States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes.
*/
EconomicMap<FixedNode, StateT> states = EconomicMap.create(Equivalence.IDENTITY);
StateT state = initialState;
Block current = start;
StructuredGraph graph = start.getBeginNode().graph();
CompilationAlarm compilationAlarm = CompilationAlarm.current();
while (true) {
if (compilationAlarm.hasExpired()) {
int period = CompilationAlarm.Options.CompilationExpirationPeriod.getValue(graph.getOptions());
if (period > 120) {
throw new PermanentBailoutException("Compilation exceeded %d seconds during CFG traversal", period);
} else {
throw new RetryableBailoutException("Compilation exceeded %d seconds during CFG traversal", period);
}
}
Block next = null;
if (stopAtBlock != null && stopAtBlock.test(current)) {
states.put(current.getBeginNode(), state);
} else {
state = closure.processBlock(current, state);
Block[] successors = current.getSuccessors();
if (successors.length == 0) {
// nothing to do...
} else if (successors.length == 1) {
Block successor = successors[0];
if (successor.isLoopHeader()) {
if (current.isLoopEnd()) {
// nothing to do... loop ends only lead to loop begins we've already
// visited
states.put(current.getEndNode(), state);
} else {
recurseIntoLoop(closure, blockQueue, states, state, successor);
}
} else if (current.getEndNode() instanceof AbstractEndNode) {
AbstractEndNode end = (AbstractEndNode) current.getEndNode();
// add the end node and see if the merge is ready for processing
AbstractMergeNode merge = end.merge();
if (allEndsVisited(states, current, merge)) {
ArrayList<StateT> mergedStates = mergeStates(states, state, current, successor, merge);
state = closure.merge(successor, mergedStates);
next = successor;
} else {
assert !states.containsKey(end);
states.put(end, state);
}
} else {
next = successor;
}
} else {
next = processMultipleSuccessors(closure, blockQueue, states, state, successors);
}
}
// get next queued block
if (next != null) {
current = next;
} else if (blockQueue.isEmpty()) {
return states;
} else {
current = blockQueue.removeFirst();
assert current.getPredecessorCount() == 1;
assert states.containsKey(current.getBeginNode());
state = states.removeKey(current.getBeginNode());
}
}
}
use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.
the class LoopTransformations method fullUnroll.
public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) {
// assert loop.isCounted(); //TODO (gd) strengthen : counted with known trip count
LoopBeginNode loopBegin = loop.loopBegin();
StructuredGraph graph = loopBegin.graph();
int initialNodeCount = graph.getNodeCount();
while (!loopBegin.isDeleted()) {
Mark mark = graph.getMark();
peel(loop);
canonicalizer.applyIncremental(graph, context, mark);
loop.invalidateFragments();
if (graph.getNodeCount() > initialNodeCount + MaximumDesiredSize.getValue(graph.getOptions()) * 2) {
throw new RetryableBailoutException("FullUnroll : Graph seems to grow out of proportion");
}
}
}
Aggregations