use of org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class CachingPEGraphDecoder method createGraph.
@SuppressWarnings("try")
private EncodedGraph createGraph(ResolvedJavaMethod method, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider) {
StructuredGraph graphToEncode = new StructuredGraph.Builder(options, debug, allowAssumptions).useProfilingInfo(false).trackNodeSourcePosition(graphBuilderConfig.trackNodeSourcePosition()).method(method).build();
try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) {
IntrinsicContext initialIntrinsicContext = intrinsicBytecodeProvider != null ? new IntrinsicContext(originalMethod, method, intrinsicBytecodeProvider, INLINE_AFTER_PARSING) : null;
GraphBuilderPhase.Instance graphBuilderPhaseInstance = createGraphBuilderPhaseInstance(initialIntrinsicContext);
graphBuilderPhaseInstance.apply(graphToEncode);
PhaseContext context = new PhaseContext(providers);
new CanonicalizerPhase().apply(graphToEncode, context);
/*
* ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that
* fewer frame states will be created. This significantly reduces the number of nodes in
* the initial graph.
*/
new ConvertDeoptimizeToGuardPhase().apply(graphToEncode, context);
EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graphToEncode, architecture);
graphCache.put(method, encodedGraph);
return encodedGraph;
} catch (Throwable ex) {
throw debug.handle(ex);
}
}
use of org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class GuardPrioritiesTest method prepareGraph.
private StructuredGraph prepareGraph(String method) {
StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
HighTierContext highTierContext = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new ConvertDeoptimizeToGuardPhase().apply(graph, highTierContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
new FloatingReadPhase().apply(graph);
return graph;
}
use of org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class ConditionalEliminationTestBase method prepareGraph.
protected void prepareGraph(StructuredGraph graph, CanonicalizerPhase canonicalizer, PhaseContext context, boolean applyLowering) {
if (applyLowering) {
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
}
canonicalizer.apply(graph, context);
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
}
use of org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class IfNodeCanonicalizationTest method test.
public void test(String name, Class<? extends Node> expectedClass, int expectedCount) {
StructuredGraph graph = parseEager(name, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
graph.clearAllStateAfter();
graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA);
canonicalizer.apply(graph, context);
// new DominatorConditionalEliminationPhase(true).apply(graph, context);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
Assert.assertEquals(expectedCount, graph.getNodes().filter(expectedClass).count());
}
use of org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class PartialEvaluator method fastPartialEvaluation.
@SuppressWarnings({ "try", "unused" })
private void fastPartialEvaluation(CompilableTruffleAST compilable, TruffleInliningPlan inliningDecision, StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) {
DebugContext debug = graph.getDebug();
doGraphPE(compilable, graph, tierContext, inliningDecision);
debug.dump(DebugContext.BASIC_LEVEL, graph, "After Partial Evaluation");
graph.maybeCompress();
// Perform deoptimize to guard conversion.
new ConvertDeoptimizeToGuardPhase().apply(graph, tierContext);
for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE)) {
StructuredGraph inlineGraph = providers.getReplacements().getSubstitution(methodCallTargetNode.targetMethod(), methodCallTargetNode.invoke().bci(), graph.trackNodeSourcePosition(), methodCallTargetNode.asNode().getNodeSourcePosition());
if (inlineGraph != null) {
InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, true, methodCallTargetNode.targetMethod());
}
}
// Perform conditional elimination.
new ConditionalEliminationPhase(false).apply(graph, tierContext);
canonicalizer.apply(graph, tierContext);
// Do single partial escape and canonicalization pass.
try (DebugContext.Scope pe = debug.scope("TrufflePartialEscape", graph)) {
new PartialEscapePhase(TruffleCompilerOptions.getValue(TruffleIterativePartialEscape), canonicalizer, graph.getOptions()).apply(graph, tierContext);
} catch (Throwable t) {
debug.handle(t);
}
// recompute loop frequencies now that BranchProbabilities have had time to canonicalize
ComputeLoopFrequenciesClosure.compute(graph);
applyInstrumentationPhases(graph, tierContext);
graph.maybeCompress();
PerformanceInformationHandler.reportPerformanceWarnings(compilable, graph);
}
Aggregations