use of com.oracle.svm.core.thread.Safepoint in project graal by oracle.
the class PosixCEntryPointSnippets method detachThreadMT.
@SubstrateForeignCallTarget
@Uninterruptible(reason = "Thread state going away.")
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not (thread-local) allocate while detaching a thread.")
private static int detachThreadMT(IsolateThread thread) {
int result = Errors.NO_ERROR;
/*
* Set thread status to exited. This makes me immune to safepoints (the safepoint mechanism
* ignores me). Also clear any pending safepoint requests, since I will not honor them.
*/
VMThreads.StatusSupport.setStatusExited();
Safepoint.setSafepointRequested(Safepoint.SafepointRequestValues.RESET);
// try-finally because try-with-resources can call interruptible code
VMThreads.THREAD_MUTEX.lockNoTransition();
try {
detachJavaLangThreadMT(thread);
// clear references to thread to avoid unintended use
writeCurrentVMThread(VMThreads.nullThread());
PosixVMThreads.VMThreadTL.set(VMThreads.nullThread());
VMThreads.detachThread(thread);
} catch (Throwable t) {
result = Errors.UNSPECIFIED;
} finally {
VMThreads.THREAD_MUTEX.unlock();
LibC.free(thread);
}
return result;
}
Aggregations