@@ -475,29 +475,18 @@ void G1ConcurrentMark::reset() {
475
475
_root_regions.reset ();
476
476
}
477
477
478
- void G1ConcurrentMark::clear_statistics_in_region (uint region_idx) {
478
+ void G1ConcurrentMark::clear_statistics (HeapRegion* r) {
479
+ uint region_idx = r->hrm_index ();
479
480
for (uint j = 0 ; j < _max_num_tasks; ++j) {
480
481
_tasks[j]->clear_mark_stats_cache (region_idx);
481
482
}
482
483
_top_at_rebuild_starts[region_idx] = NULL ;
483
484
_region_mark_stats[region_idx].clear ();
484
485
}
485
486
486
- void G1ConcurrentMark::clear_statistics (HeapRegion* r) {
487
- uint const region_idx = r->hrm_index ();
488
- if (r->is_humongous ()) {
489
- assert (r->is_starts_humongous (), " Got humongous continues region here" );
490
- uint const size_in_regions = (uint )_g1h->humongous_obj_size_in_regions (cast_to_oop (r->humongous_start_region ()->bottom ())->size ());
491
- for (uint j = region_idx; j < (region_idx + size_in_regions); j++) {
492
- clear_statistics_in_region (j);
493
- }
494
- } else {
495
- clear_statistics_in_region (region_idx);
496
- }
497
- }
498
-
499
487
void G1ConcurrentMark::humongous_object_eagerly_reclaimed (HeapRegion* r) {
500
488
assert_at_safepoint ();
489
+ assert (r->is_starts_humongous (), " Got humongous continues region here" );
501
490
502
491
// Need to clear mark bit of the humongous object. Doing this unconditionally is fine.
503
492
mark_bitmap ()->clear (r->bottom ());
@@ -507,7 +496,10 @@ void G1ConcurrentMark::humongous_object_eagerly_reclaimed(HeapRegion* r) {
507
496
}
508
497
509
498
// Clear any statistics about the region gathered so far.
510
- clear_statistics (r);
499
+ _g1h->humongous_obj_regions_iterate (r,
500
+ [&] (HeapRegion* r) {
501
+ clear_statistics (r);
502
+ });
511
503
}
512
504
513
505
void G1ConcurrentMark::reset_marking_for_restart () {
@@ -1124,29 +1116,27 @@ class G1UpdateRemSetTrackingBeforeRebuildTask : public WorkerTask {
1124
1116
// Distribute the given marked bytes across the humongous object starting
1125
1117
// with hr and note end of marking for these regions.
1126
1118
void distribute_marked_bytes (HeapRegion* hr, size_t marked_bytes) {
1127
- uint const region_idx = hr->hrm_index ();
1128
-
1129
1119
size_t const obj_size_in_words = cast_to_oop (hr->bottom ())->size ();
1130
- uint const num_regions_in_humongous = (uint )G1CollectedHeap::humongous_obj_size_in_regions (obj_size_in_words);
1131
1120
1132
1121
// "Distributing" zero words means that we only note end of marking for these
1133
1122
// regions.
1134
1123
assert (marked_bytes == 0 || obj_size_in_words * HeapWordSize == marked_bytes,
1135
1124
" Marked bytes should either be 0 or the same as humongous object (%zu) but is %zu" ,
1136
1125
obj_size_in_words * HeapWordSize, marked_bytes);
1137
1126
1138
- for (uint i = region_idx; i < (region_idx + num_regions_in_humongous); i++) {
1139
- HeapRegion* const r = _g1h->region_at (i);
1127
+ auto distribute_bytes = [&] (HeapRegion* r) {
1140
1128
size_t const bytes_to_add = MIN2 (HeapRegion::GrainBytes, marked_bytes);
1141
1129
1142
1130
log_trace (gc, marking)(" Adding %zu bytes to humongous region %u (%s)" ,
1143
- bytes_to_add, i , r->get_type_str ());
1131
+ bytes_to_add, r-> hrm_index () , r->get_type_str ());
1144
1132
add_marked_bytes_and_note_end (r, bytes_to_add);
1145
1133
marked_bytes -= bytes_to_add;
1146
- }
1134
+ };
1135
+ _g1h->humongous_obj_regions_iterate (hr, distribute_bytes);
1136
+
1147
1137
assert (marked_bytes == 0 ,
1148
- " %zu bytes left after distributing space across %u regions" ,
1149
- marked_bytes, num_regions_in_humongous );
1138
+ " %zu bytes left after distributing space across %zu regions" ,
1139
+ marked_bytes, G1CollectedHeap::humongous_obj_size_in_regions (obj_size_in_words) );
1150
1140
}
1151
1141
1152
1142
void update_marked_bytes (HeapRegion* hr) {
@@ -1369,7 +1359,7 @@ class G1ReclaimEmptyRegionsTask : public WorkerTask {
1369
1359
_g1h->free_region (hr, _local_cleanup_list);
1370
1360
}
1371
1361
hr->clear_cardtable ();
1372
- _g1h->concurrent_mark ()->clear_statistics_in_region (hr-> hrm_index () );
1362
+ _g1h->concurrent_mark ()->clear_statistics (hr);
1373
1363
}
1374
1364
1375
1365
return false ;
0 commit comments