Search in sources :

Example 56 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext 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 57 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext 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 58 with HighTierContext

use of org.graalvm.compiler.phases.tiers.HighTierContext 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 59 with HighTierContext

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

the class PointerTest method assertNumWordCasts.

private void assertNumWordCasts(String snippetName, int expectedWordCasts) {
    HighTierContext context = new HighTierContext(getProviders(), null, OptimisticOptimizations.ALL);
    StructuredGraph graph = parseEager(snippetName, AllowAssumptions.YES);
    new CanonicalizerPhase().apply(graph, context);
    Assert.assertEquals(expectedWordCasts, graph.getNodes().filter(WordCastNode.class).count());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext)

Example 60 with HighTierContext

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

the class ReplacementsParseTest method testGraph.

@SuppressWarnings("try")
private void testGraph(String name) {
    StructuredGraph graph = parseEager(name, StructuredGraph.AllowAssumptions.YES);
    try (DebugContext.Scope s0 = graph.getDebug().scope(name, graph)) {
        for (OpaqueNode node : graph.getNodes().filter(OpaqueNode.class)) {
            node.replaceAndDelete(node.getValue());
        }
        HighTierContext context = getDefaultHighTierContext();
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        canonicalizer.apply(graph, context);
        new DeadCodeEliminationPhase().apply(graph);
        new GuardLoweringPhase().apply(graph, getDefaultMidTierContext());
        new FrameStateAssignmentPhase().apply(graph);
    } catch (Throwable e) {
        throw graph.getDebug().handle(e);
    }
}
Also used : FrameStateAssignmentPhase(org.graalvm.compiler.phases.common.FrameStateAssignmentPhase) 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) DebugContext(org.graalvm.compiler.debug.DebugContext) OpaqueNode(org.graalvm.compiler.nodes.debug.OpaqueNode) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

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