Search in sources :

Example 1 with DeoptimizedFrame

use of com.oracle.svm.core.deopt.DeoptimizedFrame in project graal by oracle.

the class JavaStackWalker method doWalk.

@AlwaysInline("avoid virtual call to visitor")
private static boolean doWalk(JavaFrameAnchor lastAnchor, Pointer startSP, CodePointer startIP, StackFrameVisitor visitor) {
    if (!visitor.prologue()) {
        return false;
    }
    if (startSP.isNonNull() && startIP.isNonNull()) {
        JavaFrameAnchor anchor = lastAnchor;
        Pointer sp = startSP;
        CodePointer ip = startIP;
        while (true) {
            while (anchor.isNonNull() && anchor.getLastJavaSP().belowOrEqual(sp)) {
                /* Skip anchors that are in parts of the stack we are not traversing. */
                anchor = anchor.getPreviousAnchor();
            }
            long totalFrameSize;
            DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sp);
            if (deoptFrame != null) {
                totalFrameSize = deoptFrame.getSourceTotalFrameSize();
            } else {
                totalFrameSize = CodeInfoTable.lookupTotalFrameSize(ip);
            }
            if (totalFrameSize != -1) {
                /* This is a Java frame, visit it. */
                if (!visitor.visitFrame(sp, ip, deoptFrame)) {
                    return false;
                }
                /* Bump sp *up* over my frame. */
                sp = sp.add(WordFactory.unsigned(totalFrameSize));
                /* Read the return address to my caller. */
                ip = FrameAccess.readReturnAddress(sp);
            } else if (anchor.isNonNull()) {
                /*
                     * At the end of a block of Java frames, but we have more Java frames after a
                     * block of C frames.
                     */
                assert anchor.getLastJavaSP().aboveThan(sp);
                sp = anchor.getLastJavaSP();
                ip = FrameAccess.readReturnAddress(sp);
                anchor = anchor.getPreviousAnchor();
            } else {
                /* Really at the end of the stack, we are done with walking. */
                break;
            }
        }
    } else {
    /*
             * It is fine for a thread to have no Java frames, for example in the case of a native
             * thread that was attached via JNI, but is currently not executing any Java code.
             */
    }
    return visitor.epilogue();
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) DeoptimizedFrame(com.oracle.svm.core.deopt.DeoptimizedFrame) AlwaysInline(com.oracle.svm.core.annotate.AlwaysInline)

Example 2 with DeoptimizedFrame

use of com.oracle.svm.core.deopt.DeoptimizedFrame 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)

Aggregations

DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)2 Pointer (org.graalvm.word.Pointer)2 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)1 NeverInline (com.oracle.svm.core.annotate.NeverInline)1 JavaFrameAnchor (com.oracle.svm.core.stack.JavaFrameAnchor)1 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)1 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)1