Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp
          +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp
↓ open down ↓ 184 lines elided ↑ open up ↑
 185  185      GCCauseSetter gccs(gch, _gc_cause);
 186  186      gch->do_full_collection(gch->must_clear_all_soft_refs(),
 187  187                              0 /* collect only youngest gen */);
 188  188    } // Else no need for a foreground young gc
 189  189    assert((_gc_count_before < gch->total_collections()) ||
 190  190           (GC_locker::is_active() /* gc may have been skipped */
 191  191            && (_gc_count_before == gch->total_collections())),
 192  192           "total_collections() should be monotonically increasing");
 193  193  
 194  194    MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
      195 +  assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
 195  196    if (gch->total_full_collections() == _full_gc_count_before) {
 196      -    // Disable iCMS until the full collection is done.
      197 +    // Disable iCMS until the full collection is done, and
      198 +    // remember that we did so.
 197  199      CMSCollector::disable_icms();
      200 +    _disabled_icms = true;
 198  201      // In case CMS thread was in icms_wait(), wake it up.
 199  202      CMSCollector::start_icms();
 200  203      // Nudge the CMS thread to start a concurrent collection.
 201  204      CMSCollector::request_full_gc(_full_gc_count_before);
 202  205    } else {
      206 +    assert(_full_gc_count_before < gch->total_full_collections(), "Error");
 203  207      FullGCCount_lock->notify_all();  // Inform the Java thread its work is done
 204  208    }
 205  209  }
 206  210  
 207  211  bool VM_GenCollectFullConcurrent::evaluate_at_safepoint() const {
 208  212    Thread* thr = Thread::current();
 209  213    assert(thr != NULL, "Unexpected tid");
 210  214    if (!thr->is_Java_thread()) {
 211  215      assert(thr->is_VM_thread(), "Expected to be evaluated by VM thread");
 212  216      GenCollectedHeap* gch = GenCollectedHeap::heap();
↓ open down ↓ 39 lines elided ↑ open up ↑
 252  256      // or by the CMS thread, so we do not want to be suspended
 253  257      // while holding that lock.
 254  258      ThreadToNativeFromVM native(jt);
 255  259      MutexLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
 256  260      // Either a concurrent or a stop-world full gc is sufficient
 257  261      // witness to our request.
 258  262      while (gch->total_full_collections_completed() <= _full_gc_count_before) {
 259  263        FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
 260  264      }
 261  265    }
 262      -  // Enable iCMS back.
 263      -  CMSCollector::enable_icms();
      266 +  // Enable iCMS back if we disabled it earlier.
      267 +  if (_disabled_icms) {
      268 +    CMSCollector::enable_icms();
      269 +  }
 264  270  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX