use of com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method executeNative.
@Substitute
void executeNative(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs, byte[] ret) {
try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount);
PinnedObject retBuffer = PinnedObject.create(ret)) {
NativeTruffleContext ctx = WordFactory.pointer(nativeContext);
ffi_cif ffiCif = WordFactory.pointer(cif);
ExecuteHelper.execute(ctx, ffiCif, retBuffer.addressOfArrayElement(0), functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope);
}
}
use of com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method executeObject.
@Substitute
Object executeObject(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs) {
try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount)) {
NativeTruffleContext ctx = WordFactory.pointer(nativeContext);
ffi_cif ffiCif = WordFactory.pointer(cif);
WordPointer retPtr = StackValue.get(8);
ExecuteHelper.execute(ctx, ffiCif, retPtr, functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope);
return ImageSingletons.lookup(TruffleNFISupport.class).resolveHandle(retPtr.read());
}
}
use of com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method executePrimitive.
@Substitute
long executePrimitive(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs) {
try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount)) {
NativeTruffleContext ctx = WordFactory.pointer(nativeContext);
ffi_cif ffiCif = WordFactory.pointer(cif);
CLongPointer retPtr = StackValue.get(8);
ExecuteHelper.execute(ctx, ffiCif, retPtr, functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope);
return retPtr.read();
}
}
use of com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method initializeNativeContext.
// Checkstyle: resume
@Substitute
private long initializeNativeContext() {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
NativeTruffleContext ret = UnmanagedMemory.malloc(SizeOf.get(NativeTruffleContext.class));
ret.setContextHandle(support.createContextHandle(this));
NFIInitialization.initializeContext(ret);
return ret.rawValue();
}
use of com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method initializeNativeEnv.
@Substitute
private static long initializeNativeEnv(long context) {
NativeTruffleContext ctx = WordFactory.pointer(context);
NativeTruffleEnv env = UnmanagedMemory.malloc(SizeOf.get(NativeTruffleEnv.class));
NFIInitialization.initializeEnv(env, ctx);
return env.rawValue();
}
Aggregations