Search in sources :

Example 66 with StructuredGraph

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

the class NodePropertiesTest method testGraphCost.

@Test
public void testGraphCost() {
    StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("test1Snippet"));
    StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("test2Snippet"));
    HighTierContext htc = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(g1, htc);
    new CanonicalizerPhase().apply(g2, htc);
    GraphCostPhase gc1 = new GraphCostPhase();
    GraphCostPhase gc2 = new GraphCostPhase();
    gc1.apply(g1, htc);
    gc2.apply(g2, htc);
    g1.getDebug().log("Test Graph Cost --> 1.Graph cost:%f vs. 2.Graph cost:%f\n", gc1.finalCycles, gc2.finalCycles);
    Assert.assertTrue(gc2.finalCycles > gc1.finalCycles);
    Assert.assertTrue(gc2.finalSize == gc1.finalSize);
}
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 67 with StructuredGraph

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

the class IfCanonicalizerTest method testCombinedIf.

private void testCombinedIf(String snippet, int count) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    PhaseContext context = new PhaseContext(getProviders());
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    new FloatingReadPhase().apply(graph);
    MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
    new GuardLoweringPhase().apply(graph, midContext);
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
    new CanonicalizerPhase().apply(graph, context);
    assertDeepEquals(count, graph.getNodes().filter(IfNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 68 with StructuredGraph

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

the class ImplicitNullCheckTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("FloatingReadTest", new DebugDumpScope(snippet))) {
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES, debug);
        PhaseContext context = new PhaseContext(getProviders());
        new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        MidTierContext midTierContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midTierContext);
        Assert.assertEquals(0, graph.getNodes(DeoptimizeNode.TYPE).count());
        Assert.assertTrue(graph.getNodes().filter(ReadNode.class).first().canNullCheck());
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) DebugContext(org.graalvm.compiler.debug.DebugContext) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 69 with StructuredGraph

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

the class InfopointReasonTest method lineInfopoints.

@Test
public void lineInfopoints() {
    final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
    final StructuredGraph graph = parse(builder(method, AllowAssumptions.ifTrue(OptAssumptions.getValue(getInitialOptions()))), getDebugGraphBuilderSuite());
    int graphLineSPs = 0;
    for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) {
        if (ipn.getReason() == InfopointReason.BYTECODE_POSITION) {
            ++graphLineSPs;
        }
    }
    assertTrue(graphLineSPs > 0);
    PhaseSuite<HighTierContext> graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true));
    final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), createSuites(graph.getOptions()), createLIRSuites(graph.getOptions()), new CompilationResult(graph.compilationId()), CompilationResultBuilderFactory.Default);
    int lineSPs = 0;
    for (Infopoint sp : cr.getInfopoints()) {
        assertNotNull(sp.reason);
        if (sp.reason == InfopointReason.BYTECODE_POSITION) {
            ++lineSPs;
        }
    }
    assertTrue(lineSPs > 0);
}
Also used : FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Infopoint(jdk.vm.ci.code.site.Infopoint) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Infopoint(jdk.vm.ci.code.site.Infopoint) Test(org.junit.Test)

Example 70 with StructuredGraph

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

the class IntegerEqualsCanonicalizerTest method test.

private void test(String snippet, String referenceSnippet) {
    StructuredGraph graph = getCanonicalizedGraph(snippet);
    StructuredGraph referenceGraph = getCanonicalizedGraph(referenceSnippet);
    assertEquals(referenceGraph, graph);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph)

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