Search in sources :

Example 16 with InliningPhase

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

the class FinalizableSubclassTest method parseAndProcess.

private StructuredGraph parseAndProcess(Class<?> cl, AllowAssumptions allowAssumptions) {
    Constructor<?>[] constructors = cl.getConstructors();
    Assert.assertTrue(constructors.length == 1);
    final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(constructors[0]);
    OptionValues options = getInitialOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, javaMethod), allowAssumptions).method(javaMethod).build();
    GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(getDefaultGraphBuilderPlugins());
    new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), getProviders().getConstantReflection(), getProviders().getConstantFieldProvider(), conf, OptimisticOptimizations.ALL, null).apply(graph);
    HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, context);
    return graph;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Constructor(java.lang.reflect.Constructor) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 17 with InliningPhase

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

the class InvokeExceptionTest method test.

private void test(String snippet) {
    StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
    Map<Invoke, Double> hints = new HashMap<>();
    for (Invoke invoke : graph.getInvokes()) {
        hints.put(invoke, 1000d);
    }
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, context);
    new DeadCodeEliminationPhase().apply(graph);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HashMap(java.util.HashMap) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 18 with InliningPhase

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

the class InvokeHintsTest method test.

private void test(String snippet) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    Map<Invoke, Double> hints = new HashMap<>();
    for (Invoke invoke : graph.getInvokes()) {
        hints.put(invoke, 1000d);
    }
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, context);
    new DeadCodeEliminationPhase().apply(graph);
    StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
    assertEquals(referenceGraph, graph);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HashMap(java.util.HashMap) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 19 with InliningPhase

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

the class ArraysSubstitutionsTest method testVirtualNotEqual.

@Test
public void testVirtualNotEqual() {
    StructuredGraph graph = parseEager("testVirtualNotEqualSnippet", AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 0);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) 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) Test(org.junit.Test)

Example 20 with InliningPhase

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

the class ArraysSubstitutionsTest method testVirtualEqual.

@Test
public void testVirtualEqual() {
    StructuredGraph graph = parseEager("testVirtualEqualSnippet", AllowAssumptions.NO);
    HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 1);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) 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) Test(org.junit.Test)

Aggregations

CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)27 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)27 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)26 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)24 DebugContext (org.graalvm.compiler.debug.DebugContext)9 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)9 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)8 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)7 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)7 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)5 Test (org.junit.Test)5 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)4 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)4 HashMap (java.util.HashMap)3 Node (org.graalvm.compiler.graph.Node)3 WriteBarrierAdditionPhase (org.graalvm.compiler.hotspot.phases.WriteBarrierAdditionPhase)3 Invoke (org.graalvm.compiler.nodes.Invoke)3 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)3 G1PostWriteBarrier (org.graalvm.compiler.hotspot.nodes.G1PostWriteBarrier)2 G1PreWriteBarrier (org.graalvm.compiler.hotspot.nodes.G1PreWriteBarrier)2