4239 before_exit(thread);
4240
4241 thread->exit(true);
4242
4243 // Stop VM thread.
4244 {
4245 // 4945125 The vm thread comes to a safepoint during exit.
4246 // GC vm_operations can get caught at the safepoint, and the
4247 // heap is unparseable if they are caught. Grab the Heap_lock
4248 // to prevent this. The GC vm_operations will not be able to
4249 // queue until after the vm thread is dead. After this point,
4250 // we'll never emerge out of the safepoint before the VM exits.
4251
4252 MutexLocker ml(Heap_lock);
4253
4254 VMThread::wait_for_vm_thread_exit();
4255 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
4256 VMThread::destroy();
4257 }
4258
4259 // Remember the Thread that is shutting down the VM because it needs
4260 // to be immune to some of the sanity checks and policies that have
4261 // to happen at VM shutdown time.
4262 VM_Exit::set_shutdown_thread(thread);
4263
4264 // Clean up ideal graph printers after the VMThread has started
4265 // the final safepoint which will block all the Compiler threads.
4266 #if defined(COMPILER2) && !defined(PRODUCT)
4267 IdealGraphPrinter::clean_up();
4268 #endif
4269
4270 // Now, all Java threads are gone except daemon threads. Daemon threads
4271 // running Java code or in VM are stopped by the Safepoint. However,
4272 // daemon threads executing native code are still running. But they
4273 // will be stopped at native=>Java/VM barriers. Note that we can't
4274 // simply kill or suspend them, as it is inherently deadlock-prone.
4275
4276 VM_Exit::set_vm_exited();
4277
4278 notify_vm_shutdown();
4279
4280 // We are after VM_Exit::set_vm_exited() so we can't call
4281 // thread->smr_delete() or we will block on the Threads_lock.
4282 // Deleting the shutdown thread here is safe because another
4283 // JavaThread cannot have an active ThreadsListHandle for
4284 // this JavaThread.
4285 delete thread;
4286
4287 #if INCLUDE_JVMCI
4288 if (JVMCICounterSize > 0) {
4289 FREE_C_HEAP_ARRAY(jlong, JavaThread::_jvmci_old_thread_counters);
4290 }
4291 #endif
4292
4293 // exit_globals() will delete tty
4294 exit_globals();
4295
4296 LogConfiguration::finalize();
4297
|
4239 before_exit(thread);
4240
4241 thread->exit(true);
4242
4243 // Stop VM thread.
4244 {
4245 // 4945125 The vm thread comes to a safepoint during exit.
4246 // GC vm_operations can get caught at the safepoint, and the
4247 // heap is unparseable if they are caught. Grab the Heap_lock
4248 // to prevent this. The GC vm_operations will not be able to
4249 // queue until after the vm thread is dead. After this point,
4250 // we'll never emerge out of the safepoint before the VM exits.
4251
4252 MutexLocker ml(Heap_lock);
4253
4254 VMThread::wait_for_vm_thread_exit();
4255 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
4256 VMThread::destroy();
4257 }
4258
4259 // Now, all Java threads are gone except daemon threads. Daemon threads
4260 // running Java code or in VM are stopped by the Safepoint. However,
4261 // daemon threads executing native code are still running. But they
4262 // will be stopped at native=>Java/VM barriers. Note that we can't
4263 // simply kill or suspend them, as it is inherently deadlock-prone.
4264
4265 VM_Exit::set_vm_exited();
4266
4267 // Clean up ideal graph printers after the VMThread has started
4268 // the final safepoint which will block all the Compiler threads.
4269 // Note that this Thread has already logically exited so the
4270 // clean_up() function's use of a JavaThreadIteratorWithHandle
4271 // would be a problem except set_vm_exited() has remembered the
4272 // shutdown thread which is granted a policy exception.
4273 #if defined(COMPILER2) && !defined(PRODUCT)
4274 IdealGraphPrinter::clean_up();
4275 #endif
4276
4277 notify_vm_shutdown();
4278
4279 // We are after VM_Exit::set_vm_exited() so we can't call
4280 // thread->smr_delete() or we will block on the Threads_lock.
4281 // Deleting the shutdown thread here is safe because another
4282 // JavaThread cannot have an active ThreadsListHandle for
4283 // this JavaThread.
4284 delete thread;
4285
4286 #if INCLUDE_JVMCI
4287 if (JVMCICounterSize > 0) {
4288 FREE_C_HEAP_ARRAY(jlong, JavaThread::_jvmci_old_thread_counters);
4289 }
4290 #endif
4291
4292 // exit_globals() will delete tty
4293 exit_globals();
4294
4295 LogConfiguration::finalize();
4296
|