4234 }
4235
4236 EventShutdown e;
4237 if (e.should_commit()) {
4238 e.set_reason("No remaining non-daemon Java threads");
4239 e.commit();
4240 }
4241
4242 // Hang forever on exit if we are reporting an error.
4243 if (ShowMessageBoxOnError && VMError::is_error_reported()) {
4244 os::infinite_sleep();
4245 }
4246 os::wait_for_keypress_at_exit();
4247
4248 // run Java level shutdown hooks
4249 thread->invoke_shutdown_hooks();
4250
4251 before_exit(thread);
4252
4253 thread->exit(true);
4254 // thread will never call smr_delete, instead of implicit cancel
4255 // in wait_for_vm_thread_exit we do it explicit.
4256 thread->cancel_handshake();
4257
4258 // Stop VM thread.
4259 {
4260 // 4945125 The vm thread comes to a safepoint during exit.
4261 // GC vm_operations can get caught at the safepoint, and the
4262 // heap is unparseable if they are caught. Grab the Heap_lock
4263 // to prevent this. The GC vm_operations will not be able to
4264 // queue until after the vm thread is dead. After this point,
4265 // we'll never emerge out of the safepoint before the VM exits.
4266
4267 MutexLocker ml(Heap_lock);
4268
4269 VMThread::wait_for_vm_thread_exit();
4270 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
4271 VMThread::destroy();
4272 }
4273
4274 // Now, all Java threads are gone except daemon threads. Daemon threads
4275 // running Java code or in VM are stopped by the Safepoint. However,
4276 // daemon threads executing native code are still running. But they
|
4234 }
4235
4236 EventShutdown e;
4237 if (e.should_commit()) {
4238 e.set_reason("No remaining non-daemon Java threads");
4239 e.commit();
4240 }
4241
4242 // Hang forever on exit if we are reporting an error.
4243 if (ShowMessageBoxOnError && VMError::is_error_reported()) {
4244 os::infinite_sleep();
4245 }
4246 os::wait_for_keypress_at_exit();
4247
4248 // run Java level shutdown hooks
4249 thread->invoke_shutdown_hooks();
4250
4251 before_exit(thread);
4252
4253 thread->exit(true);
4254
4255 // Stop VM thread.
4256 {
4257 // 4945125 The vm thread comes to a safepoint during exit.
4258 // GC vm_operations can get caught at the safepoint, and the
4259 // heap is unparseable if they are caught. Grab the Heap_lock
4260 // to prevent this. The GC vm_operations will not be able to
4261 // queue until after the vm thread is dead. After this point,
4262 // we'll never emerge out of the safepoint before the VM exits.
4263
4264 MutexLocker ml(Heap_lock);
4265
4266 VMThread::wait_for_vm_thread_exit();
4267 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
4268 VMThread::destroy();
4269 }
4270
4271 // Now, all Java threads are gone except daemon threads. Daemon threads
4272 // running Java code or in VM are stopped by the Safepoint. However,
4273 // daemon threads executing native code are still running. But they
|