use of com.oracle.svm.core.c.function.CEntryPointOptions 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 com.oracle.svm.core.c.function.CEntryPointOptions 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 com.oracle.svm.core.c.function.CEntryPointOptions 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();
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class JNIFunctions method NewGlobalRef.
/*
* jobject NewGlobalRef(JNIEnv *env, jobject obj);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullHandle.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIObjectHandle NewGlobalRef(JNIEnvironment env, JNIObjectHandle handle) {
JNIObjectHandle result = JNIObjectHandles.nullHandle();
Object obj = JNIObjectHandles.getObject(handle);
if (obj != null) {
result = (JNIObjectHandle) JNIGlobalHandles.singleton().create(obj);
}
return result;
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class JNIFunctions method NewString.
/*
* jstring NewString(JNIEnv *env, const jchar *unicodeChars, jsize len);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullHandle.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIObjectHandle NewString(JNIEnvironment env, CShortPointer unicode, int len) {
String str;
char[] chars = new char[len];
for (int i = 0; i < chars.length; i++) {
int value = Short.toUnsignedInt(unicode.read(i));
chars[i] = (char) value;
}
str = new String(chars);
return JNIThreadLocalHandles.get().create(str);
}
Aggregations