use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class JNIInvocationInterface method DetachCurrentThread.
/*
* jint DetachCurrentThread(JavaVM *vm);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIJavaVMEnterAttachThreadPrologue.class, epilogue = LeaveDetachThreadEpilogue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static int DetachCurrentThread(JNIJavaVM vm) {
int result = JNIErrors.JNI_OK();
if (!vm.equal(JNIFunctionTables.singleton().getGlobalJavaVM())) {
result = JNIErrors.JNI_ERR();
}
// JNI specification requires releasing all owned monitors
Support.releaseCurrentThreadOwnedMonitors();
return result;
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeAPIImpl method isSameObject.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static int isSameObject(@SuppressWarnings("unused") NativeTruffleEnv env, TruffleObjectHandle handle1, TruffleObjectHandle handle2) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Object object1 = support.resolveHandle(handle1);
Object object2 = support.resolveHandle(handle2);
return object1 == object2 ? 1 : 0;
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NativeAPIImpl method getClosureObject.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static TruffleObjectHandle getClosureObject(NativeTruffleEnv env, PointerBase closure) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Target_com_oracle_truffle_nfi_impl_NFIContext context = lookupContext(env.context());
TruffleObject ret = context.getClosureObject(closure.rawValue());
return support.createGlobalHandle(ret);
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class NFIInitialization method initializeNativeSimpleType.
@CEntryPoint
@CEntryPointOptions(publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void initializeNativeSimpleType(@SuppressWarnings("unused") IsolateThread thread, NativeTruffleContext ctx, CCharPointer typeName, ffi_type ffiType) {
NativeSimpleType simpleType = NativeSimpleType.valueOf(CTypeConversion.toJavaString(typeName));
int size = (int) ffiType.size().rawValue();
int alignment = ffiType.alignment();
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Target_com_oracle_truffle_nfi_impl_NFIContext context = support.resolveContextHandle(ctx.contextHandle());
context.initializeSimpleType(simpleType, size, alignment, ffiType.rawValue());
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PosixThreadsFeature method pthreadStartRoutine.
@CEntryPoint
@CEntryPointOptions(prologue = PthreadStartRoutinePrologue.class, epilogue = LeaveDetachThreadEpilogue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static WordBase pthreadStartRoutine(ThreadStartData data) {
ObjectHandle threadHandle = data.getThreadHandle();
UnmanagedMemory.free(data);
Thread thread = ObjectHandles.getGlobal().get(threadHandle);
boolean status = singleton().assignJavaThread(thread, false);
VMError.guarantee(status, "currentThread already initialized");
/*
* Destroy the handle only after setting currentThread, since the lock used by destroy
* requires the current thread.
*/
ObjectHandles.getGlobal().destroy(threadHandle);
/* Complete the initialization of the thread, now that it is (nearly) running. */
setPthreadIdentifier(thread, Pthread.pthread_self());
singleton().setNativeName(thread, thread.getName());
singleton().noteThreadStart(thread);
try {
thread.run();
} catch (Throwable ex) {
SnippetRuntime.reportUnhandledExceptionJava(ex);
} finally {
exit(thread);
singleton().noteThreadFinish(thread);
}
return WordFactory.nullPointer();
}
Aggregations