Search in sources :

Example 1 with Activation

use of org.graalvm.compiler.debug.DebugContext.Activation in project graal by oracle.

the class HotSpotGraalCompiler method compileMethod.

@SuppressWarnings("try")
CompilationRequestResult compileMethod(CompilationRequest request, boolean installAsDefault) {
    if (graalRuntime.isShutdown()) {
        return HotSpotCompilationRequestResult.failure(String.format("Shutdown entered"), false);
    }
    ResolvedJavaMethod method = request.getMethod();
    OptionValues options = graalRuntime.getOptions(method);
    if (graalRuntime.isBootstrapping()) {
        if (DebugOptions.BootstrapInitializeOnly.getValue(options)) {
            return HotSpotCompilationRequestResult.failure(String.format("Skip compilation because %s is enabled", DebugOptions.BootstrapInitializeOnly.getName()), true);
        }
        if (bootstrapWatchDog != null) {
            if (bootstrapWatchDog.hitCriticalCompilationRateOrTimeout()) {
                // Drain the compilation queue to expedite completion of the bootstrap
                return HotSpotCompilationRequestResult.failure("hit critical bootstrap compilation rate or timeout", true);
            }
        }
    }
    HotSpotCompilationRequest hsRequest = (HotSpotCompilationRequest) request;
    try (CompilationWatchDog w1 = CompilationWatchDog.watch(method, hsRequest.getId(), options);
        BootstrapWatchDog.Watch w2 = bootstrapWatchDog == null ? null : bootstrapWatchDog.watch(request);
        CompilationAlarm alarm = CompilationAlarm.trackCompilationPeriod(options)) {
        if (compilationCounters != null) {
            compilationCounters.countCompilation(method);
        }
        CompilationTask task = new CompilationTask(jvmciRuntime, this, hsRequest, true, installAsDefault, options);
        CompilationRequestResult r = null;
        try (DebugContext debug = graalRuntime.openDebugContext(options, task.getCompilationIdentifier(), method, getDebugHandlersFactories());
            Activation a = debug.activate()) {
            r = task.runCompilation(debug);
        }
        assert r != null;
        return r;
    }
}
Also used : CompilationRequestResult(jdk.vm.ci.code.CompilationRequestResult) HotSpotCompilationRequestResult(jdk.vm.ci.hotspot.HotSpotCompilationRequestResult) OptionValues(org.graalvm.compiler.options.OptionValues) CompilationAlarm(org.graalvm.compiler.core.common.util.CompilationAlarm) Activation(org.graalvm.compiler.debug.DebugContext.Activation) DebugContext(org.graalvm.compiler.debug.DebugContext) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with Activation

use of org.graalvm.compiler.debug.DebugContext.Activation in project graal by oracle.

the class HotSpotTruffleCompilerImpl method installTruffleCallBoundaryMethods.

/**
 * @see #compileTruffleCallBoundaryMethod
 */
@Override
@SuppressWarnings("try")
public void installTruffleCallBoundaryMethods() {
    HotSpotTruffleCompilerRuntime runtime = (HotSpotTruffleCompilerRuntime) TruffleCompilerRuntime.getRuntime();
    for (ResolvedJavaMethod method : runtime.getTruffleCallBoundaryMethods()) {
        HotSpotCompilationIdentifier compilationId = (HotSpotCompilationIdentifier) backend.getCompilationIdentifier(method);
        OptionValues options = getOptions();
        try (DebugContext debug = DebugStubsAndSnippets.getValue(options) ? hotspotGraalRuntime.openDebugContext(options, compilationId, method, getDebugHandlerFactories()) : DebugContext.DISABLED;
            Activation a = debug.activate();
            DebugContext.Scope d = debug.scope("InstallingTruffleStub")) {
            CompilationResult compResult = compileTruffleCallBoundaryMethod(method, compilationId, debug);
            CodeCacheProvider codeCache = providers.getCodeCache();
            try (DebugContext.Scope s = debug.scope("CodeInstall", codeCache, method, compResult)) {
                CompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, method, compilationId.getRequest(), compResult);
                codeCache.setDefaultCode(method, compiledCode);
            } catch (Throwable e) {
                throw debug.handle(e);
            }
        }
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotCompilationIdentifier(org.graalvm.compiler.hotspot.HotSpotCompilationIdentifier) Activation(org.graalvm.compiler.debug.DebugContext.Activation) CompiledCode(jdk.vm.ci.code.CompiledCode) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider) HotSpotTruffleCompilerRuntime(org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 Activation (org.graalvm.compiler.debug.DebugContext.Activation)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 CodeCacheProvider (jdk.vm.ci.code.CodeCacheProvider)1 CompilationRequestResult (jdk.vm.ci.code.CompilationRequestResult)1 CompiledCode (jdk.vm.ci.code.CompiledCode)1 HotSpotCodeCacheProvider (jdk.vm.ci.hotspot.HotSpotCodeCacheProvider)1 HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)1 HotSpotCompilationRequestResult (jdk.vm.ci.hotspot.HotSpotCompilationRequestResult)1 HotSpotResolvedJavaMethod (jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1 CompilationAlarm (org.graalvm.compiler.core.common.util.CompilationAlarm)1 HotSpotCompilationIdentifier (org.graalvm.compiler.hotspot.HotSpotCompilationIdentifier)1 HotSpotTruffleCompilerRuntime (org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime)1