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;
}
Aggregations