Search in sources :

Example 11 with PartialEscapePhase

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);
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Example 12 with PartialEscapePhase

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);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) Test(org.junit.Test)

Example 13 with PartialEscapePhase

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);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) Test(org.junit.Test)

Example 14 with PartialEscapePhase

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;
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase)

Example 15 with PartialEscapePhase

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);
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)15 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)14 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)8 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)7 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)7 Test (org.junit.Test)5 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 DebugContext (org.graalvm.compiler.debug.DebugContext)2 DefaultLoopPolicies (org.graalvm.compiler.loop.DefaultLoopPolicies)2 AllocatedObjectNode (org.graalvm.compiler.nodes.virtual.AllocatedObjectNode)2 CommitAllocationNode (org.graalvm.compiler.nodes.virtual.CommitAllocationNode)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)2 InstalledCode (jdk.vm.ci.code.InstalledCode)1 Node (org.graalvm.compiler.graph.Node)1 LoopFullUnrollPhase (org.graalvm.compiler.loop.phases.LoopFullUnrollPhase)1 LoopPeelingPhase (org.graalvm.compiler.loop.phases.LoopPeelingPhase)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1