mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-30 04:58:25 +00:00
8289003: JavaThread::check_is_terminated() implementation should rely on Thread-SMR
Reviewed-by: dholmes, pchilanomate
This commit is contained in:
parent
2342684f2c
commit
441c33f0b1
@ -564,9 +564,10 @@ bool JavaThread::is_interrupted(bool clear_interrupted) {
|
||||
void JavaThread::block_if_vm_exited() {
|
||||
if (_terminated == _vm_exited) {
|
||||
// _vm_exited is set at safepoint, and Threads_lock is never released
|
||||
// we will block here forever.
|
||||
// so we will block here forever.
|
||||
// Here we can be doing a jump from a safe state to an unsafe state without
|
||||
// proper transition, but it happens after the final safepoint has begun.
|
||||
// proper transition, but it happens after the final safepoint has begun so
|
||||
// this jump won't cause any safepoint problems.
|
||||
set_thread_state(_thread_in_vm);
|
||||
Threads_lock->lock();
|
||||
ShouldNotReachHere();
|
||||
|
||||
@ -567,12 +567,10 @@ private:
|
||||
bool is_exiting() const;
|
||||
// thread's GC barrier is NOT detached and thread is NOT terminated
|
||||
bool is_oop_safe() const;
|
||||
// thread is terminated (no longer on the threads list); we compare
|
||||
// against the three non-terminated values so that a freed JavaThread
|
||||
// will also be considered terminated.
|
||||
// thread is terminated (no longer on the threads list); the thread must
|
||||
// be protected by a ThreadsListHandle to avoid potential crashes.
|
||||
bool check_is_terminated(TerminatedTypes l_terminated) const {
|
||||
return l_terminated != _not_terminated && l_terminated != _thread_exiting &&
|
||||
l_terminated != _thread_gc_barrier_detached;
|
||||
return l_terminated == _thread_terminated || l_terminated == _vm_exited;
|
||||
}
|
||||
bool is_terminated() const;
|
||||
void set_terminated(TerminatedTypes t);
|
||||
|
||||
@ -367,7 +367,7 @@ int VM_Exit::set_vm_exited() {
|
||||
_shutdown_thread = thr_cur;
|
||||
_vm_exited = true; // global flag
|
||||
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thr = jtiwh.next(); ) {
|
||||
if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
|
||||
if (thr != thr_cur && thr->thread_state() == _thread_in_native) {
|
||||
++num_active;
|
||||
thr->set_terminated(JavaThread::_vm_exited); // per-thread flag
|
||||
}
|
||||
@ -495,7 +495,7 @@ void VM_Exit::wait_if_vm_exited() {
|
||||
if (_vm_exited &&
|
||||
Thread::current_or_null() != _shutdown_thread) {
|
||||
// _vm_exited is set at safepoint, and the Threads_lock is never released
|
||||
// we will block here until the process dies
|
||||
// so we will block here until the process dies.
|
||||
Threads_lock->lock();
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user