Search in sources :

Example 1 with ConvertDeoptimizeToGuardPhase

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

the class ConditionalEliminationTestBase method prepareGraph.

protected void prepareGraph(StructuredGraph graph, CanonicalizerPhase canonicalizer, CoreProviders 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.loop.phases.ConvertDeoptimizeToGuardPhase)

Example 2 with ConvertDeoptimizeToGuardPhase

use of org.graalvm.compiler.loop.phases.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 = createCanonicalizerPhase();
    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.loop.phases.ConvertDeoptimizeToGuardPhase)

Example 3 with ConvertDeoptimizeToGuardPhase

use of org.graalvm.compiler.loop.phases.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);
    CoreProviders context = getProviders();
    CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
    new ConvertDeoptimizeToGuardPhase().apply(graph, context);
    graph.clearAllStateAfterForTestingOnly();
    graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA);
    canonicalizer.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 : IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase)

Example 4 with ConvertDeoptimizeToGuardPhase

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

the class CachingPEGraphDecoder method createGraph.

@SuppressWarnings("try")
private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider, boolean isSubstitution) {
    StructuredGraph graphToEncode;
    if (isSubstitution && IS_IN_NATIVE_IMAGE) {
        throw GraalError.shouldNotReachHere("dead path");
    } else {
        graphToEncode = buildGraph(method, intrinsicBytecodeProvider, isSubstitution);
    }
    /*
         * 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.
         */
    try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) {
        new ConvertDeoptimizeToGuardPhase().apply(graphToEncode, providers);
    } catch (Throwable t) {
        throw debug.handle(t);
    }
    EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graphToEncode, architecture);
    graphCache.put(method, encodedGraph);
    return encodedGraph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) DebugContext(org.graalvm.compiler.debug.DebugContext) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase)

Example 5 with ConvertDeoptimizeToGuardPhase

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

the class GraphPrepareMetaAccessExtensionProvider method beforeCompilation.

@Override
@SuppressWarnings("try")
public void beforeCompilation(BeforeCompilationAccess c) {
    CompilationAccessImpl config = (CompilationAccessImpl) c;
    if (Options.PrintRuntimeCompileMethods.getValue()) {
        printCallTree();
    }
    if (Options.PrintStaticTruffleBoundaries.getValue()) {
        printStaticTruffleBoundaries();
    }
    int maxMethods = 0;
    for (String value : Options.MaxRuntimeCompileMethods.getValue().values()) {
        String numberStr = null;
        try {
            /* Strip optional comment string from MaxRuntimeCompileMethods value */
            numberStr = value.split("#")[0];
            maxMethods += Long.parseLong(numberStr);
        } catch (NumberFormatException ex) {
            throw UserError.abort("Invalid value for option 'MaxRuntimeCompileMethods': '%s' is not a valid number", numberStr);
        }
    }
    if (Options.EnforceMaxRuntimeCompileMethods.getValue() && maxMethods != 0 && methods.size() > maxMethods) {
        printDeepestLevelPath();
        throw VMError.shouldNotReachHere("Number of methods for runtime compilation exceeds the allowed limit: " + methods.size() + " > " + maxMethods);
    }
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    runtimeConfigBuilder.updateLazyState(hMetaAccess);
    /*
         * Start fresh with a new GraphEncoder, since we are going to optimize all graphs now that
         * the static analysis results are available.
         */
    graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
    StrengthenStampsPhase strengthenStamps = new RuntimeStrengthenStampsPhase(config.getUniverse(), objectReplacer);
    CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
    IterativeConditionalEliminationPhase conditionalElimination = new IterativeConditionalEliminationPhase(canonicalizer, true);
    ConvertDeoptimizeToGuardPhase convertDeoptimizeToGuard = new ConvertDeoptimizeToGuardPhase();
    for (CallTreeNode node : methods.values()) {
        StructuredGraph graph = node.graph;
        if (graph != null) {
            DebugContext debug = graph.getDebug();
            try (DebugContext.Scope scope = debug.scope("RuntimeOptimize", graph)) {
                removeUnreachableInvokes(node);
                strengthenStamps.apply(graph);
                canonicalizer.apply(graph, hostedProviders);
                conditionalElimination.apply(graph, hostedProviders);
                /*
                     * ConvertDeoptimizeToGuardPhase was already executed after parsing, but
                     * optimizations applied in between can provide new potential.
                     */
                convertDeoptimizeToGuard.apply(graph, hostedProviders);
                graphEncoder.prepare(graph);
            } catch (Throwable ex) {
                debug.handle(ex);
            }
        }
    }
    graphEncoder.finishPrepare();
    for (CallTreeNode node : methods.values()) {
        if (node.graph != null) {
            registerDeoptEntries(node);
            long startOffset = graphEncoder.encode(node.graph);
            objectReplacer.createMethod(node.implementationMethod).setEncodedGraphStartOffset(startOffset);
            /* We do not need the graph anymore, let the GC do it's work. */
            node.graph = null;
        }
    }
    ProgressReporter.singleton().setGraphEncodingByteLength(graphEncoder.getEncoding().length);
    GraalSupport.setGraphEncoding(config, graphEncoder.getEncoding(), graphEncoder.getObjects(), graphEncoder.getNodeClasses());
    objectReplacer.updateDataDuringAnalysis();
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) GraphEncoder(org.graalvm.compiler.nodes.GraphEncoder) DebugContext(org.graalvm.compiler.debug.DebugContext) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase) IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) StrengthenStampsPhase(com.oracle.svm.hosted.phases.StrengthenStampsPhase)

Aggregations

ConvertDeoptimizeToGuardPhase (org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 DebugContext (org.graalvm.compiler.debug.DebugContext)3 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)3 IterativeConditionalEliminationPhase (org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase)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 PointsToAnalysisMethod (com.oracle.graal.pointsto.meta.PointsToAnalysisMethod)1 CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)1 HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)1 StrengthenStampsPhase (com.oracle.svm.hosted.phases.StrengthenStampsPhase)1 ArrayList (java.util.ArrayList)1 EncodedGraph (org.graalvm.compiler.nodes.EncodedGraph)1 GraphEncoder (org.graalvm.compiler.nodes.GraphEncoder)1 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)1 CoreProviders (org.graalvm.compiler.nodes.spi.CoreProviders)1 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1 DeoptimizeOnExceptionPhase (org.graalvm.compiler.truffle.compiler.phases.DeoptimizeOnExceptionPhase)1