Search in sources :

Example 66 with DebugContext

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

the class UninterruptibleAnnotationChecker method checkUninterruptibleCallers.

/**
 * Check that each method that calls a method annotated with {@linkplain Uninterruptible} that
 * has "callerMustBeUninterrutible = true" is also annotated with {@linkplain Uninterruptible}.
 */
@SuppressWarnings("try")
private void checkUninterruptibleCallers(DebugContext debug) {
    for (HostedMethod caller : methodCollection) {
        try (DebugContext.Scope s = debug.scope("CheckUninterruptibleCallers", caller.compilationInfo.graph, caller, this)) {
            Uninterruptible callerAnnotation = caller.getAnnotation(Uninterruptible.class);
            StructuredGraph graph = caller.compilationInfo.getGraph();
            if (callerAnnotation == null && graph != null) {
                for (Invoke invoke : graph.getInvokes()) {
                    HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
                    if (isCallerMustBe(callee)) {
                        postUninterruptibleWarning("Unannotated caller: " + caller.format("%h.%n(%p)") + " calls annotated callee " + callee.format("%h.%n(%p)"));
                    }
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 67 with DebugContext

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

the class UninterruptibleAnnotationChecker method checkUninterruptibleAllocations.

/**
 * Check that each method that is annotated with {@linkplain Uninterruptible} contains no
 * allocations.
 */
@SuppressWarnings("try")
private void checkUninterruptibleAllocations(DebugContext debug) {
    for (HostedMethod method : methodCollection) {
        try (DebugContext.Scope s = debug.scope("CheckUninterruptibleAllocations", method.compilationInfo.graph, method, this)) {
            Uninterruptible methodAnnotation = method.getAnnotation(Uninterruptible.class);
            StructuredGraph graph = method.compilationInfo.getGraph();
            if (methodAnnotation != null && graph != null) {
                for (Node node : graph.getNodes()) {
                    if (node instanceof AbstractNewObjectNode) {
                        postUninterruptibleWarning("Annotated method: " + method.format("%h.%n(%p)") + " allocates.");
                    }
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) Node(org.graalvm.compiler.graph.Node) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 68 with DebugContext

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

the class SnippetStub method getGraph.

@Override
@SuppressWarnings("try")
protected StructuredGraph getGraph(DebugContext debug, CompilationIdentifier compilationId) {
    Plugins defaultPlugins = providers.getGraphBuilderPlugins();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    SnippetReflectionProvider snippetReflection = providers.getSnippetReflection();
    Plugins plugins = new Plugins(defaultPlugins);
    plugins.prependParameterPlugin(new ConstantBindingParameterPlugin(makeConstArgs(), metaAccess, snippetReflection));
    GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
    // Stubs cannot have optimistic assumptions since they have
    // to be valid for the entire run of the VM.
    final StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).compilationId(compilationId).build();
    try (DebugContext.Scope outer = debug.scope("SnippetStub", graph)) {
        graph.disableUnsafeAccessTracking();
        IntrinsicContext initialIntrinsicContext = new IntrinsicContext(method, method, getReplacementsBytecodeProvider(), INLINE_AFTER_PARSING);
        GraphBuilderPhase.Instance instance = new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialIntrinsicContext);
        instance.apply(graph);
        for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
            int index = param.index();
            if (method.getParameterAnnotation(NonNullParameter.class, index) != null) {
                param.setStamp(param.stamp(NodeView.DEFAULT).join(StampFactory.objectNonNull()));
            }
        }
        new RemoveValueProxyPhase().apply(graph);
        graph.setGuardsStage(GuardsStage.FLOATING_GUARDS);
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        PhaseContext context = new PhaseContext(providers);
        canonicalizer.apply(graph, context);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    return graph;
}
Also used : RemoveValueProxyPhase(org.graalvm.compiler.phases.common.RemoveValueProxyPhase) IntrinsicContext(org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) DebugContext(org.graalvm.compiler.debug.DebugContext) ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) NonNullParameter(org.graalvm.compiler.api.replacements.Snippet.NonNullParameter) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 69 with DebugContext

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

the class Stub method buildCompilationResult.

@SuppressWarnings("try")
private CompilationResult buildCompilationResult(DebugContext debug, final Backend backend) {
    CompilationIdentifier compilationId = getStubCompilationId();
    final StructuredGraph graph = getGraph(debug, compilationId);
    CompilationResult compResult = new CompilationResult(compilationId, toString(), GeneratePIC.getValue(options));
    // Stubs cannot be recompiled so they cannot be compiled with assumptions
    assert graph.getAssumptions() == null;
    if (!(graph.start() instanceof StubStartNode)) {
        StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
        newStart.setStateAfter(graph.start().stateAfter());
        graph.replaceFixed(graph.start(), newStart);
    }
    try (DebugContext.Scope s0 = debug.scope("StubCompilation", graph, providers.getCodeCache())) {
        Suites suites = createSuites();
        emitFrontEnd(providers, backend, graph, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, DefaultProfilingInfo.get(TriState.UNKNOWN), suites);
        LIRSuites lirSuites = createLIRSuites();
        emitBackEnd(graph, Stub.this, getInstalledCodeOwner(), backend, compResult, CompilationResultBuilderFactory.Default, getRegisterConfig(), lirSuites);
        assert checkStubInvariants(compResult);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    return compResult;
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) StubStartNode(org.graalvm.compiler.hotspot.nodes.StubStartNode) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) CompilationResult(org.graalvm.compiler.code.CompilationResult) DebugContext(org.graalvm.compiler.debug.DebugContext) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 70 with DebugContext

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

the class Stub method getCode.

/**
 * Gets the code for this stub, compiling it first if necessary.
 */
@SuppressWarnings("try")
public synchronized InstalledCode getCode(final Backend backend) {
    if (code == null) {
        try (DebugContext debug = openDebugContext(DebugContext.forCurrentThread())) {
            try (DebugContext.Scope d = debug.scope("CompilingStub", providers.getCodeCache(), debugScopeContext())) {
                CodeCacheProvider codeCache = providers.getCodeCache();
                CompilationResult compResult = buildCompilationResult(debug, backend);
                try (DebugContext.Scope s = debug.scope("CodeInstall", compResult);
                    DebugContext.Activation a = debug.activate()) {
                    assert destroyedCallerRegisters != null;
                    // Add a GeneratePIC check here later, we don't want to install
                    // code if we don't have a corresponding VM global symbol.
                    HotSpotCompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, null, null, compResult);
                    code = codeCache.installCode(null, compiledCode, null, null, false);
                } catch (Throwable e) {
                    throw debug.handle(e);
                }
            } catch (Throwable e) {
                throw debug.handle(e);
            }
            assert code != null : "error installing stub " + this;
        }
    }
    return code;
}
Also used : HotSpotCompiledCode(jdk.vm.ci.hotspot.HotSpotCompiledCode) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider)

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