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

Print this page

        

@@ -190,18 +190,22 @@
          (GC_locker::is_active() /* gc may have been skipped */
           && (_gc_count_before == gch->total_collections())),
          "total_collections() should be monotonically increasing");
 
   MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
+  assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
   if (gch->total_full_collections() == _full_gc_count_before) {
-    // Disable iCMS until the full collection is done.
+    // Disable iCMS until the full collection is done, and
+    // remember that we did so.
     CMSCollector::disable_icms();
+    _disabled_icms = true;
     // In case CMS thread was in icms_wait(), wake it up.
     CMSCollector::start_icms();
     // Nudge the CMS thread to start a concurrent collection.
     CMSCollector::request_full_gc(_full_gc_count_before);
   } else {
+    assert(_full_gc_count_before < gch->total_full_collections(), "Error");
     FullGCCount_lock->notify_all();  // Inform the Java thread its work is done
   }
 }
 
 bool VM_GenCollectFullConcurrent::evaluate_at_safepoint() const {

@@ -257,8 +261,10 @@
     // witness to our request.
     while (gch->total_full_collections_completed() <= _full_gc_count_before) {
       FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
     }
   }
-  // Enable iCMS back.
+  // Enable iCMS back if we disabled it earlier.
+  if (_disabled_icms) {
   CMSCollector::enable_icms();
+  }
 }