3966 { |
3966 { |
3967 // 4945125 The vm thread comes to a safepoint during exit. |
3967 // 4945125 The vm thread comes to a safepoint during exit. |
3968 // GC vm_operations can get caught at the safepoint, and the |
3968 // GC vm_operations can get caught at the safepoint, and the |
3969 // heap is unparseable if they are caught. Grab the Heap_lock |
3969 // heap is unparseable if they are caught. Grab the Heap_lock |
3970 // to prevent this. The GC vm_operations will not be able to |
3970 // to prevent this. The GC vm_operations will not be able to |
3971 // queue until after the vm thread is dead. |
3971 // queue until after the vm thread is dead. After this point, |
3972 // After this point, we'll never emerge out of the safepoint before |
3972 // we'll never emerge out of the safepoint before the VM exits. |
3973 // the VM exits, so concurrent GC threads do not need to be explicitly |
|
3974 // stopped; they remain inactive until the process exits. |
|
3975 // Note: some concurrent G1 threads may be running during a safepoint, |
|
3976 // but these will not be accessing the heap, just some G1-specific side |
|
3977 // data structures that are not accessed by any other threads but them |
|
3978 // after this point in a terminal safepoint. |
|
3979 |
3973 |
3980 MutexLocker ml(Heap_lock); |
3974 MutexLocker ml(Heap_lock); |
3981 |
3975 |
3982 VMThread::wait_for_vm_thread_exit(); |
3976 VMThread::wait_for_vm_thread_exit(); |
3983 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint"); |
3977 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint"); |