use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase 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);
}
use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.
the class ArraysSubstitutionsTest method testVirtualNotEqual.
@Test
public void testVirtualNotEqual() {
StructuredGraph graph = parseEager("testVirtualNotEqualSnippet", AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 0);
}
use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.
the class ArraysSubstitutionsTest method testVirtualEqual.
@Test
public void testVirtualEqual() {
StructuredGraph graph = parseEager("testVirtualEqualSnippet", AllowAssumptions.NO);
HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 1);
}
use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.
the class PEAReadEliminationTest method processMethod.
protected StructuredGraph processMethod(final String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new PartialEscapePhase(false, true, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
return graph;
}
use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.
the class EATestBase method prepareGraph.
@SuppressWarnings("try")
protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) {
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope(getClass(), method, getCodeCache())) {
graph = parseEager(method, AllowAssumptions.YES, debug);
context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
canonicalizeGraph();
new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
postEACanonicalizeGraph();
returnNodes = graph.getNodes(ReturnNode.TYPE).snapshot();
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations