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