231 } while (cur_pos != start_pos);
232 }
233
234 void G1CollectionSet::update_young_region_prediction(HeapRegion* hr,
235 size_t new_rs_length) {
236 // Update the CSet information that is dependent on the new RS length
237 assert(hr->is_young(), "Precondition");
238 assert(!SafepointSynchronize::is_at_safepoint(), "should not be at a safepoint");
239
240 // We could have updated _inc_recorded_rs_length and
241 // _inc_predicted_elapsed_time_ms directly but we'd need to do
242 // that atomically, as this code is executed by a concurrent
243 // refinement thread, potentially concurrently with a mutator thread
244 // allocating a new region and also updating the same fields. To
245 // avoid the atomic operations we accumulate these updates on two
246 // separate fields (*_diff) and we'll just add them to the "main"
247 // fields at the start of a GC.
248
249 size_t old_rs_length = hr->recorded_rs_length();
250 assert(old_rs_length <= new_rs_length,
251 "Remembered set sizes must increase (changed from " SIZE_FORMAT " to " SIZE_FORMAT " region %u type %s)",
252 old_rs_length, new_rs_length, hr->hrm_index(), hr->get_short_type_str());
253 size_t rs_length_diff = new_rs_length - old_rs_length;
254 _inc_recorded_rs_length_diff += rs_length_diff;
255
256 double old_elapsed_time_ms = hr->predicted_elapsed_time_ms();
257 double new_region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
258 double elapsed_ms_diff = new_region_elapsed_time_ms - old_elapsed_time_ms;
259 _inc_predicted_elapsed_time_ms_diff += elapsed_ms_diff;
260
261 hr->set_recorded_rs_length(new_rs_length);
262 hr->set_predicted_elapsed_time_ms(new_region_elapsed_time_ms);
263 }
264
265 void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
266 assert(hr->is_young(), "invariant");
267 assert(_inc_build_state == Active, "Precondition");
268
269 // This routine is used when:
270 // * adding survivor regions to the incremental cset at the end of an
271 // evacuation pause or
|
231 } while (cur_pos != start_pos);
232 }
233
234 void G1CollectionSet::update_young_region_prediction(HeapRegion* hr,
235 size_t new_rs_length) {
236 // Update the CSet information that is dependent on the new RS length
237 assert(hr->is_young(), "Precondition");
238 assert(!SafepointSynchronize::is_at_safepoint(), "should not be at a safepoint");
239
240 // We could have updated _inc_recorded_rs_length and
241 // _inc_predicted_elapsed_time_ms directly but we'd need to do
242 // that atomically, as this code is executed by a concurrent
243 // refinement thread, potentially concurrently with a mutator thread
244 // allocating a new region and also updating the same fields. To
245 // avoid the atomic operations we accumulate these updates on two
246 // separate fields (*_diff) and we'll just add them to the "main"
247 // fields at the start of a GC.
248
249 size_t old_rs_length = hr->recorded_rs_length();
250 assert(old_rs_length <= new_rs_length,
251 "Remembered set decreased (changed from " SIZE_FORMAT " to " SIZE_FORMAT " region %u type %s)",
252 old_rs_length, new_rs_length, hr->hrm_index(), hr->get_short_type_str());
253 size_t rs_length_diff = new_rs_length - old_rs_length;
254 _inc_recorded_rs_length_diff += rs_length_diff;
255
256 double old_elapsed_time_ms = hr->predicted_elapsed_time_ms();
257 double new_region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
258 double elapsed_ms_diff = new_region_elapsed_time_ms - old_elapsed_time_ms;
259 _inc_predicted_elapsed_time_ms_diff += elapsed_ms_diff;
260
261 hr->set_recorded_rs_length(new_rs_length);
262 hr->set_predicted_elapsed_time_ms(new_region_elapsed_time_ms);
263 }
264
265 void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
266 assert(hr->is_young(), "invariant");
267 assert(_inc_build_state == Active, "Precondition");
268
269 // This routine is used when:
270 // * adding survivor regions to the incremental cset at the end of an
271 // evacuation pause or
|