Search in sources :

Example 6 with HighTierContext

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

the class NestedLoop_EA method createSuites.

@Override
protected Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);
    ListIterator<BasePhase<? super HighTierContext>> position = suites.getHighTier().findPhase(PartialEscapePhase.class);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    // incremental canonicalizer of PEA is missing some important canonicalization (TODO?)
    position.add(canonicalizer);
    position.add(new PartialEscapePhase(true, canonicalizer, options));
    return suites;
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) BasePhase(org.graalvm.compiler.phases.BasePhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 7 with HighTierContext

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

the class TrufflePEATest method processMethod.

protected StructuredGraph processMethod(final String snippet) {
    StructuredGraph graph = parseEager(snippet, StructuredGraph.AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new PartialEscapePhase(true, true, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
    return graph;
}
Also used : 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)

Example 8 with HighTierContext

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

the class InliningTest method getGraph.

@SuppressWarnings("try")
private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("InliningTest", new DebugDumpScope(snippet, true))) {
        ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
        Builder builder = builder(method, AllowAssumptions.YES, debug);
        StructuredGraph graph = eagerInfopointMode ? parse(builder, getDebugGraphBuilderSuite()) : parse(builder, getEagerGraphBuilderSuite());
        try (DebugContext.Scope s2 = debug.scope("Inlining", graph)) {
            PhaseSuite<HighTierContext> graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true)) : getDefaultGraphBuilderSuite();
            HighTierContext context = new HighTierContext(getProviders(), graphBuilderSuite, OptimisticOptimizations.ALL);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new DeadCodeEliminationPhase().apply(graph);
            return graph;
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) Builder(org.graalvm.compiler.nodes.StructuredGraph.Builder) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 9 with HighTierContext

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

the class NestedLoopEffectsPhaseComplexityTest method prepareGraph.

private StructuredGraph prepareGraph(String snippet, int inliningCount) {
    ResolvedJavaMethod callerMethod = getResolvedJavaMethod(snippet);
    StructuredGraph callerGraph = parseEager(callerMethod, AllowAssumptions.YES);
    PhaseSuite<HighTierContext> graphBuilderSuite = getDefaultGraphBuilderSuite();
    HighTierContext context = new HighTierContext(getProviders(), graphBuilderSuite, OptimisticOptimizations.ALL);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    Invoke next = callerGraph.getNodes(MethodCallTargetNode.TYPE).first().invoke();
    StructuredGraph calleeGraph = parseBytecodes(next.callTarget().targetMethod(), context, canonicalizer);
    ResolvedJavaMethod calleeMethod = next.callTarget().targetMethod();
    for (int i = 0; i < inliningCount; i++) {
        next = callerGraph.getNodes(MethodCallTargetNode.TYPE).first().invoke();
        EconomicSet<Node> canonicalizeNodes = InliningUtil.inlineForCanonicalization(next, calleeGraph, false, calleeMethod);
        canonicalizer.applyIncremental(callerGraph, context, canonicalizeNodes);
        callerGraph.getDebug().dump(DebugContext.DETAILED_LEVEL, callerGraph, "After inlining %s into %s iteration %d", calleeMethod, callerMethod, i);
    }
    return callerGraph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Node(org.graalvm.compiler.graph.Node) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 10 with HighTierContext

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

the class EarlyReadEliminationTest method processMethod.

protected StructuredGraph processMethod(String snippet, boolean doLowering) {
    StructuredGraph graph = parseEager(getResolvedJavaMethod(snippet), AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    if (doLowering) {
        new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    }
    new EarlyReadEliminationPhase(new CanonicalizerPhase()).apply(graph, context);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) EarlyReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)

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