Search in sources :

Example 36 with HighTierContext

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

the class GraalUtil method getGraph.

public static StructuredGraph getGraph(GraalState graal, ResolvedJavaMethod javaMethod, boolean useProfilingInfo) {
    StructuredGraph graph = new StructuredGraph.Builder(graal.options, graal.debug, AllowAssumptions.YES).useProfilingInfo(useProfilingInfo).method(javaMethod).build();
    PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
    graphBuilderSuite.appendPhase(new GraphBuilderPhase(GraphBuilderConfiguration.getDefault(new Plugins(new InvocationPlugins()))));
    graphBuilderSuite.apply(graph, new HighTierContext(graal.providers, graphBuilderSuite, OptimisticOptimizations.ALL));
    return graph;
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) PhaseSuite(org.graalvm.compiler.phases.PhaseSuite) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 37 with HighTierContext

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

the class EliminateRedundantInitializationPhaseTest method test.

private void test(String name, int initNodesAfterParse, int initNodesAfterOpt) {
    StructuredGraph graph = parseEager(name, AllowAssumptions.NO);
    Assert.assertEquals(initNodesAfterParse, graph.getNodes().filter(InitializeKlassNode.class).count());
    HighTierContext highTierContext = getDefaultHighTierContext();
    new EliminateRedundantInitializationPhase().apply(graph, highTierContext);
    Assert.assertEquals(initNodesAfterOpt, graph.getNodes().filter(InitializeKlassNode.class).count());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EliminateRedundantInitializationPhase(org.graalvm.compiler.hotspot.phases.aot.EliminateRedundantInitializationPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext)

Example 38 with HighTierContext

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

the class UnsafeAutomaticSubstitutionProcessor method getStaticInitializerGraph.

private StructuredGraph getStaticInitializerGraph(ResolvedJavaMethod clinit, OptionValues options, DebugContext debug) {
    assert clinit.hasBytecodes();
    StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(clinit).build();
    HighTierContext context = new HighTierContext(GraalAccess.getOriginalProviders(), null, OptimisticOptimizations.NONE);
    builderPhase.apply(graph, context);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext)

Example 39 with HighTierContext

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

the class ScheduleState method preprocessOriginal.

@Override
protected StructuredGraph preprocessOriginal(StructuredGraph structuredGraph) {
    StructuredGraph g = super.preprocessOriginal(structuredGraph);
    GraalState graal = new GraalState();
    PhaseSuite<HighTierContext> highTier = graal.backend.getSuites().getDefaultSuites(graal.options).getHighTier();
    highTier.apply(g, new HighTierContext(graal.providers, graal.backend.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL));
    return g;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext)

Example 40 with HighTierContext

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

the class TruffleCompilerImpl method compileAST.

/**
 * Compiles a Truffle AST. If compilation succeeds, the AST will have compiled code associated
 * with it that can be executed instead of interpreting the AST.
 *
 * @param compilable representation of the AST to be compiled
 * @param inliningPlan
 * @param compilationId identifier to be used for the compilation
 * @param cancellable an object polled during the compilation process to
 *            {@linkplain CancellationBailoutException abort} early if the thread owning the
 *            cancellable requests it
 * @param listener
 */
@SuppressWarnings("try")
public void compileAST(DebugContext debug, final CompilableTruffleAST compilable, TruffleInliningPlan inliningPlan, CompilationIdentifier compilationId, Cancellable cancellable, TruffleCompilerListener listener) {
    final CompilationPrinter printer = CompilationPrinter.begin(TruffleCompilerOptions.getOptions(), compilationId, new TruffleDebugJavaMethod(compilable), INVOCATION_ENTRY_BCI);
    StructuredGraph graph = null;
    try (CompilationAlarm alarm = CompilationAlarm.trackCompilationPeriod(TruffleCompilerOptions.getOptions())) {
        PhaseSuite<HighTierContext> graphBuilderSuite = createGraphBuilderSuite();
        // Failed speculations must be collected before any compilation or
        // partial evaluation is performed.
        SpeculationLog speculationLog = compilable.getSpeculationLog();
        if (speculationLog != null) {
            speculationLog.collectFailedSpeculations();
        }
        try (DebugCloseable a = PartialEvaluationTime.start(debug);
            DebugCloseable c = PartialEvaluationMemUse.start(debug)) {
            graph = partialEvaluator.createGraph(debug, compilable, inliningPlan, AllowAssumptions.YES, compilationId, speculationLog, cancellable);
        }
        // Check if the task has been cancelled
        if (cancellable != null && cancellable.isCancelled()) {
            return;
        }
        if (listener != null) {
            listener.onTruffleTierFinished(compilable, inliningPlan, new GraphInfoImpl(graph));
        }
        CompilationResult compilationResult = compilePEGraph(graph, compilable.toString(), graphBuilderSuite, compilable, asCompilationRequest(compilationId), listener);
        if (listener != null) {
            listener.onSuccess(compilable, inliningPlan, new GraphInfoImpl(graph), new CompilationResultInfoImpl(compilationResult));
        }
        // Partial evaluation and installation are included in
        // compilation time and memory usage reported by printer
        printer.finish(compilationResult);
    } catch (Throwable t) {
        // graph is null
        if (listener != null) {
            BailoutException bailout = t instanceof BailoutException ? (BailoutException) t : null;
            boolean permanentBailout = bailout != null ? bailout.isPermanent() : false;
            listener.onFailure(compilable, t.toString(), bailout != null, permanentBailout);
        }
        throw t;
    }
}
Also used : CompilationAlarm(org.graalvm.compiler.core.common.util.CompilationAlarm) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) CancellationBailoutException(org.graalvm.compiler.core.common.CancellationBailoutException) BailoutException(jdk.vm.ci.code.BailoutException) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) SpeculationLog(jdk.vm.ci.meta.SpeculationLog) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CompilationPrinter(org.graalvm.compiler.core.CompilationPrinter) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) CompilationResult(org.graalvm.compiler.code.CompilationResult)

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