Search in sources :

Example 1 with SpeculationLog

use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.

the class HotSpotGraalCompiler method createGraph.

public StructuredGraph createGraph(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
    HotSpotBackend backend = graalRuntime.getHostBackend();
    HotSpotProviders providers = backend.getProviders();
    final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
    StructuredGraph graph = method.isNative() || isOSR ? null : getIntrinsicGraph(method, providers, compilationId, options, debug);
    if (graph == null) {
        SpeculationLog speculationLog = method.getSpeculationLog();
        if (speculationLog != null) {
            speculationLog.collectFailedSpeculations();
        }
        graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.ifTrue(OptAssumptions.getValue(options))).method(method).entryBCI(entryBCI).speculationLog(speculationLog).useProfilingInfo(useProfilingInfo).compilationId(compilationId).build();
    }
    return graph;
}
Also used : SpeculationLog(jdk.vm.ci.meta.SpeculationLog) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders)

Example 2 with SpeculationLog

use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.

the class TruffleToTruffleCallExceptionHandlerTest method partialEval.

@SuppressWarnings("try")
private static StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions) {
    compilable.call(arguments);
    compilable.call(arguments);
    compilable.call(arguments);
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
        TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
        SpeculationLog speculationLog = compilable.getSpeculationLog();
        return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, INVALID_COMPILATION_ID, speculationLog, null);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SpeculationLog(jdk.vm.ci.meta.SpeculationLog) OptionValues(org.graalvm.compiler.options.OptionValues) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 3 with SpeculationLog

use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.

the class PartialEvaluationTest method partialEval.

@SuppressWarnings("try")
protected StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId) {
    // Executed AST so that all classes are loaded and initialized.
    compilable.call(arguments);
    compilable.call(arguments);
    compilable.call(arguments);
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = getDebugContext(options);
    try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
        TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
        SpeculationLog speculationLog = compilable.getSpeculationLog();
        return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, compilationId, speculationLog, null);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SpeculationLog(jdk.vm.ci.meta.SpeculationLog) OptionValues(org.graalvm.compiler.options.OptionValues) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 4 with SpeculationLog

use of jdk.vm.ci.meta.SpeculationLog 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

SpeculationLog (jdk.vm.ci.meta.SpeculationLog)4 TruffleDebugJavaMethod (org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod)3 DebugContext (org.graalvm.compiler.debug.DebugContext)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 DefaultInliningPolicy (org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy)2 TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)2 BailoutException (jdk.vm.ci.code.BailoutException)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1 CompilationPrinter (org.graalvm.compiler.core.CompilationPrinter)1 CancellationBailoutException (org.graalvm.compiler.core.common.CancellationBailoutException)1 RetryableBailoutException (org.graalvm.compiler.core.common.RetryableBailoutException)1 CompilationAlarm (org.graalvm.compiler.core.common.util.CompilationAlarm)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1