Search in sources :

Example 1 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class NestedLoop_EA method createSuites.

@Override
protected Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);
    ListIterator<BasePhase<? super HighTierContext>> position = suites.getHighTier().findPhase(PartialEscapePhase.class);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    // incremental canonicalizer of PEA is missing some important canonicalization (TODO?)
    position.add(canonicalizer);
    position.add(new PartialEscapePhase(true, canonicalizer, options));
    return suites;
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) BasePhase(org.graalvm.compiler.phases.BasePhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 2 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class TrufflePEATest method processMethod.

protected StructuredGraph processMethod(final String snippet) {
    StructuredGraph graph = parseEager(snippet, StructuredGraph.AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new PartialEscapePhase(true, 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 3 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class NestedLoopEffectsPhaseComplexityTest method testAndTime.

private void testAndTime(String snippet) {
    for (int i = InliningCountLowerBound; i < InliningCountUpperBound; i++) {
        StructuredGraph g1 = prepareGraph(snippet, i);
        StructuredGraph g2 = (StructuredGraph) g1.copy(g1.getDebug());
        ResolvedJavaMethod method = g1.method();
        long elapsedRE = runAndTimePhase(g1, new EarlyReadEliminationPhase(new CanonicalizerPhase()));
        long elapsedPEA = runAndTimePhase(g2, new PartialEscapePhase(true, new CanonicalizerPhase(), g1.getOptions()));
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early partial escape analysis on a graph with %d nested loops compiling method %s\n", elapsedPEA, i, method);
        }
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early read elimination on a graph with %d nested loops compiling method %s\n", elapsedRE, i, method);
        }
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) EarlyReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)

Example 4 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class EscapeAnalysisTest method testRemovalSpecialCase.

/**
 * Test the case where allocations before and during a loop that have no usages other than their
 * phi need to be recognized as an important change. This needs a loop so that the allocation is
 * not trivially removed by dead code elimination.
 */
@Test
public void testRemovalSpecialCase() {
    prepareGraph("testRemovalSpecialCaseSnippet", false);
    Assert.assertEquals(2, graph.getNodes().filter(CommitAllocationNode.class).count());
    // create the situation by removing the if
    graph.replaceFixedWithFloating(graph.getNodes().filter(LoadFieldNode.class).first(), graph.unique(ConstantNode.forInt(0)));
    new CanonicalizerPhase().apply(graph, context);
    // verify that an additional run removes all allocations
    new PartialEscapePhase(false, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
    Assert.assertEquals(0, graph.getNodes().filter(CommitAllocationNode.class).count());
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) Test(org.junit.Test)

Example 5 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class EscapeAnalysisTest method testChangeHandling.

/**
 * Tests that a graph with allocations that does not make progress during PEA will not be
 * changed.
 */
@Test
public void testChangeHandling() {
    prepareGraph("testChangeHandlingSnippet", false);
    Assert.assertEquals(2, graph.getNodes().filter(CommitAllocationNode.class).count());
    Assert.assertEquals(1, graph.getNodes().filter(BoxNode.class).count());
    List<Node> nodes = graph.getNodes().snapshot();
    // verify that an additional run doesn't add or remove nodes
    new PartialEscapePhase(false, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
    Assert.assertEquals(nodes.size(), graph.getNodeCount());
    for (Node node : nodes) {
        Assert.assertTrue(node.isAlive());
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) ValueAnchorNode(org.graalvm.compiler.nodes.extended.ValueAnchorNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode) Node(org.graalvm.compiler.graph.Node) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) Test(org.junit.Test)

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