Search in sources :

Example 46 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class CEntryPointNativeFunctions method getCurrentThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "current_thread", documentation = { "Given an isolate to which the current thread is attached, returns the address of", "the thread's associated isolate thread structure.  If the current thread is not", "attached to the passed isolate or if another error occurs, returns NULL." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static IsolateThread getCurrentThread(Isolate isolate) {
    int result = CEntryPointActions.enterIsolate(isolate);
    if (result != 0) {
        return WordFactory.nullPointer();
    }
    IsolateThread thread = CEntryPointContext.getCurrentIsolateThread();
    if (CEntryPointActions.leave() != 0) {
        thread = WordFactory.nullPointer();
    }
    return thread;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 47 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class CEntryPointNativeFunctions method detachThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "detach_thread", documentation = { "Detaches the passed isolate thread from its isolate and discards any state or", "context that is associated with it. At the time of the call, no code may still", "be executing in the isolate thread's context.", "Returns 0 on success, or a non-zero value on failure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int detachThread(IsolateThread thread) {
    int result = CEntryPointActions.enter(thread);
    if (result != 0) {
        CEntryPointActions.leave();
        return result;
    }
    result = CEntryPointActions.leaveDetachThread();
    return result;
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 48 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class CEntryPointNativeFunctions method tearDownIsolate.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "tear_down_isolate", documentation = { "Tears down the passed isolate, waiting for any attached threads to detach from", "it, then discards the isolate's objects, threads, and any other state or context", "that is associated with it.", "Returns 0 on success, or a non-zero value on failure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int tearDownIsolate(Isolate isolate) {
    int result = CEntryPointActions.enterAttachThread(isolate);
    if (result != 0) {
        CEntryPointActions.leave();
        return result;
    }
    result = CEntryPointActions.leaveTearDownIsolate();
    return result;
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 49 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class CEntryPointNativeFunctions method attachThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "attach_thread", documentation = { "Attaches the current thread to the passed isolate.", "On failure, returns a non-zero value. On success, writes the address of the", "created isolate thread structure to the passed pointer and returns 0.", "If the thread has already been attached, the call succeeds and also provides", "the thread's isolate thread structure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int attachThread(Isolate isolate, IsolateThreadPointer thread) {
    int result = CEntryPointActions.enterAttachThread(isolate);
    if (result == 0) {
        thread.write(CEntryPointContext.getCurrentIsolateThread());
        result = CEntryPointActions.leave();
    }
    return result;
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 50 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class CEntryPointNativeFunctions method getCurrentIsolate.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "current_isolate", documentation = { "Given an isolate thread structure for the current thread, determines to which", "isolate it belongs and returns the address of its isolate structure.  If an", "error occurs, returns NULL instead." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static Isolate getCurrentIsolate(IsolateThread thread) {
    int result = CEntryPointActions.enter(thread);
    if (result != 0) {
        return WordFactory.nullPointer();
    }
    Isolate isolate = CEntryPointContext.getCurrentIsolate();
    if (CEntryPointActions.leave() != 0) {
        isolate = WordFactory.nullPointer();
    }
    return isolate;
}
Also used : Isolate(org.graalvm.nativeimage.Isolate) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Aggregations

CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)81 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)26 Value (org.graalvm.polyglot.Value)23 CEntryPointContext (org.graalvm.nativeimage.c.function.CEntryPointContext)19 Context (org.graalvm.polyglot.Context)19 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)7 ObjectHandle (org.graalvm.nativeimage.ObjectHandle)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)4 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)4 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)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