Search in sources :

Example 6 with DebugContext

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

the class GreedyInliningPolicy method continueInlining.

@Override
public boolean continueInlining(StructuredGraph currentGraph) {
    if (InliningUtil.getNodeCount(currentGraph) >= MaximumDesiredSize.getValue(currentGraph.getOptions())) {
        DebugContext debug = currentGraph.getDebug();
        InliningUtil.logInliningDecision(debug, "inlining is cut off by MaximumDesiredSize");
        inliningStoppedByMaxDesiredSizeCounter.increment(debug);
        return false;
    }
    return true;
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 7 with DebugContext

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

the class GuardLoweringPhase method processBlock.

private static void processBlock(Block block, ScheduleResult schedule) {
    DebugContext debug = block.getBeginNode().getDebug();
    new LowerGuards(block, debug.isDumpEnabledForMethod() || debug.isLogEnabledForMethod()).processNodes(block, schedule);
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 8 with DebugContext

use of org.graalvm.compiler.debug.DebugContext 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 9 with DebugContext

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

the class HotSpotGraalCompiler method getIntrinsicGraph.

/**
 * Gets a graph produced from the intrinsic for a given method that can be compiled and
 * installed for the method.
 *
 * @param method
 * @param compilationId
 * @param options
 * @param debug
 * @return an intrinsic graph that can be compiled and installed for {@code method} or null
 */
@SuppressWarnings("try")
public StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, HotSpotProviders providers, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
    Replacements replacements = providers.getReplacements();
    Bytecode subst = replacements.getSubstitutionBytecode(method);
    if (subst != null) {
        ResolvedJavaMethod substMethod = subst.getMethod();
        assert !substMethod.equals(method);
        StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(substMethod).compilationId(compilationId).build();
        try (DebugContext.Scope scope = debug.scope("GetIntrinsicGraph", graph)) {
            Plugins plugins = new Plugins(providers.getGraphBuilderPlugins());
            GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
            IntrinsicContext initialReplacementContext = new IntrinsicContext(method, substMethod, subst.getOrigin(), ROOT_COMPILATION);
            new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialReplacementContext).apply(graph);
            assert !graph.isFrozen();
            return graph;
        } catch (Throwable e) {
            debug.handle(e);
        }
    }
    return null;
}
Also used : Replacements(org.graalvm.compiler.nodes.spi.Replacements) IntrinsicContext(org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) DebugContext(org.graalvm.compiler.debug.DebugContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Bytecode(org.graalvm.compiler.bytecode.Bytecode) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 10 with DebugContext

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

the class HotSpotGraalVMEventListener method notifyInstall.

@Override
public void notifyInstall(HotSpotCodeCacheProvider codeCache, InstalledCode installedCode, CompiledCode compiledCode) {
    DebugContext debug = DebugContext.forCurrentThread();
    if (debug.isDumpEnabled(DebugContext.BASIC_LEVEL)) {
        CompilationResult compResult = debug.contextLookup(CompilationResult.class);
        assert compResult != null : "can't dump installed code properly without CompilationResult";
        debug.dump(DebugContext.BASIC_LEVEL, installedCode, "After code installation");
    }
    if (debug.isLogEnabled()) {
        debug.log("%s", codeCache.disassemble(installedCode));
    }
    for (HotSpotCodeCacheListener listener : listeners) {
        listener.notifyInstall(codeCache, installedCode, compiledCode);
    }
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)234 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)87 OptionValues (org.graalvm.compiler.options.OptionValues)50 Indent (org.graalvm.compiler.debug.Indent)37 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)29 Test (org.junit.Test)27 Node (org.graalvm.compiler.graph.Node)24 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)24 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)22 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)20 Scope (org.graalvm.compiler.debug.DebugContext.Scope)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)18 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)14 CompilationResult (org.graalvm.compiler.code.CompilationResult)13 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)13 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)12 LIR (org.graalvm.compiler.lir.LIR)11