< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page
rev 49502 : imported patch 8199742-collectorstate-fixes
rev 49504 : imported patch 8151171-renamings
rev 49505 : [mq]: 8151171-stefanj-review
rev 49506 : imported patch 8200234-g1concurrentmark-refactorings
rev 49507 : imported patch 8200234-stefanj-review
rev 49510 : 8200255: Remove G1CMTask::_concurrent
Reviewed-by: sangheki, sjohanss
rev 49511 : 8200074: Remove G1ConcurrentMark::_concurrent_marking_in_progress
Reviewed-by: sjohanss, sangheki
rev 49512 : imported patch 8200305-gc,liveness-output
rev 49513 : [mq]: 8200385-prev-bitmap-marks-left
rev 49514 : [mq]: 8200385-stefanj-review
rev 49515 : imported patch 8178105-switch-at-remark
rev 49516 : [mq]: 8154528-reclaim-at-remark


1115     // We're done with marking.
1116     // This is the end of the marking cycle, we're expected all
1117     // threads to have SATB queues with active set to true.
1118     satb_mq_set.set_active_all_threads(false, /* new active value */
1119                                        true /* expected_active */);
1120 
1121     {
1122       GCTraceTime(Debug, gc, phases)("Flush Task Caches");
1123       flush_all_task_caches();
1124     }
1125 
1126     // Install newly created mark bitmap as "prev".
1127     swap_mark_bitmaps();
1128     {
1129       GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking Before Rebuild");
1130       G1UpdateRemSetTrackingBeforeRebuild cl(_g1h, this);
1131       _g1h->heap_region_iterate(&cl);
1132       log_debug(gc, remset, tracking)("Remembered Set Tracking update regions total %u, selected %u",
1133                                       _g1h->num_regions(), cl.num_selected_for_rebuild());
1134     }












1135 
1136     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark after");
1137 
1138     assert(!restart_for_overflow(), "sanity");
1139     // Completely reset the marking state since marking completed
1140     reset_at_marking_complete();
1141   } else {
1142     // We overflowed.  Restart concurrent marking.
1143     _restart_for_overflow = true;
1144 
1145     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark overflow");
1146 
1147     // Clear the marking state because we will be restarting
1148     // marking due to overflowing the global mark stack.
1149     reset_marking_for_restart();
1150   }
1151 
1152   {
1153     GCTraceTime(Debug, gc, phases)("Report Object Count");
1154     report_object_count(mark_finished);


1253 
1254   G1CleanupTask cl(_g1h, &empty_regions_list, workers->active_workers());
1255   workers->run_task(&cl);
1256 
1257   if (!empty_regions_list.is_empty()) {
1258     log_debug(gc)("Reclaimed %u empty regions", empty_regions_list.length());
1259     // Now print the empty regions list.
1260     G1HRPrinter* hrp = _g1h->hr_printer();
1261     if (hrp->is_active()) {
1262       FreeRegionListIterator iter(&empty_regions_list);
1263       while (iter.more_available()) {
1264         HeapRegion* hr = iter.get_next();
1265         hrp->cleanup(hr);
1266       }
1267     }
1268     // And actually make them available.
1269     _g1h->prepend_to_freelist(&empty_regions_list);
1270   }
1271 }
1272 












1273 void G1ConcurrentMark::cleanup() {
1274   assert_at_safepoint_on_vm_thread();
1275 
1276   // If a full collection has happened, we shouldn't do this.
1277   if (has_aborted()) {
1278     return;
1279   }
1280 
1281   G1Policy* g1p = _g1h->g1_policy();
1282   g1p->record_concurrent_mark_cleanup_start();
1283 
1284   double start = os::elapsedTime();
1285 
1286   verify_during_pause(G1HeapVerifier::G1VerifyCleanup, VerifyOption_G1UsePrevMarking, "Cleanup before");
1287 
1288   {
1289     GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking After Rebuild");
1290     G1UpdateRemSetTrackingAfterRebuild cl(_g1h);
1291     _g1h->heap_region_iterate(&cl);
1292   }
1293 
1294   if (log_is_enabled(Trace, gc, liveness)) {
1295     G1PrintRegionLivenessInfoClosure cl("Post-Cleanup");
1296     _g1h->heap_region_iterate(&cl);
1297   }
1298 
1299   {
1300     GCTraceTime(Debug, gc, phases)("Reclaim Empty Regions");
1301     reclaim_empty_regions();
1302   }
1303 
1304   // Cleanup will have freed any regions completely full of garbage.
1305   // Update the soft reference policy with the new heap occupancy.
1306   Universe::update_heap_info_at_gc();
1307 
1308   // Clean out dead classes and update Metaspace sizes.
1309   if (ClassUnloadingWithConcurrentMark) {
1310     GCTraceTime(Debug, gc, phases)("Purge Metaspace");
1311     ClassLoaderDataGraph::purge();
1312   }
1313   MetaspaceGC::compute_new_size();
1314 
1315   // We reclaimed old regions so we should calculate the sizes to make
1316   // sure we update the old gen/space data.
1317   _g1h->g1mm()->update_sizes();
1318 
1319   verify_during_pause(G1HeapVerifier::G1VerifyCleanup, VerifyOption_G1UsePrevMarking, "Cleanup after");
1320 
1321   // We need to make this be a "collection" so any collection pause that
1322   // races with it goes around and waits for Cleanup to finish.
1323   _g1h->increment_total_collections();
1324 
1325   // Local statistics
1326   double recent_cleanup_time = (os::elapsedTime() - start);
1327   _total_cleanup_time += recent_cleanup_time;
1328   _cleanup_times.add(recent_cleanup_time);
1329 
1330   {
1331     GCTraceTime(Debug, gc, phases)("Finalize Concurrent Mark Cleanup");
1332     _g1h->g1_policy()->record_concurrent_mark_cleanup_end();
1333   }
1334 }
1335 
1336 // Supporting Object and Oop closures for reference discovery
1337 // and processing in during marking




1115     // We're done with marking.
1116     // This is the end of the marking cycle, we're expected all
1117     // threads to have SATB queues with active set to true.
1118     satb_mq_set.set_active_all_threads(false, /* new active value */
1119                                        true /* expected_active */);
1120 
1121     {
1122       GCTraceTime(Debug, gc, phases)("Flush Task Caches");
1123       flush_all_task_caches();
1124     }
1125 
1126     // Install newly created mark bitmap as "prev".
1127     swap_mark_bitmaps();
1128     {
1129       GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking Before Rebuild");
1130       G1UpdateRemSetTrackingBeforeRebuild cl(_g1h, this);
1131       _g1h->heap_region_iterate(&cl);
1132       log_debug(gc, remset, tracking)("Remembered Set Tracking update regions total %u, selected %u",
1133                                       _g1h->num_regions(), cl.num_selected_for_rebuild());
1134     }
1135     {
1136       GCTraceTime(Debug, gc, phases)("Reclaim Empty Regions");
1137       reclaim_empty_regions();
1138     }
1139 
1140     // Clean out dead classes
1141     if (ClassUnloadingWithConcurrentMark) {
1142       GCTraceTime(Debug, gc, phases)("Purge Metaspace");
1143       ClassLoaderDataGraph::purge();
1144     }
1145 
1146     compute_new_sizes();
1147 
1148     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark after");
1149 
1150     assert(!restart_for_overflow(), "sanity");
1151     // Completely reset the marking state since marking completed
1152     reset_at_marking_complete();
1153   } else {
1154     // We overflowed.  Restart concurrent marking.
1155     _restart_for_overflow = true;
1156 
1157     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark overflow");
1158 
1159     // Clear the marking state because we will be restarting
1160     // marking due to overflowing the global mark stack.
1161     reset_marking_for_restart();
1162   }
1163 
1164   {
1165     GCTraceTime(Debug, gc, phases)("Report Object Count");
1166     report_object_count(mark_finished);


1265 
1266   G1CleanupTask cl(_g1h, &empty_regions_list, workers->active_workers());
1267   workers->run_task(&cl);
1268 
1269   if (!empty_regions_list.is_empty()) {
1270     log_debug(gc)("Reclaimed %u empty regions", empty_regions_list.length());
1271     // Now print the empty regions list.
1272     G1HRPrinter* hrp = _g1h->hr_printer();
1273     if (hrp->is_active()) {
1274       FreeRegionListIterator iter(&empty_regions_list);
1275       while (iter.more_available()) {
1276         HeapRegion* hr = iter.get_next();
1277         hrp->cleanup(hr);
1278       }
1279     }
1280     // And actually make them available.
1281     _g1h->prepend_to_freelist(&empty_regions_list);
1282   }
1283 }
1284 
1285 void G1ConcurrentMark::compute_new_sizes() {
1286   MetaspaceGC::compute_new_size();
1287 
1288   // Cleanup will have freed any regions completely full of garbage.
1289   // Update the soft reference policy with the new heap occupancy.
1290   Universe::update_heap_info_at_gc();
1291 
1292   // We reclaimed old regions so we should calculate the sizes to make
1293   // sure we update the old gen/space data.
1294   _g1h->g1mm()->update_sizes();
1295 }
1296 
1297 void G1ConcurrentMark::cleanup() {
1298   assert_at_safepoint_on_vm_thread();
1299 
1300   // If a full collection has happened, we shouldn't do this.
1301   if (has_aborted()) {
1302     return;
1303   }
1304 
1305   G1Policy* g1p = _g1h->g1_policy();
1306   g1p->record_concurrent_mark_cleanup_start();
1307 
1308   double start = os::elapsedTime();
1309 
1310   verify_during_pause(G1HeapVerifier::G1VerifyCleanup, VerifyOption_G1UsePrevMarking, "Cleanup before");
1311 
1312   {
1313     GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking After Rebuild");
1314     G1UpdateRemSetTrackingAfterRebuild cl(_g1h);
1315     _g1h->heap_region_iterate(&cl);
1316   }
1317 
1318   if (log_is_enabled(Trace, gc, liveness)) {
1319     G1PrintRegionLivenessInfoClosure cl("Post-Cleanup");
1320     _g1h->heap_region_iterate(&cl);
1321   }




















1322 
1323   verify_during_pause(G1HeapVerifier::G1VerifyCleanup, VerifyOption_G1UsePrevMarking, "Cleanup after");
1324 
1325   // We need to make this be a "collection" so any collection pause that
1326   // races with it goes around and waits for Cleanup to finish.
1327   _g1h->increment_total_collections();
1328 
1329   // Local statistics
1330   double recent_cleanup_time = (os::elapsedTime() - start);
1331   _total_cleanup_time += recent_cleanup_time;
1332   _cleanup_times.add(recent_cleanup_time);
1333 
1334   {
1335     GCTraceTime(Debug, gc, phases)("Finalize Concurrent Mark Cleanup");
1336     _g1h->g1_policy()->record_concurrent_mark_cleanup_end();
1337   }
1338 }
1339 
1340 // Supporting Object and Oop closures for reference discovery
1341 // and processing in during marking


< prev index next >