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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations