Search in sources :

Example 16 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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 17 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class UnsafeVirtualizationTest method testPartialEscapeReadElimination.

public void testPartialEscapeReadElimination(String snippet, boolean canonicalizeBefore, Object... args) {
    assert AF1Offset % 8 == 0 : "First of the two int-fields must be 8-byte aligned";
    ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    OptionValues options = graph.getOptions();
    PhaseContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    if (canonicalizeBefore) {
        canonicalizer.apply(graph, context);
    }
    Result r = executeExpected(method, null, args);
    new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
    try {
        InstalledCode code = getCode(method, graph);
        Object result = code.executeVarargs(args);
        assertEquals(r, new Result(result, null));
    } catch (Throwable e) {
        assertFalse(true, e.toString());
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OptionValues(org.graalvm.compiler.options.OptionValues) InstalledCode(jdk.vm.ci.code.InstalledCode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 18 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class StraighteningTest method test.

private void test(final String snippet) {
    // No debug scope to reduce console noise for @Test(expected = ...) tests
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 19 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class TypeSystemTest method test.

private void test(String snippet, String referenceSnippet) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    /*
         * When using FlowSensitiveReductionPhase instead of ConditionalEliminationPhase,
         * tail-duplication gets activated thus resulting in a graph with more nodes than the
         * reference graph.
         */
    new ConditionalEliminationPhase(false).apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    // a second canonicalizer is needed to process nested MaterializeNodes
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
    new ConditionalEliminationPhase(false).apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 20 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class TypeSystemTest method testHelper.

private <T extends Node> void testHelper(String snippet, Class<T> clazz) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph " + snippet);
    Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)114 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)98 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)60 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)48 DebugContext (org.graalvm.compiler.debug.DebugContext)34 Test (org.junit.Test)33 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)31 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)27 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)17 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)16 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)14 Node (org.graalvm.compiler.graph.Node)12 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)12 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)10 OptionValues (org.graalvm.compiler.options.OptionValues)10 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)10 ConditionalEliminationPhase (org.graalvm.compiler.phases.common.ConditionalEliminationPhase)9 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)9 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)8 Invoke (org.graalvm.compiler.nodes.Invoke)8