Search in sources :

Example 6 with EspressoRootNode

use of com.oracle.truffle.espresso.nodes.EspressoRootNode 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)

Example 7 with EspressoRootNode

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

the class VM method getEspressoRootFromFrame.

@TruffleBoundary
public static EspressoRootNode getEspressoRootFromFrame(FrameInstance frameInstance, EspressoContext context) {
    EspressoRootNode root = getRawEspressoRootFromFrame(frameInstance);
    if (root == null) {
        return null;
    }
    Method method = root.getMethod();
    if (method.getContext() != context) {
        return null;
    }
    return root;
}
Also used : EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode) Method(com.oracle.truffle.espresso.impl.Method) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 8 with EspressoRootNode

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

the class Method method forceSplit.

public Method forceSplit() {
    Method result = new Method(this, getCodeAttribute());
    BytecodeNode bytecodeNode = new BytecodeNode(result.getMethodVersion());
    EspressoRootNode root = EspressoRootNode.create(bytecodeNode.getFrameDescriptor(), bytecodeNode);
    result.getMethodVersion().callTarget = root.getCallTarget();
    return result;
}
Also used : BytecodeNode(com.oracle.truffle.espresso.nodes.BytecodeNode) EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode)

Example 9 with EspressoRootNode

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

the class JDWPContextImpl method getOwnedMonitors.

@Override
public MonitorStackInfo[] getOwnedMonitors(CallFrame[] callFrames) {
    List<MonitorStackInfo> result = new ArrayList<>();
    int stackDepth = 0;
    for (CallFrame callFrame : callFrames) {
        RootNode rootNode = callFrame.getRootNode();
        if (rootNode instanceof EspressoRootNode) {
            EspressoRootNode espressoRootNode = (EspressoRootNode) rootNode;
            if (espressoRootNode.usesMonitors()) {
                StaticObject[] monitors = espressoRootNode.getMonitorsOnFrame(callFrame.getFrame());
                for (StaticObject monitor : monitors) {
                    if (monitor != null) {
                        result.add(new MonitorStackInfo(monitor, stackDepth));
                    }
                }
            }
        }
        stackDepth++;
    }
    return result.toArray(new MonitorStackInfo[result.size()]);
}
Also used : EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode) RootNode(com.oracle.truffle.api.nodes.RootNode) ArrayList(java.util.ArrayList) CallFrame(com.oracle.truffle.espresso.jdwp.api.CallFrame) MonitorStackInfo(com.oracle.truffle.espresso.jdwp.api.MonitorStackInfo) EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode)

Aggregations

EspressoRootNode (com.oracle.truffle.espresso.nodes.EspressoRootNode)9 RootNode (com.oracle.truffle.api.nodes.RootNode)4 Method (com.oracle.truffle.espresso.impl.Method)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 RootCallTarget (com.oracle.truffle.api.RootCallTarget)2 BytecodeNode (com.oracle.truffle.espresso.nodes.BytecodeNode)2 TruffleStackTrace (com.oracle.truffle.api.TruffleStackTrace)1 TruffleStackTraceElement (com.oracle.truffle.api.TruffleStackTraceElement)1 Node (com.oracle.truffle.api.nodes.Node)1 BytecodeStream (com.oracle.truffle.espresso.bytecode.BytecodeStream)1 CallFrame (com.oracle.truffle.espresso.jdwp.api.CallFrame)1 MonitorStackInfo (com.oracle.truffle.espresso.jdwp.api.MonitorStackInfo)1 QuickNode (com.oracle.truffle.espresso.nodes.quick.QuickNode)1 EspressoException (com.oracle.truffle.espresso.runtime.EspressoException)1 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)1 ArrayList (java.util.ArrayList)1