src/share/vm/runtime/thread.cpp

Print this page
rev 6443 : 8040807: G1: Enable G1CollectedHeap::stop()
Reviewed-by: TBD


3949   if (JDK_Version::is_jdk12x_version()) {
3950     // We are the last thread running, so check if finalizers should be run.
3951     // For 1.3 or later this is done in thread->invoke_shutdown_hooks()
3952     HandleMark rm(thread);
3953     Universe::run_finalizers_on_exit();
3954   } else {
3955     // run Java level shutdown hooks
3956     thread->invoke_shutdown_hooks();
3957   }
3958 
3959   before_exit(thread);
3960 
3961   thread->exit(true);
3962 
3963   // Stop VM thread.
3964   {
3965     // 4945125 The vm thread comes to a safepoint during exit.
3966     // GC vm_operations can get caught at the safepoint, and the
3967     // heap is unparseable if they are caught. Grab the Heap_lock
3968     // to prevent this. The GC vm_operations will not be able to
3969     // queue until after the vm thread is dead.
3970     // After this point, we'll never emerge out of the safepoint before
3971     // the VM exits, so concurrent GC threads do not need to be explicitly
3972     // stopped; they remain inactive until the process exits.
3973     // Note: some concurrent G1 threads may be running during a safepoint,
3974     // but these will not be accessing the heap, just some G1-specific side
3975     // data structures that are not accessed by any other threads but them
3976     // after this point in a terminal safepoint.
3977 
3978     MutexLocker ml(Heap_lock);
3979 
3980     VMThread::wait_for_vm_thread_exit();
3981     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3982     VMThread::destroy();
3983   }
3984 
3985   // clean up ideal graph printers
3986 #if defined(COMPILER2) && !defined(PRODUCT)
3987   IdealGraphPrinter::clean_up();
3988 #endif
3989 
3990   // Now, all Java threads are gone except daemon threads. Daemon threads
3991   // running Java code or in VM are stopped by the Safepoint. However,
3992   // daemon threads executing native code are still running.  But they
3993   // will be stopped at native=>Java/VM barriers. Note that we can't
3994   // simply kill or suspend them, as it is inherently deadlock-prone.
3995 
3996 #ifndef PRODUCT




3949   if (JDK_Version::is_jdk12x_version()) {
3950     // We are the last thread running, so check if finalizers should be run.
3951     // For 1.3 or later this is done in thread->invoke_shutdown_hooks()
3952     HandleMark rm(thread);
3953     Universe::run_finalizers_on_exit();
3954   } else {
3955     // run Java level shutdown hooks
3956     thread->invoke_shutdown_hooks();
3957   }
3958 
3959   before_exit(thread);
3960 
3961   thread->exit(true);
3962 
3963   // Stop VM thread.
3964   {
3965     // 4945125 The vm thread comes to a safepoint during exit.
3966     // GC vm_operations can get caught at the safepoint, and the
3967     // heap is unparseable if they are caught. Grab the Heap_lock
3968     // to prevent this. The GC vm_operations will not be able to
3969     // queue until after the vm thread is dead. After this point,
3970     // we'll never emerge out of the safepoint before the VM exits.






3971 
3972     MutexLocker ml(Heap_lock);
3973 
3974     VMThread::wait_for_vm_thread_exit();
3975     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3976     VMThread::destroy();
3977   }
3978 
3979   // clean up ideal graph printers
3980 #if defined(COMPILER2) && !defined(PRODUCT)
3981   IdealGraphPrinter::clean_up();
3982 #endif
3983 
3984   // Now, all Java threads are gone except daemon threads. Daemon threads
3985   // running Java code or in VM are stopped by the Safepoint. However,
3986   // daemon threads executing native code are still running.  But they
3987   // will be stopped at native=>Java/VM barriers. Note that we can't
3988   // simply kill or suspend them, as it is inherently deadlock-prone.
3989 
3990 #ifndef PRODUCT