hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp
changeset 36084 9a3bf78e9a76
parent 35943 e726308008c0
child 36191 07d2ba48d1d3
equal deleted inserted replaced
35949:02676622ca27 36084:9a3bf78e9a76
   370   assert(res == NULL || res->is_survivor(), "post-condition");
   370   assert(res == NULL || res->is_survivor(), "post-condition");
   371 
   371 
   372   return res;
   372   return res;
   373 }
   373 }
   374 
   374 
       
   375 void G1CMRootRegions::notify_scan_done() {
       
   376   MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag);
       
   377   _scan_in_progress = false;
       
   378   RootRegionScan_lock->notify_all();
       
   379 }
       
   380 
       
   381 void G1CMRootRegions::cancel_scan() {
       
   382   notify_scan_done();
       
   383 }
       
   384 
   375 void G1CMRootRegions::scan_finished() {
   385 void G1CMRootRegions::scan_finished() {
   376   assert(scan_in_progress(), "pre-condition");
   386   assert(scan_in_progress(), "pre-condition");
   377 
   387 
   378   // Currently, only survivors can be root regions.
   388   // Currently, only survivors can be root regions.
   379   if (!_should_abort) {
   389   if (!_should_abort) {
   380     assert(_next_survivor == NULL, "we should have claimed all survivors");
   390     assert(_next_survivor == NULL, "we should have claimed all survivors");
   381   }
   391   }
   382   _next_survivor = NULL;
   392   _next_survivor = NULL;
   383 
   393 
   384   {
   394   notify_scan_done();
   385     MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag);
       
   386     _scan_in_progress = false;
       
   387     RootRegionScan_lock->notify_all();
       
   388   }
       
   389 }
   395 }
   390 
   396 
   391 bool G1CMRootRegions::wait_until_scan_finished() {
   397 bool G1CMRootRegions::wait_until_scan_finished() {
   392   if (!scan_in_progress()) return false;
   398   if (!scan_in_progress()) return false;
   393 
   399 
   976     }
   982     }
   977   }
   983   }
   978 };
   984 };
   979 
   985 
   980 void G1ConcurrentMark::scanRootRegions() {
   986 void G1ConcurrentMark::scanRootRegions() {
   981   // Start of concurrent marking.
       
   982   ClassLoaderDataGraph::clear_claimed_marks();
       
   983 
       
   984   // scan_in_progress() will have been set to true only if there was
   987   // scan_in_progress() will have been set to true only if there was
   985   // at least one root region to scan. So, if it's false, we
   988   // at least one root region to scan. So, if it's false, we
   986   // should not attempt to do any further work.
   989   // should not attempt to do any further work.
   987   if (root_regions()->scan_in_progress()) {
   990   if (root_regions()->scan_in_progress()) {
       
   991     assert(!has_aborted(), "Aborting before root region scanning is finished not supported.");
   988     GCTraceConcTime(Info, gc) tt("Concurrent Root Region Scan");
   992     GCTraceConcTime(Info, gc) tt("Concurrent Root Region Scan");
   989 
   993 
   990     _parallel_marking_threads = calc_parallel_marking_threads();
   994     _parallel_marking_threads = calc_parallel_marking_threads();
   991     assert(parallel_marking_threads() <= max_parallel_marking_threads(),
   995     assert(parallel_marking_threads() <= max_parallel_marking_threads(),
   992            "Maximum number of marking threads exceeded");
   996            "Maximum number of marking threads exceeded");