Search in sources :

Example 46 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.

the class MemoryScheduleTest method getFinalSchedule.

@SuppressWarnings("try")
private ScheduleResult getFinalSchedule(final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
    OptionValues options = new OptionValues(getInitialOptions(), OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false);
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, options);
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope d = debug.scope("FloatingReadTest", graph)) {
        HighTierContext context = getDefaultHighTierContext();
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        canonicalizer.apply(graph, context);
        if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
            new InliningPhase(canonicalizer).apply(graph, context);
        }
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
            graph.clearAllStateAfter();
        }
        debug.dump(DebugContext.BASIC_LEVEL, graph, "after removal of framestates");
        new FloatingReadPhase().apply(graph);
        new RemoveValueProxyPhase().apply(graph);
        MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
        SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
        schedule.apply(graph);
        assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
        return graph.getLastSchedule();
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) OptionValues(org.graalvm.compiler.options.OptionValues) RemoveValueProxyPhase(org.graalvm.compiler.phases.common.RemoveValueProxyPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) 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) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase)

Example 47 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.

the class NodePropertiesTest method testFieldStore.

@Test
public void testFieldStore() {
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("fieldStore"));
    HighTierContext htc = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(g1, htc);
    GraphCostPhase gc1 = new GraphCostPhase();
    gc1.apply(g1, htc);
    Assert.assertEquals(15, gc1.finalCycles, 25);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Test(org.junit.Test)

Example 48 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.

the class NodePropertiesTest method testFieldLoad.

@Test
public void testFieldLoad() {
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("fieldLoad"));
    HighTierContext htc = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(g1, htc);
    GraphCostPhase gc1 = new GraphCostPhase();
    gc1.apply(g1, htc);
    Assert.assertEquals(15, gc1.finalCycles, 25);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Test(org.junit.Test)

Example 49 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.

the class NodePropertiesTest method testArrayStore.

@Test
public void testArrayStore() {
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("arrayStoreTest"));
    HighTierContext htc = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(g1, htc);
    GraphCostPhase gc1 = new GraphCostPhase();
    gc1.apply(g1, htc);
    Assert.assertEquals(15, gc1.finalCycles, 25);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Test(org.junit.Test)

Example 50 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.

the class NodePropertiesTest method testDifferentLoopFaster.

@Test
public void testDifferentLoopFaster() {
    HighTierContext htc = getDefaultHighTierContext();
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("testLoop01"));
    StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("testLoop03"));
    prepareGraphForLoopFrequencies(g1, htc);
    prepareGraphForLoopFrequencies(g2, htc);
    assertFrequency(g1, ITERATIONS_LOOP_1);
    assertFrequency(g2, ITERATIONS_LOOP_1);
    GraphCostPhase gc1 = new GraphCostPhase();
    GraphCostPhase gc2 = new GraphCostPhase();
    gc1.apply(g1, htc);
    gc2.apply(g2, htc);
    g1.getDebug().log("Test testDifferentLoopFaster --> 1.Graph cycles:%f size:%f vs. 2.Graph cycles:%f size:%f\n", gc1.finalCycles, gc1.finalSize, gc2.finalCycles, gc2.finalSize);
    Assert.assertTrue(gc2.finalCycles > gc1.finalCycles);
    Assert.assertTrue(gc2.finalSize == gc1.finalSize);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Test(org.junit.Test)

Aggregations

HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)71 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)60 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)46 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)27 DebugContext (org.graalvm.compiler.debug.DebugContext)18 Test (org.junit.Test)18 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)15 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)13 OptionValues (org.graalvm.compiler.options.OptionValues)13 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)10 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)8 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)8 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)8 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)7 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)7 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)6 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)6 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)6