Search in sources :

Example 71 with DebugContext

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

the class FrameStateBuilder method insertProxies.

public void insertProxies(Function<ValueNode, ValueNode> proxyFunction) {
    DebugContext debug = graph.getDebug();
    for (int i = 0; i < localsSize(); i++) {
        ValueNode value = locals[i];
        if (value != null && value != TWO_SLOT_MARKER) {
            debug.log(" inserting proxy for %s", value);
            locals[i] = proxyFunction.apply(value);
        }
    }
    for (int i = 0; i < stackSize(); i++) {
        ValueNode value = stack[i];
        if (value != null && value != TWO_SLOT_MARKER) {
            debug.log(" inserting proxy for %s", value);
            stack[i] = proxyFunction.apply(value);
        }
    }
    for (int i = 0; i < lockedObjects.length; i++) {
        ValueNode value = lockedObjects[i];
        if (value != null) {
            debug.log(" inserting proxy for %s", value);
            lockedObjects[i] = proxyFunction.apply(value);
        }
    }
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 72 with DebugContext

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

the class SubstrateReplacements method getSnippet.

@Override
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
    Integer startOffset = snippetStartOffsets.get(method);
    if (startOffset == null) {
        throw VMError.shouldNotReachHere("snippet not found: " + method.format("%H.%n(%p)"));
    }
    ParameterPlugin parameterPlugin = null;
    if (args != null) {
        parameterPlugin = new ConstantBindingParameterPlugin(args, providers.getMetaAccess(), snippetReflection);
    }
    EncodedGraph encodedGraph = new EncodedGraph(snippetEncoding, startOffset, snippetObjects, snippetNodeClasses, null, null, null, false, trackNodeSourcePosition);
    try (DebugContext debug = openDebugContext("SVMSnippet_", method)) {
        StructuredGraph result = new StructuredGraph.Builder(options, debug).method(method).trackNodeSourcePosition(trackNodeSourcePosition).build();
        PEGraphDecoder graphDecoder = new PEGraphDecoder(ConfigurationValues.getTarget().arch, result, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), null, snippetInvocationPlugins, new InlineInvokePlugin[0], parameterPlugin, null, null, null) {

            @Override
            protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod lookupMethod, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider, boolean track) {
                if (lookupMethod.equals(method)) {
                    assert !track || encodedGraph.trackNodeSourcePosition();
                    return encodedGraph;
                } else {
                    throw VMError.shouldNotReachHere(method.format("%H.%n(%p)"));
                }
            }
        };
        graphDecoder.decode(method, trackNodeSourcePosition);
        assert result.verify();
        return result;
    }
}
Also used : ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) PEGraphDecoder(org.graalvm.compiler.replacements.PEGraphDecoder) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) DebugContext(org.graalvm.compiler.debug.DebugContext) ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 73 with DebugContext

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

the class SubstrateReplacements method registerSnippet.

/**
 * Compiles the snippet and stores the graph.
 */
@Platforms(Platform.HOSTED_ONLY.class)
@Override
public void registerSnippet(ResolvedJavaMethod method, boolean trackNodeSourcePosition) {
    assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName();
    assert method.hasBytecodes() : "Snippet must not be abstract or native";
    assert builder.graphs.get(method) == null : "snippet registered twice: " + method.getName();
    try (DebugContext debug = openDebugContext("Snippet_", method)) {
        StructuredGraph graph = makeGraph(debug, defaultBytecodeProvider, method, null, null, trackNodeSourcePosition, null);
        // Check if all methods which should be inlined are really inlined.
        for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) {
            ResolvedJavaMethod callee = callTarget.targetMethod();
            if (!builder.delayedInvocationPluginMethods.contains(callee)) {
                throw shouldNotReachHere("method " + callee.getName() + " not inlined in snippet " + method.getName() + " (maybe not final?)");
            }
        }
        builder.graphs.put(method, graph);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) Snippet(org.graalvm.compiler.api.replacements.Snippet) DebugContext(org.graalvm.compiler.debug.DebugContext) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Platforms(org.graalvm.nativeimage.Platforms)

Example 74 with DebugContext

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

the class SubstrateAMD64Backend method newCompilationResultBuilder.

@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenResult, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
    Assembler masm = createAssembler(frameMap);
    SharedMethod method = ((SubstrateLIRGenerationResult) lirGenResult).getMethod();
    Deoptimizer.StubType stubType = method.getDeoptStubType();
    DataBuilder dataBuilder = new SubstrateDataBuilder();
    FrameContext frameContext;
    if (stubType == Deoptimizer.StubType.EntryStub) {
        frameContext = new DeoptEntryStubContext();
    } else if (stubType == Deoptimizer.StubType.ExitStub) {
        frameContext = new DeoptExitStubContext();
    } else {
        frameContext = new SubstrateAMD64FrameContext();
    }
    LIR lir = lirGenResult.getLIR();
    OptionValues options = lir.getOptions();
    DebugContext debug = lir.getDebug();
    CompilationResultBuilder tasm = factory.createBuilder(getCodeCache(), getForeignCalls(), lirGenResult.getFrameMap(), masm, dataBuilder, frameContext, options, debug, compilationResult);
    tasm.setTotalFrameSize(lirGenResult.getFrameMap().totalFrameSize());
    return tasm;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) FrameContext(org.graalvm.compiler.lir.asm.FrameContext) DebugContext(org.graalvm.compiler.debug.DebugContext) Deoptimizer(com.oracle.svm.core.deopt.Deoptimizer) CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) LIR(org.graalvm.compiler.lir.LIR) SubstrateDataBuilder(com.oracle.svm.core.graal.code.SubstrateDataBuilder) DataBuilder(org.graalvm.compiler.lir.asm.DataBuilder) SharedMethod(com.oracle.svm.core.meta.SharedMethod) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler) Assembler(org.graalvm.compiler.asm.Assembler) SubstrateDataBuilder(com.oracle.svm.core.graal.code.SubstrateDataBuilder)

Example 75 with DebugContext

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

the class LIRGenerationPhase method emitBlock.

private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
    assert !isProcessed(lirGenRes, b) : "Block already processed " + b;
    assert verifyPredecessors(lirGenRes, b);
    nodeLirGen.doBlock(b, graph, blockMap);
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    instructionCounter.add(debug, lir.getLIRforBlock(b).size());
}
Also used : LIR(org.graalvm.compiler.lir.LIR) DebugContext(org.graalvm.compiler.debug.DebugContext)

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