use of com.oracle.truffle.api.nodes.ControlFlowException in project graal by oracle.
the class TruffleStackTrace method fillIn.
@TruffleBoundary
static TruffleStackTrace fillIn(Throwable t) {
if (t instanceof ControlFlowException) {
return EMPTY;
}
LazyStackTrace lazy = findImpl(t);
if (lazy == null) {
Throwable insertCause = findInsertCause(t);
if (insertCause == null) {
return null;
}
insert(insertCause, lazy = new LazyStackTrace());
}
if (lazy.stackTrace != null) {
// stack trace already exists
return lazy.stackTrace;
}
int stackFrameLimit;
Node topCallSite;
if (t instanceof TruffleException) {
TruffleException te = (TruffleException) t;
topCallSite = te.getLocation();
stackFrameLimit = te.getStackTraceElementLimit();
} else {
topCallSite = null;
stackFrameLimit = -1;
}
// add the lazily captured stack frames above the manually queried ones
ArrayList<TracebackElement> elements = new ArrayList<>();
TracebackElement currentElement = lazy.current;
while (currentElement != null) {
elements.add(currentElement);
currentElement = currentElement.last;
}
Collections.reverse(elements);
List<TruffleStackTraceElement> frames = new ArrayList<>();
for (TracebackElement element : elements) {
if (element.root != null) {
frames.add(new TruffleStackTraceElement(topCallSite, element.root, element.frame));
topCallSite = null;
}
if (element.callNode != null) {
topCallSite = element.callNode;
}
}
int lazyFrames = frames.size();
// attach the remaining stack trace elements
addStackFrames(stackFrameLimit, lazyFrames, topCallSite, frames);
return lazy.stackTrace = new TruffleStackTrace(frames, lazyFrames);
}
use of com.oracle.truffle.api.nodes.ControlFlowException in project sulong by graalvm.
the class LLVMContext method dispose.
public void dispose(LLVMMemory memory) {
printNativeCallStatistic();
// - _exit(), _Exit(), or abort(): no cleanup necessary
if (cleanupNecessary) {
try {
RootCallTarget disposeContext = globalScope.getFunctionDescriptor("@__sulong_dispose_context").getLLVMIRFunction();
try (StackPointer stackPointer = threadingStack.getStack().newFrame()) {
disposeContext.call(stackPointer);
}
} catch (ControlFlowException e) {
// nothing needs to be done as the behavior is not defined
}
}
threadingStack.freeMainStack(memory);
globalStack.free();
}
Aggregations