Search in sources :

Example 21 with CoreProviders

use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.

the class ConditionalEliminationTestBase method testProxies.

public void testProxies(String snippet, int expectedProxiesCreated) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    CoreProviders context = getProviders();
    CanonicalizerPhase canonicalizer1 = CanonicalizerPhase.createWithoutCFGSimplification();
    canonicalizer1.apply(graph, context);
    CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    int baseProxyCount = graph.getNodes().filter(ProxyNode.class).count();
    new ConditionalEliminationPhase(true).apply(graph, context);
    canonicalizer.apply(graph, context);
    new SchedulePhase(graph.getOptions()).apply(graph, context);
    int actualProxiesCreated = graph.getNodes().filter(ProxyNode.class).count() - baseProxyCount;
    Assert.assertEquals(expectedProxiesCreated, actualProxiesCreated);
}
Also used : ProxyNode(org.graalvm.compiler.nodes.ProxyNode) CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Example 22 with CoreProviders

use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.

the class ConditionalEliminationTestBase method testConditionalElimination.

@SuppressWarnings("try")
protected void testConditionalElimination(String snippet, String referenceSnippet, boolean applyConditionalEliminationOnReference, boolean applyLowering) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    CoreProviders context = getProviders();
    CanonicalizerPhase canonicalizer1 = createCanonicalizerPhase();
    CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
    try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest", graph)) {
        prepareGraph(graph, canonicalizer1, context, applyLowering);
        new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
        canonicalizer.apply(graph, context);
        canonicalizer.apply(graph, context);
    } catch (Throwable t) {
        debug.handle(t);
    }
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
    try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
        prepareGraph(referenceGraph, canonicalizer, context, applyLowering);
        if (applyConditionalEliminationOnReference) {
            new ConditionalEliminationPhase(true).apply(referenceGraph, context);
        }
        canonicalizer.apply(referenceGraph, context);
        canonicalizer.apply(referenceGraph, context);
    } catch (Throwable t) {
        debug.handle(t);
    }
    assertEquals(referenceGraph, graph);
}
Also used : IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 23 with CoreProviders

use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.

the class ConditionalEliminationTest15 method checkNodeCount.

private void checkNodeCount(String methodName, Class<? extends Node> nodeClass, int count) {
    StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
    CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
    CoreProviders context = getProviders();
    new LoweringPhase(this.createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    // Merge arr.length reads.
    new ReadEliminationPhase(canonicalizer).apply(graph, context);
    new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
    getDebugContext().dump(DebugContext.BASIC_LEVEL, graph, "After ConditionalEliminationPhase");
    Assert.assertEquals(count, graph.getNodes().filter(nodeClass).count());
}
Also used : IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase)

Example 24 with CoreProviders

use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.

the class ConditionalEliminationTest2 method testInstanceOfCheckCastLowered.

@Test
public void testInstanceOfCheckCastLowered() {
    StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet", AllowAssumptions.YES);
    CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
    CoreProviders context = getProviders();
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    new ConditionalEliminationPhase(true).apply(graph, context);
    canonicalizer.apply(graph, context);
    assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count());
}
Also used : CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) Test(org.junit.Test)

Example 25 with CoreProviders

use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.

the class ConditionalEliminationTest2 method checkInstanceOfCount.

private void checkInstanceOfCount(String methodName, int count) {
    StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
    CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
    CoreProviders context = getProviders();
    canonicalizer.apply(graph, context);
    new ConditionalEliminationPhase(true).apply(graph, context);
    getDebugContext().dump(DebugContext.BASIC_LEVEL, graph, "After ConditionalEliminationPhase");
    canonicalizer.apply(graph, context);
    Assert.assertEquals(count, graph.getNodes().filter(InstanceOfNode.class).count());
}
Also used : CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Aggregations

CoreProviders (org.graalvm.compiler.nodes.spi.CoreProviders)30 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)25 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)16 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)15 DebugContext (org.graalvm.compiler.debug.DebugContext)9 ConditionalEliminationPhase (org.graalvm.compiler.phases.common.ConditionalEliminationPhase)7 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)7 Test (org.junit.Test)6 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 IterativeConditionalEliminationPhase (org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase)5 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)4 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)4 Node (org.graalvm.compiler.graph.Node)3 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)3 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)3 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 FrameState (org.graalvm.compiler.nodes.FrameState)2