< prev index next >

src/share/vm/runtime/vmThread.cpp

Print this page




 269   // 6295565  This has the effect of waiting for any large tty
 270   // outputs to finish.
 271   if (xtty != NULL) {
 272     ttyLocker ttyl;
 273     xtty->begin_elem("destroy_vm");
 274     xtty->stamp();
 275     xtty->end_elem();
 276     assert(should_terminate(), "termination flag must be set");
 277   }
 278 
 279   // 4526887 let VM thread exit at Safepoint
 280   SafepointSynchronize::begin();
 281 
 282   if (VerifyBeforeExit) {
 283     HandleMark hm(VMThread::vm_thread());
 284     // Among other things, this ensures that Eden top is correct.
 285     Universe::heap()->prepare_for_verify();
 286     os::check_heap();
 287     // Silent verification so as not to pollute normal output,
 288     // unless we really asked for it.
 289     Universe::verify(!(PrintGCDetails || Verbose) || VerifySilently);
 290   }
 291 
 292   CompileBroker::set_should_block();
 293 
 294   // wait for threads (compiler threads or daemon threads) in the
 295   // _thread_in_native state to block.
 296   VM_Exit::wait_for_threads_in_native_to_block();
 297 
 298   // signal other threads that VM process is gone
 299   {
 300     // Note: we must have the _no_safepoint_check_flag. Mutex::lock() allows
 301     // VM thread to enter any lock at Safepoint as long as its _owner is NULL.
 302     // If that happens after _terminate_lock->wait() has unset _owner
 303     // but before it actually drops the lock and waits, the notification below
 304     // may get lost and we will have a hang. To avoid this, we need to use
 305     // Mutex::lock_without_safepoint_check().
 306     MutexLockerEx ml(_terminate_lock, Mutex::_no_safepoint_check_flag);
 307     _terminated = true;
 308     _terminate_lock->notify();
 309   }




 269   // 6295565  This has the effect of waiting for any large tty
 270   // outputs to finish.
 271   if (xtty != NULL) {
 272     ttyLocker ttyl;
 273     xtty->begin_elem("destroy_vm");
 274     xtty->stamp();
 275     xtty->end_elem();
 276     assert(should_terminate(), "termination flag must be set");
 277   }
 278 
 279   // 4526887 let VM thread exit at Safepoint
 280   SafepointSynchronize::begin();
 281 
 282   if (VerifyBeforeExit) {
 283     HandleMark hm(VMThread::vm_thread());
 284     // Among other things, this ensures that Eden top is correct.
 285     Universe::heap()->prepare_for_verify();
 286     os::check_heap();
 287     // Silent verification so as not to pollute normal output,
 288     // unless we really asked for it.
 289     Universe::verify();
 290   }
 291 
 292   CompileBroker::set_should_block();
 293 
 294   // wait for threads (compiler threads or daemon threads) in the
 295   // _thread_in_native state to block.
 296   VM_Exit::wait_for_threads_in_native_to_block();
 297 
 298   // signal other threads that VM process is gone
 299   {
 300     // Note: we must have the _no_safepoint_check_flag. Mutex::lock() allows
 301     // VM thread to enter any lock at Safepoint as long as its _owner is NULL.
 302     // If that happens after _terminate_lock->wait() has unset _owner
 303     // but before it actually drops the lock and waits, the notification below
 304     // may get lost and we will have a hang. To avoid this, we need to use
 305     // Mutex::lock_without_safepoint_check().
 306     MutexLockerEx ml(_terminate_lock, Mutex::_no_safepoint_check_flag);
 307     _terminated = true;
 308     _terminate_lock->notify();
 309   }


< prev index next >