use of com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer in project sulong by graalvm.
the class LLVMNativeDispatchNode method doCached.
@Specialization(guards = "function.getVal() == cachedFunction.getVal()")
@SuppressWarnings("unused")
protected Object doCached(LLVMAddress function, Object[] arguments, @Cached("getContextReference()") ContextReference<LLVMContext> context, @Cached("function") LLVMAddress cachedFunction, @Cached("identityFunction()") TruffleObject identity, @Cached("dispatchIdentity(identity, cachedFunction.getVal())") TruffleObject nativeFunctionHandle, @Cached("createToNativeNodes()") LLVMNativeConvertNode[] toNative, @Cached("createFromNativeNode()") LLVMNativeConvertNode fromNative, @Cached("nativeCallStatisticsEnabled(context)") boolean statistics) {
Object[] nativeArgs = prepareNativeArguments(arguments, toNative);
Object returnValue;
try (StackPointer save = ((StackPointer) arguments[0]).newFrame()) {
returnValue = LLVMNativeCallUtils.callNativeFunction(statistics, context, nativeCallNode, nativeFunctionHandle, nativeArgs, null);
}
return fromNative.executeConvert(returnValue);
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer 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();
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer in project sulong by graalvm.
the class LLVMForeignCallNode method directCall.
private Object directCall(Object[] arguments, DirectCallNode callNode, PackForeignArgumentsNode packNode, LLVMGetStackNode getStack, LLVMContext context) {
Object result;
LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
try (StackPointer stackPointer = stack.newFrame()) {
result = callNode.call(packNode.pack(arguments, stackPointer));
}
return prepareValueForEscape.executeWithTarget(result);
}
Aggregations