@@ -63,10 +63,16 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion*
63
63
} else {
64
64
assert (MarkSweepDeadRatio > 0 ,
65
65
" only skip compaction for other regions when MarkSweepDeadRatio > 0" );
66
-
67
66
// Force the high live ratio region as compacting to skip these regions in the
68
67
// later compaction step.
69
68
force_not_compacted = true ;
69
+ if (hr->is_young ()) {
70
+ // G1 updates the BOT for old region contents incrementally, but young regions
71
+ // lack BOT information for performance reasons.
72
+ // Recreate BOT information of high live ratio young regions here to keep expected
73
+ // performance during scanning their card tables in the collection pauses later.
74
+ update_bot (hr);
75
+ }
70
76
log_debug (gc, phases)(" Phase 2: skip compaction region index: %u, live words: " SIZE_FORMAT,
71
77
hr->hrm_index (), _collector->live_words (hr->hrm_index ()));
72
78
}
@@ -157,6 +163,22 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::should_compact(HeapRegion*
157
163
return live_words <= live_words_threshold;
158
164
}
159
165
166
+ void G1FullGCPrepareTask::G1CalculatePointersClosure::update_bot (HeapRegion* hr) {
167
+ HeapWord* const limit = hr->top ();
168
+ HeapWord* next_addr = hr->bottom ();
169
+ HeapWord* threshold = hr->initialize_threshold ();
170
+ HeapWord* prev_addr;
171
+ while (next_addr < limit) {
172
+ prev_addr = next_addr;
173
+ next_addr = _bitmap->get_next_marked_addr (next_addr + 1 , limit);
174
+
175
+ if (next_addr > threshold) {
176
+ threshold = hr->cross_threshold (prev_addr, next_addr);
177
+ }
178
+ }
179
+ assert (next_addr == limit, " Should stop the scan at the limit." );
180
+ }
181
+
160
182
void G1FullGCPrepareTask::G1CalculatePointersClosure::reset_region_metadata (HeapRegion* hr) {
161
183
hr->rem_set ()->clear ();
162
184
hr->clear_cardtable ();
0 commit comments