< prev index next >

src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp

Print this page




 273 
 274 void VM_GenCollectFullConcurrent::doit_epilogue() {
 275   Thread* thr = Thread::current();
 276   assert(thr->is_Java_thread(), "just checking");
 277   JavaThread* jt = (JavaThread*)thr;
 278   // Release the Heap_lock first.
 279   Heap_lock->unlock();
 280   release_and_notify_pending_list_lock();
 281 
 282   // It is fine to test whether completed collections has
 283   // exceeded our request count without locking because
 284   // the completion count is monotonically increasing;
 285   // this will break for very long-running apps when the
 286   // count overflows and wraps around. XXX fix me !!!
 287   // e.g. at the rate of 1 full gc per ms, this could
 288   // overflow in about 1000 years.
 289   GenCollectedHeap* gch = GenCollectedHeap::heap();
 290   if (_gc_cause != GCCause::_gc_locker &&
 291       gch->total_full_collections_completed() <= _full_gc_count_before) {
 292     // maybe we should change the condition to test _gc_cause ==
 293     // GCCause::_java_lang_system_gc, instead of
 294     // _gc_cause != GCCause::_gc_locker
 295     assert(_gc_cause == GCCause::_java_lang_system_gc,
 296            "the only way to get here if this was a System.gc()-induced GC");
 297     assert(ExplicitGCInvokesConcurrent, "Error");
 298     // Now, wait for witnessing concurrent gc cycle to complete,
 299     // but do so in native mode, because we want to lock the
 300     // FullGCEvent_lock, which may be needed by the VM thread
 301     // or by the CMS thread, so we do not want to be suspended
 302     // while holding that lock.
 303     ThreadToNativeFromVM native(jt);
 304     MutexLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
 305     // Either a concurrent or a stop-world full gc is sufficient
 306     // witness to our request.
 307     while (gch->total_full_collections_completed() <= _full_gc_count_before) {
 308       FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
 309     }
 310   }
 311   // Enable iCMS back if we disabled it earlier.
 312   if (_disabled_icms) {
 313     CMSCollector::enable_icms();
 314   }
 315 }


 273 
 274 void VM_GenCollectFullConcurrent::doit_epilogue() {
 275   Thread* thr = Thread::current();
 276   assert(thr->is_Java_thread(), "just checking");
 277   JavaThread* jt = (JavaThread*)thr;
 278   // Release the Heap_lock first.
 279   Heap_lock->unlock();
 280   release_and_notify_pending_list_lock();
 281 
 282   // It is fine to test whether completed collections has
 283   // exceeded our request count without locking because
 284   // the completion count is monotonically increasing;
 285   // this will break for very long-running apps when the
 286   // count overflows and wraps around. XXX fix me !!!
 287   // e.g. at the rate of 1 full gc per ms, this could
 288   // overflow in about 1000 years.
 289   GenCollectedHeap* gch = GenCollectedHeap::heap();
 290   if (_gc_cause != GCCause::_gc_locker &&
 291       gch->total_full_collections_completed() <= _full_gc_count_before) {
 292     // maybe we should change the condition to test _gc_cause ==
 293     // GCCause::_java_lang_system_gc or GCCause::_dcmd_gc_run,
 294     // instead of _gc_cause != GCCause::_gc_locker
 295     assert(GCCause::is_user_requested_gc(_gc_cause),
 296            "the only way to get here if this was a System.gc()-induced GC");
 297     assert(ExplicitGCInvokesConcurrent, "Error");
 298     // Now, wait for witnessing concurrent gc cycle to complete,
 299     // but do so in native mode, because we want to lock the
 300     // FullGCEvent_lock, which may be needed by the VM thread
 301     // or by the CMS thread, so we do not want to be suspended
 302     // while holding that lock.
 303     ThreadToNativeFromVM native(jt);
 304     MutexLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
 305     // Either a concurrent or a stop-world full gc is sufficient
 306     // witness to our request.
 307     while (gch->total_full_collections_completed() <= _full_gc_count_before) {
 308       FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
 309     }
 310   }
 311   // Enable iCMS back if we disabled it earlier.
 312   if (_disabled_icms) {
 313     CMSCollector::enable_icms();
 314   }
 315 }
< prev index next >