< prev index next >

src/hotspot/share/runtime/vm_operations.cpp

Print this page
rev 49294 : imported patch 8199813

@@ -415,21 +415,19 @@
   snapshot->set_concurrent_locks(tcl);
   return snapshot;
 }
 
 volatile bool VM_Exit::_vm_exited = false;
-Thread * VM_Exit::_shutdown_thread = NULL;
+Thread * volatile VM_Exit::_shutdown_thread = NULL;
 
 int VM_Exit::set_vm_exited() {
-
   Thread * thr_cur = Thread::current();
-
+  assert(_shutdown_thread == thr_cur, "_shutdown_thread should be current thread");
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
 
   int num_active = 0;
 
-  _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) {
       ++num_active;
       thr->set_terminated(JavaThread::_vm_exited);  // per-thread flag

@@ -500,10 +498,15 @@
   // native==>Java/VM barriers.
   // Among 16276 JCK tests, 94% of them come here without any threads still
   // running in native; the other 6% are quiescent within 250ms (Ultra 80).
   wait_for_threads_in_native_to_block();
 
+  // Remember the Thread that is shutting down the VM because it needs
+  // to be immune to some of the sanity checks and policies that have
+  // to happen at VM shutdown time.
+  VM_Exit::set_shutdown_thread(Thread::current());
+
   set_vm_exited();
 
   // cleanup globals resources before exiting. exit_globals() currently
   // cleans up outputStream resources and PerfMemory resources.
   exit_globals();
< prev index next >