Search in sources :

Example 1 with ConvertDeoptimizeToGuardPhase

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

the class CachingPEGraphDecoder method createGraph.

@SuppressWarnings("try")
private EncodedGraph createGraph(ResolvedJavaMethod method, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider) {
    StructuredGraph graphToEncode = new StructuredGraph.Builder(options, debug, allowAssumptions).useProfilingInfo(false).trackNodeSourcePosition(graphBuilderConfig.trackNodeSourcePosition()).method(method).build();
    try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) {
        IntrinsicContext initialIntrinsicContext = intrinsicBytecodeProvider != null ? new IntrinsicContext(originalMethod, method, intrinsicBytecodeProvider, INLINE_AFTER_PARSING) : null;
        GraphBuilderPhase.Instance graphBuilderPhaseInstance = createGraphBuilderPhaseInstance(initialIntrinsicContext);
        graphBuilderPhaseInstance.apply(graphToEncode);
        PhaseContext context = new PhaseContext(providers);
        new CanonicalizerPhase().apply(graphToEncode, context);
        /*
             * ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that
             * fewer frame states will be created. This significantly reduces the number of nodes in
             * the initial graph.
             */
        new ConvertDeoptimizeToGuardPhase().apply(graphToEncode, context);
        EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graphToEncode, architecture);
        graphCache.put(method, encodedGraph);
        return encodedGraph;
    } catch (Throwable ex) {
        throw debug.handle(ex);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) IntrinsicContext(org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Example 2 with ConvertDeoptimizeToGuardPhase

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

the class GuardPrioritiesTest method prepareGraph.

private StructuredGraph prepareGraph(String method) {
    StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
    HighTierContext highTierContext = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    new ConvertDeoptimizeToGuardPhase().apply(graph, highTierContext);
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
    new FloatingReadPhase().apply(graph);
    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) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Example 3 with ConvertDeoptimizeToGuardPhase

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

the class ConditionalEliminationTestBase method prepareGraph.

protected void prepareGraph(StructuredGraph graph, CanonicalizerPhase canonicalizer, PhaseContext context, boolean applyLowering) {
    if (applyLowering) {
        new ConvertDeoptimizeToGuardPhase().apply(graph, context);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        canonicalizer.apply(graph, context);
    }
    canonicalizer.apply(graph, context);
    new ConvertDeoptimizeToGuardPhase().apply(graph, context);
}
Also used : LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Example 4 with ConvertDeoptimizeToGuardPhase

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

the class IfNodeCanonicalizationTest method test.

public void test(String name, Class<? extends Node> expectedClass, int expectedCount) {
    StructuredGraph graph = parseEager(name, AllowAssumptions.YES);
    PhaseContext context = new PhaseContext(getProviders());
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    new ConvertDeoptimizeToGuardPhase().apply(graph, context);
    graph.clearAllStateAfter();
    graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA);
    canonicalizer.apply(graph, context);
    // new DominatorConditionalEliminationPhase(true).apply(graph, context);
    new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
    canonicalizer.apply(graph, context);
    canonicalizer.apply(graph, context);
    Assert.assertEquals(expectedCount, graph.getNodes().filter(expectedClass).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Example 5 with ConvertDeoptimizeToGuardPhase

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

the class PartialEvaluator method fastPartialEvaluation.

@SuppressWarnings({ "try", "unused" })
private void fastPartialEvaluation(CompilableTruffleAST compilable, TruffleInliningPlan inliningDecision, StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) {
    DebugContext debug = graph.getDebug();
    doGraphPE(compilable, graph, tierContext, inliningDecision);
    debug.dump(DebugContext.BASIC_LEVEL, graph, "After Partial Evaluation");
    graph.maybeCompress();
    // Perform deoptimize to guard conversion.
    new ConvertDeoptimizeToGuardPhase().apply(graph, tierContext);
    for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE)) {
        StructuredGraph inlineGraph = providers.getReplacements().getSubstitution(methodCallTargetNode.targetMethod(), methodCallTargetNode.invoke().bci(), graph.trackNodeSourcePosition(), methodCallTargetNode.asNode().getNodeSourcePosition());
        if (inlineGraph != null) {
            InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, true, methodCallTargetNode.targetMethod());
        }
    }
    // Perform conditional elimination.
    new ConditionalEliminationPhase(false).apply(graph, tierContext);
    canonicalizer.apply(graph, tierContext);
    // Do single partial escape and canonicalization pass.
    try (DebugContext.Scope pe = debug.scope("TrufflePartialEscape", graph)) {
        new PartialEscapePhase(TruffleCompilerOptions.getValue(TruffleIterativePartialEscape), canonicalizer, graph.getOptions()).apply(graph, tierContext);
    } catch (Throwable t) {
        debug.handle(t);
    }
    // recompute loop frequencies now that BranchProbabilities have had time to canonicalize
    ComputeLoopFrequenciesClosure.compute(graph);
    applyInstrumentationPhases(graph, tierContext);
    graph.maybeCompress();
    PerformanceInformationHandler.reportPerformanceWarnings(compilable, graph);
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)

Aggregations

ConvertDeoptimizeToGuardPhase (org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)4 DebugContext (org.graalvm.compiler.debug.DebugContext)3 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)3 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)2 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)2 InvokeTypeFlow (com.oracle.graal.pointsto.flow.InvokeTypeFlow)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 ArrayList (java.util.ArrayList)1 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)1 EncodedGraph (org.graalvm.compiler.nodes.EncodedGraph)1 IntrinsicContext (org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext)1 ConditionalEliminationPhase (org.graalvm.compiler.phases.common.ConditionalEliminationPhase)1 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)1 IterativeConditionalEliminationPhase (org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)1