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