Search in sources :

Example 1 with TruffleDebugJavaMethod

use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod in project graal by oracle.

the class TruffleGraphBuilderPlugins method logPerformanceWarningLocationNotConstant.

@SuppressWarnings("try")
static void logPerformanceWarningLocationNotConstant(ValueNode location, ResolvedJavaMethod targetMethod, UnsafeAccessNode access) {
    if (!PartialEvaluator.PerformanceInformationHandler.isEnabled()) {
        return;
    }
    StructuredGraph graph = location.graph();
    DebugContext debug = access.getDebug();
    try (DebugContext.Scope s = debug.scope("TrufflePerformanceWarnings", graph)) {
        TruffleDebugJavaMethod truffleMethod = debug.contextLookup(TruffleDebugJavaMethod.class);
        String callTargetName = truffleMethod != null ? truffleMethod.getName() : "";
        Map<String, Object> properties = new LinkedHashMap<>();
        properties.put("location", location);
        properties.put("method", targetMethod.format("%h.%n"));
        PartialEvaluator.PerformanceInformationHandler.logPerformanceWarning(callTargetName, Collections.singletonList(access), "location argument not PE-constant", properties);
        debug.dump(DebugContext.VERBOSE_LEVEL, graph, "perf warn: location argument not PE-constant: %s", location);
    } catch (Throwable t) {
        debug.handle(t);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with TruffleDebugJavaMethod

use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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 TruffleDebugJavaMethod

use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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 TruffleDebugJavaMethod

use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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)

Example 5 with TruffleDebugJavaMethod

use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod in project graal by oracle.

the class GraalTestTVMCI method finishWarmup.

@SuppressWarnings("try")
@Override
public void finishWarmup(OptimizedCallTarget callTarget, String testName) {
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    TruffleCompiler compiler = truffleRuntime.getTruffleCompiler();
    TruffleInlining inliningDecision = new TruffleInlining(callTarget, new DefaultInliningPolicy());
    try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(callTarget))) {
        compiler.doCompile(debug, null, options, callTarget, inliningDecision, null, null);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) TruffleCompiler(org.graalvm.compiler.truffle.common.TruffleCompiler) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

TruffleDebugJavaMethod (org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod)6 DebugContext (org.graalvm.compiler.debug.DebugContext)5 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)3 OptionValues (org.graalvm.compiler.options.OptionValues)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 TruffleCompiler (org.graalvm.compiler.truffle.common.TruffleCompiler)2 DefaultInliningPolicy (org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy)2 TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)2 LinkedHashMap (java.util.LinkedHashMap)1 ServiceConfigurationError (java.util.ServiceConfigurationError)1 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 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)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 Scope (org.graalvm.compiler.debug.DebugContext.Scope)1 GraalError (org.graalvm.compiler.debug.GraalError)1