use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeAPIImpl method releaseAndReturn.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static TruffleObjectHandle releaseAndReturn(@SuppressWarnings("unused") NativeTruffleEnv env, TruffleObjectHandle handle) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Object object = support.resolveHandle(handle);
support.destroyGlobalHandle(handle);
return TruffleNFISupport.createLocalHandle(object);
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeAPIImpl method newObjectRef.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static TruffleObjectHandle newObjectRef(@SuppressWarnings("unused") NativeTruffleEnv env, TruffleObjectHandle handle) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Object object = support.resolveHandle(handle);
return support.createGlobalHandle(object);
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeClosure method invokeClosureBufferRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureBufferRet(@SuppressWarnings("unused") ffi_cif cif, Pointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
NativeClosure closure = lookup(user);
ByteBuffer retBuffer = closure.createRetBuffer(ret);
Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches patches = (Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches) closure.call(args, retBuffer);
if (patches != null) {
for (int i = 0; i < patches.count; i++) {
Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag tag = getTag(patches.patches[i]);
int offset = getOffset(patches.patches[i]);
Object obj = patches.objects[i];
if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.OBJECT) {
WordBase handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj);
ret.writeWord(offset, handle);
} else if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.STRING) {
ret.writeWord(offset, serializeStringRet(obj));
} else {
// nothing to do
}
}
}
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeClosure method invokeClosureVoidRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureVoidRet(@SuppressWarnings("unused") ffi_cif cif, @SuppressWarnings("unused") WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
lookup(user).call(args, null);
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeClosure method invokeClosureObjectRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureObjectRet(@SuppressWarnings("unused") ffi_cif cif, WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
Object obj = lookup(user).call(args, null);
if (obj == null) {
ret.write(WordFactory.zero());
} else {
TruffleObjectHandle handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj);
ret.write(handle);
}
} finally {
Errno.set_errno(errnoMirror.read());
}
}
Aggregations