Search in sources :

Example 1 with QuickNode

use of com.oracle.truffle.espresso.nodes.quick.QuickNode in project graal by oracle.

the class InterpreterToVM method fillInStackTrace.

/**
 * Preemptively added method to benefit from truffle lazy stack traces when they will be
 * reworked.
 */
@SuppressWarnings("unused")
public static StaticObject fillInStackTrace(@JavaType(Throwable.class) StaticObject throwable, Meta meta) {
    // Inlined calls to help StackOverflows.
    VM.StackTrace frames = (VM.StackTrace) meta.HIDDEN_FRAMES.getHiddenObject(throwable);
    if (frames != null) {
        return throwable;
    }
    EspressoException e = EspressoException.wrap(throwable, meta);
    List<TruffleStackTraceElement> trace = TruffleStackTrace.getStackTrace(e);
    if (trace == null) {
        meta.HIDDEN_FRAMES.setHiddenObject(throwable, VM.StackTrace.EMPTY_STACK_TRACE);
        meta.java_lang_Throwable_backtrace.setObject(throwable, throwable);
        return throwable;
    }
    int bci = -1;
    Method m = null;
    frames = new VM.StackTrace();
    FrameCounter c = new FrameCounter();
    for (TruffleStackTraceElement element : trace) {
        Node location = element.getLocation();
        while (location != null) {
            if (location instanceof QuickNode) {
                bci = ((QuickNode) location).getBci(element.getFrame());
                break;
            }
            location = location.getParent();
        }
        RootCallTarget target = element.getTarget();
        if (target != null) {
            RootNode rootNode = target.getRootNode();
            if (rootNode instanceof EspressoRootNode) {
                m = ((EspressoRootNode) rootNode).getMethod();
                if (c.checkFillIn(m) || c.checkThrowableInit(m)) {
                    bci = UNKNOWN_BCI;
                    continue;
                }
                if (m.isNative()) {
                    bci = NATIVE_BCI;
                }
                frames.add(new VM.StackElement(m, bci));
                bci = UNKNOWN_BCI;
            }
        }
    }
    meta.HIDDEN_FRAMES.setHiddenObject(throwable, frames);
    meta.java_lang_Throwable_backtrace.setObject(throwable, throwable);
    return throwable;
}
Also used : EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode) RootNode(com.oracle.truffle.api.nodes.RootNode) TruffleStackTrace(com.oracle.truffle.api.TruffleStackTrace) TruffleStackTraceElement(com.oracle.truffle.api.TruffleStackTraceElement) EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode) QuickNode(com.oracle.truffle.espresso.nodes.quick.QuickNode) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) BytecodeNode(com.oracle.truffle.espresso.nodes.BytecodeNode) Method(com.oracle.truffle.espresso.impl.Method) EspressoException(com.oracle.truffle.espresso.runtime.EspressoException) QuickNode(com.oracle.truffle.espresso.nodes.quick.QuickNode) EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Aggregations

RootCallTarget (com.oracle.truffle.api.RootCallTarget)1 TruffleStackTrace (com.oracle.truffle.api.TruffleStackTrace)1 TruffleStackTraceElement (com.oracle.truffle.api.TruffleStackTraceElement)1 Node (com.oracle.truffle.api.nodes.Node)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 Method (com.oracle.truffle.espresso.impl.Method)1 BytecodeNode (com.oracle.truffle.espresso.nodes.BytecodeNode)1 EspressoRootNode (com.oracle.truffle.espresso.nodes.EspressoRootNode)1 QuickNode (com.oracle.truffle.espresso.nodes.quick.QuickNode)1 EspressoException (com.oracle.truffle.espresso.runtime.EspressoException)1