use of com.oracle.truffle.llvm.runtime.SulongRuntimeException in project sulong by graalvm.
the class LLVMGlobalRootNode method execute.
@Override
@ExplodeLoop
public Object execute(VirtualFrame frame) {
try (StackPointer basePointer = getContext().getThreadingStack().getStack().newFrame()) {
try {
TruffleObject appPath = (TruffleObject) ctxRef.get().getEnv().asGuestValue(applicationPath.getBytes());
LLVMTruffleObject applicationPathObj = new LLVMTruffleObject(LLVMTypedForeignObject.createUnknown(appPath));
Object[] realArgs = new Object[] { basePointer, mainFunctionType, applicationPathObj };
Object result = startFunction.call(realArgs);
getContext().awaitThreadTermination();
return result;
} catch (LLVMExitException e) {
LLVMContext context = getContext();
// if any variant of exit or abort was called, we know that all the necessary
// cleanup was already done
context.setCleanupNecessary(false);
context.awaitThreadTermination();
return e.getReturnCode();
} catch (SulongRuntimeException e) {
CompilerDirectives.transferToInterpreter();
throw e;
} catch (GuestLanguageRuntimeException e) {
CompilerDirectives.transferToInterpreter();
return e.handleExit();
} finally {
// if not done already, we want at least call a shutdown command
getContext().shutdownThreads();
}
}
}
Aggregations