284 "target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms);
285 guarantee(_head == NULL, "Precondition");
286
287 size_t pending_cards = _policy->pending_cards();
288 double base_time_ms = _policy->predict_base_elapsed_time_ms(pending_cards);
289 double time_remaining_ms = MAX2(target_pause_time_ms - base_time_ms, 0.0);
290
291 log_trace(gc, ergo, cset)("Start choosing CSet. pending cards: " SIZE_FORMAT " predicted base time: %1.2fms remaining time: %1.2fms target pause time: %1.2fms",
292 pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
293
294 collector_state()->set_last_gc_was_young(collector_state()->gcs_are_young());
295
296 // The young list is laid with the survivor regions from the previous
297 // pause are appended to the RHS of the young list, i.e.
298 // [Newly Young Regions ++ Survivors from last pause].
299
300 uint survivor_region_length = young_list->survivor_length();
301 uint eden_region_length = young_list->eden_length();
302 init_region_lengths(eden_region_length, survivor_region_length);
303
304 HeapRegion* hr = young_list->first_survivor_region();
305 while (hr != NULL) {
306 assert(hr->is_survivor(), "badly formed young list");
307 // There is a convention that all the young regions in the CSet
308 // are tagged as "eden", so we do this for the survivors here. We
309 // use the special set_eden_pre_gc() as it doesn't check that the
310 // region is free (which is not the case here).
311 hr->set_eden_pre_gc();
312 hr = hr->get_next_young_region();
313 }
314
315 verify_young_cset_indices();
316
317 // Clear the fields that point to the survivor list - they are all young now.
318 young_list->clear_survivors();
319
320 _head = _inc_head;
321 _bytes_used_before = _inc_bytes_used_before;
322 time_remaining_ms = MAX2(time_remaining_ms - _inc_predicted_elapsed_time_ms, 0.0);
323
324 log_trace(gc, ergo, cset)("Add young regions to CSet. eden: %u regions, survivors: %u regions, predicted young region time: %1.2fms, target pause time: %1.2fms",
325 eden_region_length, survivor_region_length, _inc_predicted_elapsed_time_ms, target_pause_time_ms);
326
327 // The number of recorded young regions is the incremental
328 // collection set's current size
329 set_recorded_rs_lengths(_inc_recorded_rs_lengths);
330
331 double young_end_time_sec = os::elapsedTime();
332 phase_times()->record_young_cset_choice_time_ms((young_end_time_sec - young_start_time_sec) * 1000.0);
|
284 "target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms);
285 guarantee(_head == NULL, "Precondition");
286
287 size_t pending_cards = _policy->pending_cards();
288 double base_time_ms = _policy->predict_base_elapsed_time_ms(pending_cards);
289 double time_remaining_ms = MAX2(target_pause_time_ms - base_time_ms, 0.0);
290
291 log_trace(gc, ergo, cset)("Start choosing CSet. pending cards: " SIZE_FORMAT " predicted base time: %1.2fms remaining time: %1.2fms target pause time: %1.2fms",
292 pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
293
294 collector_state()->set_last_gc_was_young(collector_state()->gcs_are_young());
295
296 // The young list is laid with the survivor regions from the previous
297 // pause are appended to the RHS of the young list, i.e.
298 // [Newly Young Regions ++ Survivors from last pause].
299
300 uint survivor_region_length = young_list->survivor_length();
301 uint eden_region_length = young_list->eden_length();
302 init_region_lengths(eden_region_length, survivor_region_length);
303
304 const GrowableArray<HeapRegion*>* survivor_regions = _g1->young_list()->survivor_regions();
305 for (GrowableArrayIterator<HeapRegion*> it = survivor_regions->begin();
306 it != survivor_regions->end();
307 ++it) {
308 HeapRegion* hr = *it;
309 assert(hr->is_survivor(), "badly formed young list");
310 // There is a convention that all the young regions in the CSet
311 // are tagged as "eden", so we do this for the survivors here. We
312 // use the special set_eden_pre_gc() as it doesn't check that the
313 // region is free (which is not the case here).
314 hr->set_eden_pre_gc();
315 }
316
317 verify_young_cset_indices();
318
319 // Clear the fields that point to the survivor list - they are all young now.
320 young_list->clear_survivors();
321
322 _head = _inc_head;
323 _bytes_used_before = _inc_bytes_used_before;
324 time_remaining_ms = MAX2(time_remaining_ms - _inc_predicted_elapsed_time_ms, 0.0);
325
326 log_trace(gc, ergo, cset)("Add young regions to CSet. eden: %u regions, survivors: %u regions, predicted young region time: %1.2fms, target pause time: %1.2fms",
327 eden_region_length, survivor_region_length, _inc_predicted_elapsed_time_ms, target_pause_time_ms);
328
329 // The number of recorded young regions is the incremental
330 // collection set's current size
331 set_recorded_rs_lengths(_inc_recorded_rs_lengths);
332
333 double young_end_time_sec = os::elapsedTime();
334 phase_times()->record_young_cset_choice_time_ms((young_end_time_sec - young_start_time_sec) * 1000.0);
|