Search in sources :

Example 6 with CodePointer

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;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) StackIntrospection(jdk.vm.ci.code.stack.StackIntrospection) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 7 with CodePointer

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();
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 8 with CodePointer

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);
}
Also used : JavaFrameAnchor(com.oracle.svm.core.stack.JavaFrameAnchor) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) DeoptimizedFrame(com.oracle.svm.core.deopt.DeoptimizedFrame) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 9 with CodePointer

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();
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) Log(com.oracle.svm.core.log.Log) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer)

Example 10 with CodePointer

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;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer)

Aggregations

CodePointer (org.graalvm.nativeimage.c.function.CodePointer)14 Pointer (org.graalvm.word.Pointer)11 NeverInline (com.oracle.svm.core.annotate.NeverInline)4 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)3 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)2 CodeInfoQueryResult (com.oracle.svm.core.code.CodeInfoQueryResult)2 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 Log (com.oracle.svm.core.log.Log)2 IsolateThread (org.graalvm.nativeimage.IsolateThread)2 Substitute (com.oracle.svm.core.annotate.Substitute)1 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 SubstrateInstalledCode (com.oracle.svm.core.deopt.SubstrateInstalledCode)1 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)1 JavaFrameAnchor (com.oracle.svm.core.stack.JavaFrameAnchor)1 StackFrameVisitor (com.oracle.svm.core.stack.StackFrameVisitor)1 StackIntrospection (jdk.vm.ci.code.stack.StackIntrospection)1 DeoptimizationAction (jdk.vm.ci.meta.DeoptimizationAction)1 DeoptimizationReason (jdk.vm.ci.meta.DeoptimizationReason)1 Snippet (org.graalvm.compiler.api.replacements.Snippet)1 NodeSourcePosition (org.graalvm.compiler.graph.NodeSourcePosition)1