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);
}
}
}
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;
}
}
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);
}
}
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;
}
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());
}
Aggregations