Search in sources :

Example 11 with CEntryPointOptions

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);
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 12 with CEntryPointOptions

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());
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) NativeSimpleType(com.oracle.truffle.nfi.types.NativeSimpleType) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 13 with CEntryPointOptions

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();
}
Also used : ObjectHandle(org.graalvm.nativeimage.ObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 14 with CEntryPointOptions

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;
}
Also used : JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 15 with CEntryPointOptions

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);
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)27 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)26 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)4 JNIObjectHandle (com.oracle.svm.jni.nativeapi.JNIObjectHandle)3 PinnedObject (org.graalvm.nativeimage.PinnedObject)3 Log (com.oracle.svm.core.log.Log)2 JNIAccessibleMethodDescriptor (com.oracle.svm.jni.access.JNIAccessibleMethodDescriptor)2 JNINativeLinkage (com.oracle.svm.jni.access.JNINativeLinkage)2 JNIMethodId (com.oracle.svm.jni.nativeapi.JNIMethodId)2 JNINativeMethod (com.oracle.svm.jni.nativeapi.JNINativeMethod)2 Executable (java.lang.reflect.Executable)2 Method (java.lang.reflect.Method)2 ByteBuffer (java.nio.ByteBuffer)2 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)2 WrappedJavaMethod (com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 AllocationSite (com.oracle.svm.core.allocationprofile.AllocationSite)1 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)1 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1