use of com.oracle.svm.truffle.nfi.LibFFI.ClosureData in project graal by oracle.
the class NativeClosure method prepareClosure.
static Target_com_oracle_truffle_nfi_impl_ClosureNativePointer prepareClosure(Target_com_oracle_truffle_nfi_impl_NFIContext ctx, Target_com_oracle_truffle_nfi_impl_LibFFISignature signature, CallTarget callTarget, ffi_closure_callback callback) {
NativeClosure closure = new NativeClosure(callTarget, signature);
NativeClosureHandle handle = ImageSingletons.lookup(TruffleNFISupport.class).createClosureHandle(closure);
WordPointer codePtr = StackValue.get(SizeOf.get(WordPointer.class));
ClosureData data = ffi_closure_alloc(SizeOf.unsigned(ClosureData.class), codePtr);
data.setNativeClosureHandle(handle);
data.setIsolate(CEntryPointContext.getCurrentIsolate());
PointerBase code = codePtr.read();
LibFFI.ffi_prep_closure_loc(data.ffiClosure(), WordFactory.pointer(signature.cif), callback, data, code);
return ctx.createClosureNativePointer(data.rawValue(), code.rawValue(), callTarget, signature);
}
Aggregations