use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class SubstrateInspectedFrame method iterateFrames.
@NeverInline("Stack walking starts at the physical caller frame of this method")
@Override
public <T> T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor<T> visitor) {
if (SubstrateUtil.HOSTED) {
/*
* During native-image generation we use HotSpotStackIntrospection to iterate frames.
* `initialMethods` and `matchingMethods` are hosted versions of `ResolvedJavaMethod`
* that we provide them in `SubstrateTruffleRuntime`.
*/
StackIntrospection hostedStackIntrospection = JVMCI.getRuntime().getHostJVMCIBackend().getStackIntrospection();
return hostedStackIntrospection.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor);
}
/* Stack walking starts at the physical caller frame of this method. */
Pointer startSP = KnownIntrinsics.readCallerStackPointer();
CodePointer startIP = KnownIntrinsics.readReturnAddress();
PhysicalStackFrameVisitor<T> physicalFrameVisitor = new PhysicalStackFrameVisitor<>(initialMethods, matchingMethods, initialSkip, visitor);
JavaStackWalker.walkCurrentThread(startSP, startIP, physicalFrameVisitor);
return physicalFrameVisitor.result;
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class ExceptionStateNode method unwindSnippet.
@Snippet
protected static void unwindSnippet(Throwable exception) {
Pointer callerSP = readCallerStackPointer();
CodePointer callerIP = readReturnAddress();
runtimeCall(UNWIND_EXCEPTION, exception, callerSP, callerIP);
throw unreachable();
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class SubstrateUtil method dumpTopFrame.
@NeverInline("catch implicit exceptions")
private static void dumpTopFrame(Log log, Pointer sp, CodePointer ip) {
log.string("TopFrame info:").newline();
log.indent(true);
if (sp.isNonNull() && ip.isNonNull()) {
long totalFrameSize;
DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sp);
if (deoptFrame != null) {
log.string("RSP ").zhex(sp.rawValue()).string(" frame was deoptimized:").newline();
log.string("SourcePC ").zhex(deoptFrame.getSourcePC().rawValue()).newline();
totalFrameSize = deoptFrame.getSourceTotalFrameSize();
} else {
log.string("Lookup TotalFrameSize in CodeInfoTable:").newline();
totalFrameSize = CodeInfoTable.lookupTotalFrameSize(ip);
}
log.string("SourceTotalFrameSize ").signed(totalFrameSize).newline();
if (totalFrameSize == -1) {
log.string("Does not look like a Java Frame. Use JavaFrameAnchors to find LastJavaSP:").newline();
JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor();
while (anchor.isNonNull() && anchor.getLastJavaSP().belowOrEqual(sp)) {
anchor = anchor.getPreviousAnchor();
}
if (anchor.isNonNull()) {
log.string("Found matching Anchor:").zhex(anchor.rawValue()).newline();
Pointer lastSp = anchor.getLastJavaSP();
log.string("LastJavaSP ").zhex(lastSp.rawValue()).newline();
CodePointer lastIp = FrameAccess.readReturnAddress(lastSp);
log.string("LastJavaIP ").zhex(lastIp.rawValue()).newline();
}
}
}
log.indent(false);
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class GarbageCollectorManagementFactory method blackenStackRoots.
@SuppressWarnings("try")
private void blackenStackRoots() {
final Log trace = Log.noopLog().string("[GCImpl.blackenStackRoots:").newline();
try (Timer bsr = blackenStackRootsTimer.open()) {
Pointer sp = readCallerStackPointer();
trace.string("[blackenStackRoots:").string(" sp: ").hex(sp);
CodePointer ip = readReturnAddress();
trace.string(" ip: ").hex(ip).newline();
JavaStackWalker.walkCurrentThread(sp, ip, frameWalker);
if (SubstrateOptions.MultiThreaded.getValue()) {
/*
* Scan the stacks of all the threads. Other threads will be blocked at a safepoint
* (or in native code) so they will each have a JavaFrameAnchor in their VMThread.
*/
for (IsolateThread vmThread = VMThreads.firstThread(); VMThreads.isNonNullThread(vmThread); vmThread = VMThreads.nextThread(vmThread)) {
if (vmThread == CEntryPointContext.getCurrentIsolateThread()) {
/*
* The current thread is already scanned by code above, so we do not have to
* do anything for it here. It might have a JavaFrameAnchor from earlier
* Java-to-C transitions, but certainly not at the top of the stack since it
* is running this code, so just this scan would be incomplete.
*/
continue;
}
JavaStackWalker.walkThread(vmThread, frameWalker);
trace.newline();
}
}
trace.string("]").newline();
}
trace.string("]").newline();
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class PathExhibitor method findPathInStack.
protected StackElement findPathInStack(final Object obj) {
stackFrameVisitor.initialize(obj);
Pointer sp = readCallerStackPointer();
CodePointer ip = readReturnAddress();
JavaStackWalker.walkCurrentThread(sp, ip, stackFrameVisitor);
final StackElement result = frameSlotVisitor.getElement();
return result;
}
Aggregations