237 238 void VM_GenCollectFullConcurrent::doit_epilogue() { 239 Thread* thr = Thread::current(); 240 assert(thr->is_Java_thread(), "just checking"); 241 JavaThread* jt = (JavaThread*)thr; 242 // Release the Heap_lock first. 243 Heap_lock->unlock(); 244 release_and_notify_pending_list_lock(); 245 246 // It is fine to test whether completed collections has 247 // exceeded our request count without locking because 248 // the completion count is monotonically increasing; 249 // this will break for very long-running apps when the 250 // count overflows and wraps around. XXX fix me !!! 251 // e.g. at the rate of 1 full gc per ms, this could 252 // overflow in about 1000 years. 253 GenCollectedHeap* gch = GenCollectedHeap::heap(); 254 if (_gc_cause != GCCause::_gc_locker && 255 gch->total_full_collections_completed() <= _full_gc_count_before) { 256 // maybe we should change the condition to test _gc_cause == 257 // GCCause::_java_lang_system_gc, instead of 258 // _gc_cause != GCCause::_gc_locker 259 assert(_gc_cause == GCCause::_java_lang_system_gc, 260 "the only way to get here if this was a System.gc()-induced GC"); 261 assert(ExplicitGCInvokesConcurrent, "Error"); 262 // Now, wait for witnessing concurrent gc cycle to complete, 263 // but do so in native mode, because we want to lock the 264 // FullGCEvent_lock, which may be needed by the VM thread 265 // or by the CMS thread, so we do not want to be suspended 266 // while holding that lock. 267 ThreadToNativeFromVM native(jt); 268 MutexLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); 269 // Either a concurrent or a stop-world full gc is sufficient 270 // witness to our request. 271 while (gch->total_full_collections_completed() <= _full_gc_count_before) { 272 FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag); 273 } 274 } 275 } | 237 238 void VM_GenCollectFullConcurrent::doit_epilogue() { 239 Thread* thr = Thread::current(); 240 assert(thr->is_Java_thread(), "just checking"); 241 JavaThread* jt = (JavaThread*)thr; 242 // Release the Heap_lock first. 243 Heap_lock->unlock(); 244 release_and_notify_pending_list_lock(); 245 246 // It is fine to test whether completed collections has 247 // exceeded our request count without locking because 248 // the completion count is monotonically increasing; 249 // this will break for very long-running apps when the 250 // count overflows and wraps around. XXX fix me !!! 251 // e.g. at the rate of 1 full gc per ms, this could 252 // overflow in about 1000 years. 253 GenCollectedHeap* gch = GenCollectedHeap::heap(); 254 if (_gc_cause != GCCause::_gc_locker && 255 gch->total_full_collections_completed() <= _full_gc_count_before) { 256 // maybe we should change the condition to test _gc_cause == 257 // GCCause::_java_lang_system_gc or GCCause::_dcmd_gc_run, 258 // instead of _gc_cause != GCCause::_gc_locker 259 assert(GCCause::is_user_requested_gc(_gc_cause), 260 "the only way to get here if this was a System.gc()-induced GC"); 261 assert(ExplicitGCInvokesConcurrent, "Error"); 262 // Now, wait for witnessing concurrent gc cycle to complete, 263 // but do so in native mode, because we want to lock the 264 // FullGCEvent_lock, which may be needed by the VM thread 265 // or by the CMS thread, so we do not want to be suspended 266 // while holding that lock. 267 ThreadToNativeFromVM native(jt); 268 MutexLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); 269 // Either a concurrent or a stop-world full gc is sufficient 270 // witness to our request. 271 while (gch->total_full_collections_completed() <= _full_gc_count_before) { 272 FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag); 273 } 274 } 275 } |