use of org.graalvm.nativeimage.Isolate in project graal by oracle.
the class PosixCEntryPointSnippets method enterSnippet.
@Snippet
public static int enterSnippet(IsolateThread thread) {
Isolate isolate;
if (MultiThreaded.getValue()) {
if (thread.isNull()) {
return Errors.NULL_ARGUMENT;
}
writeCurrentVMThread(thread);
isolate = PosixVMThreads.IsolateTL.get(thread);
} else {
// single-threaded
if (SpawnIsolates.getValue()) {
if (thread.isNull()) {
return Errors.NULL_ARGUMENT;
}
} else if (!thread.equal(CEntryPointSetup.SINGLE_THREAD_SENTINEL)) {
return Errors.UNATTACHED_THREAD;
}
isolate = (Isolate) ((Word) thread).subtract(CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND);
}
if (UseHeapBaseRegister.getValue()) {
setHeapBase(PosixIsolates.getHeapBase(isolate));
}
if (MultiThreaded.getValue()) {
Safepoint.transitionNativeToJava();
}
return Errors.NO_ERROR;
}
use of org.graalvm.nativeimage.Isolate 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