use of com.oracle.truffle.llvm.runtime.memory.LLVMStack in project sulong by graalvm.
the class LLVMTruffleExecute method doExecute.
@ExplodeLoop
private Object doExecute(VirtualFrame frame, TruffleObject value, LLVMContext context, LLVMGetStackNode getStack) {
Object[] evaluatedArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
}
try {
LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
Object rawValue;
try (StackPointer save = stack.newFrame()) {
rawValue = ForeignAccess.sendExecute(foreignExecute, value, evaluatedArgs);
}
return toLLVM.executeWithTarget(rawValue);
} catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMStack in project sulong by graalvm.
the class LLVMForeignCallNode method callIndirect.
@Specialization(replaces = "callDirectCached")
protected Object callIndirect(LLVMFunctionDescriptor function, Object[] arguments, @Cached("create()") IndirectCallNode callNode, @Cached("createSlowPackArguments()") SlowPackForeignArgumentsNode slowPack, @Cached("create()") LLVMGetStackNode getStack, @Cached("getLLVMMemory()") LLVMMemory memory) {
assert !(function.getType().getReturnType() instanceof StructureType);
LLVMStack stack = getStack.executeWithTarget(function.getContext().getThreadingStack(), Thread.currentThread());
Object result;
try (StackPointer stackPointer = stack.newFrame()) {
result = callNode.call(getCallTarget(function), slowPack.pack(function, memory, arguments, stackPointer));
}
return prepareValueForEscape.executeWithTarget(result);
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMStack in project sulong by graalvm.
the class LLVMTruffleInvoke method doInvoke.
@ExplodeLoop
private Object doInvoke(VirtualFrame frame, TruffleObject value, String id, ContextReference<LLVMContext> contextReference, LLVMGetStackNode getStack) {
Object[] evaluatedArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
}
try {
LLVMContext context = contextReference.get();
LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
Object rawValue;
try (StackPointer save = stack.newFrame()) {
rawValue = ForeignAccess.sendInvoke(foreignInvoke, value, id, evaluatedArgs);
}
return toLLVM.executeWithTarget(rawValue);
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMStack 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