1162 ConcurrentMark* _cm; 1163 1164 public: 1165 CMRootRegionScanTask(ConcurrentMark* cm) : 1166 AbstractGangTask("Root Region Scan"), _cm(cm) { } 1167 1168 void work(uint worker_id) { 1169 assert(Thread::current()->is_ConcurrentGC_thread(), 1170 "this should only be done by a conc GC thread"); 1171 1172 CMRootRegions* root_regions = _cm->root_regions(); 1173 HeapRegion* hr = root_regions->claim_next(); 1174 while (hr != NULL) { 1175 _cm->scanRootRegion(hr, worker_id); 1176 hr = root_regions->claim_next(); 1177 } 1178 } 1179 }; 1180 1181 void ConcurrentMark::scanRootRegions() { 1182 // Start of concurrent marking. 1183 ClassLoaderDataGraph::clear_claimed_marks(); 1184 1185 // scan_in_progress() will have been set to true only if there was 1186 // at least one root region to scan. So, if it's false, we 1187 // should not attempt to do any further work. 1188 if (root_regions()->scan_in_progress()) { 1189 _parallel_marking_threads = calc_parallel_marking_threads(); 1190 assert(parallel_marking_threads() <= max_parallel_marking_threads(), 1191 "Maximum number of marking threads exceeded"); 1192 uint active_workers = MAX2(1U, parallel_marking_threads()); 1193 1194 CMRootRegionScanTask task(this); 1195 _parallel_workers->set_active_workers(active_workers); 1196 _parallel_workers->run_task(&task); 1197 1198 // It's possible that has_aborted() is true here without actually 1199 // aborting the survivor scan earlier. This is OK as it's 1200 // mainly used for sanity checking. 1201 root_regions()->scan_finished(); 1202 } 1203 } 1204 1205 void ConcurrentMark::markFromRoots() { 1206 // we might be tempted to assert that: 1207 // assert(asynch == !SafepointSynchronize::is_at_safepoint(), 1208 // "inconsistent argument?"); 1209 // However that wouldn't be right, because it's possible that 1210 // a safepoint is indeed in progress as a younger generation 1211 // stop-the-world GC happens even as we mark in this generation. 1212 1213 _restart_for_overflow = false; 1214 force_overflow_conc()->init(); 1215 1216 // _g1h has _n_par_threads | 1162 ConcurrentMark* _cm; 1163 1164 public: 1165 CMRootRegionScanTask(ConcurrentMark* cm) : 1166 AbstractGangTask("Root Region Scan"), _cm(cm) { } 1167 1168 void work(uint worker_id) { 1169 assert(Thread::current()->is_ConcurrentGC_thread(), 1170 "this should only be done by a conc GC thread"); 1171 1172 CMRootRegions* root_regions = _cm->root_regions(); 1173 HeapRegion* hr = root_regions->claim_next(); 1174 while (hr != NULL) { 1175 _cm->scanRootRegion(hr, worker_id); 1176 hr = root_regions->claim_next(); 1177 } 1178 } 1179 }; 1180 1181 void ConcurrentMark::scanRootRegions() { 1182 double scan_start = os::elapsedTime(); 1183 1184 // Start of concurrent marking. 1185 ClassLoaderDataGraph::clear_claimed_marks(); 1186 1187 // scan_in_progress() will have been set to true only if there was 1188 // at least one root region to scan. So, if it's false, we 1189 // should not attempt to do any further work. 1190 if (root_regions()->scan_in_progress()) { 1191 if (G1Log::fine()) { 1192 gclog_or_tty->gclog_stamp(concurrent_gc_id()); 1193 gclog_or_tty->print_cr("[GC concurrent-root-region-scan-start]"); 1194 } 1195 1196 _parallel_marking_threads = calc_parallel_marking_threads(); 1197 assert(parallel_marking_threads() <= max_parallel_marking_threads(), 1198 "Maximum number of marking threads exceeded"); 1199 uint active_workers = MAX2(1U, parallel_marking_threads()); 1200 1201 CMRootRegionScanTask task(this); 1202 _parallel_workers->set_active_workers(active_workers); 1203 _parallel_workers->run_task(&task); 1204 1205 if (G1Log::fine()) { 1206 gclog_or_tty->gclog_stamp(concurrent_gc_id()); 1207 gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]", os::elapsedTime() - scan_start); 1208 } 1209 1210 // It's possible that has_aborted() is true here without actually 1211 // aborting the survivor scan earlier. This is OK as it's 1212 // mainly used for sanity checking. 1213 root_regions()->scan_finished(); 1214 } 1215 } 1216 1217 void ConcurrentMark::markFromRoots() { 1218 // we might be tempted to assert that: 1219 // assert(asynch == !SafepointSynchronize::is_at_safepoint(), 1220 // "inconsistent argument?"); 1221 // However that wouldn't be right, because it's possible that 1222 // a safepoint is indeed in progress as a younger generation 1223 // stop-the-world GC happens even as we mark in this generation. 1224 1225 _restart_for_overflow = false; 1226 force_overflow_conc()->init(); 1227 1228 // _g1h has _n_par_threads |