use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class RemoveUnwindPhase method run.
@Override
protected void run(StructuredGraph graph) {
SharedMethod method = (SharedMethod) graph.method();
if (method.isDeoptTarget()) {
/*
* Deoptimization targets need need to have an exception entry point for every invoke.
* This decouples deoptimization from exception handling: the exception handling
* mechanism can just deliver an exception to a deoptimized method without any checks.
*/
return;
}
List<InvokeWithExceptionNode> invocations = new ArrayList<>();
for (UnwindNode node : graph.getNodes().filter(UnwindNode.class)) {
walkBack(node.predecessor(), node, invocations);
}
/*
* Modify graph only after all suitable invocations are found, to avoid problems with
* deleted nodes during graph traversal.
*/
for (InvokeWithExceptionNode node : invocations) {
InvokeNode replacement = node.graph().add(new InvokeNode(node.callTarget(), node.bci(), node.stamp(NodeView.DEFAULT)));
replacement.setStateAfter(node.stateAfter());
node.killExceptionEdge();
node.graph().replaceSplit(node, replacement, node.next());
}
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class Deoptimizer method printDeoptimizedFrame.
private static void printDeoptimizedFrame(Log log, Pointer sp, DeoptimizedFrame deoptimizedFrame, FrameInfoQueryResult sourceFrameInfo) {
log.string("[Deoptimization of frame").newline();
SubstrateInstalledCode installedCode = deoptimizedFrame.getSourceInstalledCode();
if (installedCode != null) {
log.string(" name: ").string(installedCode.getName()).newline();
}
log.string(" sp: ").hex(sp).string(" ip: ").hex(deoptimizedFrame.getSourcePC()).newline();
if (sourceFrameInfo != null) {
log.string(" stack trace where execution continues:").newline();
FrameInfoQueryResult sourceFrame = sourceFrameInfo;
VirtualFrame targetFrame = deoptimizedFrame.getTopFrame();
while (sourceFrame != null) {
SharedMethod deoptMethod = sourceFrame.getDeoptMethod();
int bci = sourceFrame.getBci();
log.string(" at ");
if (deoptMethod != null) {
StackTraceElement element = deoptMethod.asStackTraceElement(bci);
if (element.getFileName() != null && element.getLineNumber() >= 0) {
log.string(element.toString());
} else {
log.string(deoptMethod.format("%H.%n(%p)")).string(" bci ").signed(bci);
}
} else {
log.string("method at ").hex(sourceFrame.getDeoptMethodAddress()).string(" bci ").signed(bci);
}
log.newline();
if (Options.TraceDeoptimizationDetails.getValue()) {
printVirtualFrame(log, targetFrame);
}
sourceFrame = sourceFrame.getCaller();
targetFrame = targetFrame.getCaller();
}
}
log.string("]").newline();
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class CFunctionCallStubMethod method buildGraph.
@Override
public StructuredGraph buildGraph(DebugContext debug, ResolvedJavaMethod method, HostedProviders providers, Purpose purpose) {
NativeLibraries nativeLibraries = CEntryPointCallStubSupport.singleton().getNativeLibraries();
CFunction annotation = method.getAnnotation(CFunction.class);
boolean needsTransition = annotation.transition() != Transition.NO_TRANSITION;
if (purpose == Purpose.PREPARE_RUNTIME_COMPILATION && needsTransition) {
/*
* C function calls that need a transition cannot be runtime compiled (and cannot be
* inlined during runtime compilation). Deoptimization could be required while we are
* blocked in native code, which means the deoptimization stub would need to do the
* native-to-Java transition.
*/
ImageSingletons.lookup(CFunctionFeature.class).warnRuntimeCompilationReachableCFunctionWithTransition(this);
return null;
}
boolean deoptimizationTarget = method instanceof SharedMethod && ((SharedMethod) method).isDeoptTarget();
HostedGraphKit kit = new HostedGraphKit(debug, providers, method);
FrameStateBuilder state = kit.getFrameState();
ValueNode callAddress = kit.unique(new CGlobalDataLoadAddressNode(linkage));
List<ValueNode> arguments = kit.loadArguments(method.toParameterTypes());
Signature signature = adaptSignatureAndConvertArguments(method, providers, nativeLibraries, kit, method.getSignature(), arguments);
state.clearLocals();
ValueNode returnValue = kit.createCFunctionCall(callAddress, method, arguments, signature, needsTransition, deoptimizationTarget);
returnValue = adaptReturnValue(method, providers, nativeLibraries, kit, returnValue);
kit.createReturn(returnValue, signature.getReturnKind());
assert kit.getGraph().verify();
return kit.getGraph();
}
use of com.oracle.svm.core.meta.SharedMethod 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 com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class InstalledCodeBuilder method getTargetCodeAddress.
private long getTargetCodeAddress(Call callInfo) {
// NOTE that for the moment, we don't make static calls to external
// (e.g. native) functions.
// This will change, and we will have to case-split here... but not yet.
SharedMethod targetMethod = (SharedMethod) callInfo.target;
long callTargetStart = CodeInfoTable.getImageCodeCache().absoluteIP(targetMethod.getCodeOffsetInImage()).rawValue();
if (allInstalledCode != null) {
InstalledCodeBuilder targetInstalledCodeBuilder = allInstalledCode.get(targetMethod);
if (targetInstalledCodeBuilder != null) {
SubstrateInstalledCode targetInstalledCode = targetInstalledCodeBuilder.getInstalledCode();
if (targetInstalledCode != null && targetInstalledCode.isValid()) {
callTargetStart = targetInstalledCode.getAddress();
}
}
}
if (callTargetStart == 0) {
throw VMError.shouldNotReachHere("target method not compiled: " + targetMethod.format("%H.%n(%p)"));
}
return callTargetStart;
}
Aggregations