use of org.graalvm.compiler.graph.spi.Simplifiable 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.graph.spi.Simplifiable in project graal by oracle.
the class EffectsPhase method runAnalysis.
@SuppressWarnings("try")
public boolean runAnalysis(StructuredGraph graph, PhaseContextT context) {
boolean changed = false;
CompilationAlarm compilationAlarm = CompilationAlarm.current();
DebugContext debug = graph.getDebug();
for (int iteration = 0; iteration < maxIterations && !compilationAlarm.hasExpired(); iteration++) {
try (DebugContext.Scope s = debug.scope(debug.areScopesEnabled() ? "iteration " + iteration : null)) {
ScheduleResult schedule;
ControlFlowGraph cfg;
if (unscheduled) {
schedule = null;
cfg = ControlFlowGraph.compute(graph, true, true, false, false);
} else {
new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST).apply(graph, false);
schedule = graph.getLastSchedule();
cfg = schedule.getCFG();
}
try (DebugContext.Scope scheduleScope = debug.scope("EffectsPhaseWithSchedule", schedule)) {
Closure<?> closure = createEffectsClosure(context, schedule, cfg);
ReentrantBlockIterator.apply(closure, cfg.getStartBlock());
if (closure.needsApplyEffects()) {
// apply the effects collected during this iteration
HashSetNodeEventListener listener = new HashSetNodeEventListener();
try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
closure.applyEffects();
}
if (debug.isDumpEnabled(DebugContext.VERBOSE_LEVEL)) {
debug.dump(DebugContext.VERBOSE_LEVEL, graph, "%s iteration", getName());
}
new DeadCodeEliminationPhase(Required).apply(graph);
EconomicSet<Node> changedNodes = listener.getNodes();
for (Node node : graph.getNodes()) {
if (node instanceof Simplifiable) {
changedNodes.add(node);
}
}
postIteration(graph, context, changedNodes);
}
if (closure.hasChanged()) {
changed = true;
} else {
break;
}
} catch (Throwable t) {
throw debug.handle(t);
}
}
}
return changed;
}
Aggregations