Search in sources :

Example 1 with DefaultLoopPolicies

use of org.graalvm.compiler.loop.DefaultLoopPolicies in project graal by oracle.

the class EscapeAnalysisTest method testFullyUnrolledLoop.

@Test
public void testFullyUnrolledLoop() {
    prepareGraph("testFullyUnrolledLoopSnippet", false);
    new LoopFullUnrollPhase(new CanonicalizerPhase(), new DefaultLoopPolicies()).apply(graph, context);
    new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
    Assert.assertEquals(1, returnNodes.size());
    Assert.assertTrue(returnNodes.get(0).result() instanceof AllocatedObjectNode);
    CommitAllocationNode commit = ((AllocatedObjectNode) returnNodes.get(0).result()).getCommit();
    Assert.assertEquals(2, commit.getValues().size());
    Assert.assertEquals(1, commit.getVirtualObjects().size());
    Assert.assertTrue("non-cyclic data structure expected", commit.getVirtualObjects().get(0) != commit.getValues().get(0));
}
Also used : LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode) Test(org.junit.Test)

Example 2 with DefaultLoopPolicies

use of org.graalvm.compiler.loop.DefaultLoopPolicies in project graal by oracle.

the class LockEliminationTest method testUnrolledSync.

@Test
public void testUnrolledSync() {
    StructuredGraph graph = getGraph("testUnrolledSyncSnippet");
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, new PhaseContext(getProviders()));
    HighTierContext context = getDefaultHighTierContext();
    new LoopFullUnrollPhase(canonicalizer, new DefaultLoopPolicies()).apply(graph, context);
    new LockEliminationPhase().apply(graph);
    assertDeepEquals(1, graph.getNodes().filter(RawMonitorEnterNode.class).count());
    assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) LockEliminationPhase(org.graalvm.compiler.phases.common.LockEliminationPhase) Test(org.junit.Test)

Example 3 with DefaultLoopPolicies

use of org.graalvm.compiler.loop.DefaultLoopPolicies in project graal by oracle.

the class LoopFullUnrollTest method test.

@SuppressWarnings("try")
private void test(String snippet, int loopCount) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope(getClass().getSimpleName(), new DebugDumpScope(snippet))) {
        final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, debug);
        PhaseContext context = new PhaseContext(getProviders());
        new LoopFullUnrollPhase(new CanonicalizerPhase(), new DefaultLoopPolicies()).apply(graph, context);
        assertTrue(graph.getNodes().filter(LoopBeginNode.class).count() == loopCount);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 4 with DefaultLoopPolicies

use of org.graalvm.compiler.loop.DefaultLoopPolicies in project graal by oracle.

the class BoxingEliminationTest method compareGraphs.

private void compareGraphs(final String snippet, final String referenceSnippet, final boolean loopPeeling, final boolean excludeVirtual) {
    graph = parseEager(snippet, AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, context);
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    if (loopPeeling) {
        new LoopPeelingPhase(new DefaultLoopPolicies()).apply(graph, context);
    }
    new DeadCodeEliminationPhase().apply(graph);
    canonicalizer.apply(graph, context);
    new PartialEscapePhase(false, canonicalizer, graph.getOptions()).apply(graph, context);
    new DeadCodeEliminationPhase().apply(graph);
    canonicalizer.apply(graph, context);
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
    new InliningPhase(new CanonicalizerPhase()).apply(referenceGraph, context);
    new DeadCodeEliminationPhase().apply(referenceGraph);
    new CanonicalizerPhase().apply(referenceGraph, context);
    assertEquals(referenceGraph, graph, excludeVirtual, true);
}
Also used : LoopPeelingPhase(org.graalvm.compiler.loop.phases.LoopPeelingPhase) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Example 5 with DefaultLoopPolicies

use of org.graalvm.compiler.loop.DefaultLoopPolicies in project graal by oracle.

the class LoopUnswitchTest method test.

@SuppressWarnings("try")
private void test(String snippet, String referenceSnippet) {
    DebugContext debug = getDebugContext();
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    final StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
    new LoopUnswitchingPhase(new DefaultLoopPolicies()).apply(graph);
    // Framestates create comparison problems
    graph.clearAllStateAfter();
    referenceGraph.clearAllStateAfter();
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    try (DebugContext.Scope s = debug.scope("Test", new DebugDumpScope("Test:" + snippet))) {
        assertEquals(referenceGraph, graph);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) LoopUnswitchingPhase(org.graalvm.compiler.loop.phases.LoopUnswitchingPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DefaultLoopPolicies (org.graalvm.compiler.loop.DefaultLoopPolicies)6 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)5 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 LoopFullUnrollPhase (org.graalvm.compiler.loop.phases.LoopFullUnrollPhase)3 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)3 Test (org.junit.Test)3 DebugContext (org.graalvm.compiler.debug.DebugContext)2 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)2 LoopPeelingPhase (org.graalvm.compiler.loop.phases.LoopPeelingPhase)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)2 LoopUnswitchingPhase (org.graalvm.compiler.loop.phases.LoopUnswitchingPhase)1 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)1 AllocatedObjectNode (org.graalvm.compiler.nodes.virtual.AllocatedObjectNode)1 CommitAllocationNode (org.graalvm.compiler.nodes.virtual.CommitAllocationNode)1 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)1 LockEliminationPhase (org.graalvm.compiler.phases.common.LockEliminationPhase)1 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)1 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)1