Search in sources :

Example 71 with StructuredGraph

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

the class NodePropertiesTest method testDifferentLoopsInnerOuter.

@Test
public void testDifferentLoopsInnerOuter() {
    HighTierContext htc = getDefaultHighTierContext();
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("testLoop04"));
    StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("testLoop05"));
    prepareGraphForLoopFrequencies(g1, htc);
    prepareGraphForLoopFrequencies(g2, htc);
    assertFrequency(g1, ITERATIONS_LOOP_1 * ITERATIONS_LOOP_2);
    GraphCostPhase gc1 = new GraphCostPhase();
    GraphCostPhase gc2 = new GraphCostPhase();
    gc1.apply(g1, htc);
    gc2.apply(g2, htc);
    g1.getDebug().log("Test testDifferentLoopsInnerOuter --> 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.finalSize > gc1.finalSize);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Test(org.junit.Test)

Example 72 with StructuredGraph

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

the class PhiCreationTests method test3.

@Test
public void test3() {
    StructuredGraph graph = parseEager("test3Snippet", AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) DebugContext(org.graalvm.compiler.debug.DebugContext) Test(org.junit.Test)

Example 73 with StructuredGraph

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

the class PhiCreationTests method test2.

@Test
public void test2() {
    StructuredGraph graph = parseEager("test2Snippet", AllowAssumptions.YES);
    Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) Test(org.junit.Test)

Example 74 with StructuredGraph

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

the class PushThroughIfTest method test.

private void test(String snippet, String reference) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    for (FrameState fs : graph.getNodes(FrameState.TYPE).snapshot()) {
        fs.replaceAtUsages(null);
        GraphUtil.killWithUnusedFloatingInputs(fs);
    }
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(reference, AllowAssumptions.YES);
    for (FrameState fs : referenceGraph.getNodes(FrameState.TYPE).snapshot()) {
        fs.replaceAtUsages(null);
        GraphUtil.killWithUnusedFloatingInputs(fs);
    }
    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) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FrameState(org.graalvm.compiler.nodes.FrameState)

Example 75 with StructuredGraph

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

the class ReadAfterCheckCastTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("ReadAfterCheckCastTest", new DebugDumpScope(snippet))) {
        // check shape of graph, with lots of assumptions. will probably fail if graph
        // structure changes significantly
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
        PhaseContext context = new PhaseContext(getProviders());
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        canonicalizer.apply(graph, context);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
        for (FloatingReadNode node : graph.getNodes(ParameterNode.TYPE).first().usages().filter(FloatingReadNode.class)) {
            // Checking that the parameter a is not directly used for the access to field
            // x10 (because x10 must be guarded by the checkcast).
            Assert.assertTrue(node.getLocationIdentity().isImmutable());
        }
    } 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) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)360 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)97 Test (org.junit.Test)96 DebugContext (org.graalvm.compiler.debug.DebugContext)88 ValueNode (org.graalvm.compiler.nodes.ValueNode)70 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)62 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)62 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)57 Node (org.graalvm.compiler.graph.Node)39 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)37 OptionValues (org.graalvm.compiler.options.OptionValues)34 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)28 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)26 FixedNode (org.graalvm.compiler.nodes.FixedNode)26 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)25 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)24 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)24 LogicNode (org.graalvm.compiler.nodes.LogicNode)21 CompilationResult (org.graalvm.compiler.code.CompilationResult)19 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)19