79 _max_survivor_regions(0),
80 _survivors_age_table(true)
81 {
82 }
83
84 G1Policy::~G1Policy() {
85 delete _ihop_control;
86 }
87
88 G1CollectorState* G1Policy::collector_state() const { return _g1h->collector_state(); }
89
90 void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) {
91 _g1h = g1h;
92 _collection_set = collection_set;
93
94 assert(Heap_lock->owned_by_self(), "Locking discipline.");
95
96 if (!adaptive_young_list_length()) {
97 _young_list_fixed_length = _young_gen_sizer.min_desired_young_length();
98 }
99 _young_gen_sizer.adjust_max_new_size(_g1h->max_regions());
100
101 _free_regions_at_end_of_collection = _g1h->num_free_regions();
102
103 update_young_list_max_and_target_length();
104 // We may immediately start allocating regions and placing them on the
105 // collection set list. Initialize the per-collection set info
106 _collection_set->start_incremental_building();
107 }
108
109 void G1Policy::note_gc_start() {
110 phase_times()->note_gc_start();
111 }
112
113 class G1YoungLengthPredictor {
114 const bool _during_cm;
115 const double _base_time_ms;
116 const double _base_free_regions;
117 const double _target_pause_time_ms;
118 const G1Policy* const _policy;
119
201 uint G1Policy::calculate_young_list_desired_max_length() const {
202 // Here, we might want to also take into account any additional
203 // constraints (i.e., user-defined minimum bound). Currently, we
204 // effectively don't set this bound.
205 return _young_gen_sizer.max_desired_young_length();
206 }
207
208 uint G1Policy::update_young_list_max_and_target_length() {
209 return update_young_list_max_and_target_length(_analytics->predict_rs_lengths());
210 }
211
212 uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) {
213 uint unbounded_target_length = update_young_list_target_length(rs_lengths);
214 update_max_gc_locker_expansion();
215 return unbounded_target_length;
216 }
217
218 uint G1Policy::update_young_list_target_length(size_t rs_lengths) {
219 YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
220 _young_list_target_length = young_lengths.first;
221 return young_lengths.second;
222 }
223
224 G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const {
225 YoungTargetLengths result;
226
227 // Calculate the absolute and desired min bounds first.
228
229 // This is how many young regions we already have (currently: the survivors).
230 const uint base_min_length = _g1h->survivor_regions_count();
231 uint desired_min_length = calculate_young_list_desired_min_length(base_min_length);
232 // This is the absolute minimum young length. Ensure that we
233 // will at least have one eden region available for allocation.
234 uint absolute_min_length = base_min_length + MAX2(_g1h->eden_regions_count(), (uint)1);
235 // If we shrank the young list target it should not shrink below the current size.
236 desired_min_length = MAX2(desired_min_length, absolute_min_length);
237 // Calculate the absolute and desired max bounds.
238
239 uint desired_max_length = calculate_young_list_desired_max_length();
240
|
79 _max_survivor_regions(0),
80 _survivors_age_table(true)
81 {
82 }
83
84 G1Policy::~G1Policy() {
85 delete _ihop_control;
86 }
87
88 G1CollectorState* G1Policy::collector_state() const { return _g1h->collector_state(); }
89
90 void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) {
91 _g1h = g1h;
92 _collection_set = collection_set;
93
94 assert(Heap_lock->owned_by_self(), "Locking discipline.");
95
96 if (!adaptive_young_list_length()) {
97 _young_list_fixed_length = _young_gen_sizer.min_desired_young_length();
98 }
99 _young_gen_sizer.adjust_max_new_size(_g1h->max_expandable_regions());
100
101 _free_regions_at_end_of_collection = _g1h->num_free_regions();
102
103 update_young_list_max_and_target_length();
104 // We may immediately start allocating regions and placing them on the
105 // collection set list. Initialize the per-collection set info
106 _collection_set->start_incremental_building();
107 }
108
109 void G1Policy::note_gc_start() {
110 phase_times()->note_gc_start();
111 }
112
113 class G1YoungLengthPredictor {
114 const bool _during_cm;
115 const double _base_time_ms;
116 const double _base_free_regions;
117 const double _target_pause_time_ms;
118 const G1Policy* const _policy;
119
201 uint G1Policy::calculate_young_list_desired_max_length() const {
202 // Here, we might want to also take into account any additional
203 // constraints (i.e., user-defined minimum bound). Currently, we
204 // effectively don't set this bound.
205 return _young_gen_sizer.max_desired_young_length();
206 }
207
208 uint G1Policy::update_young_list_max_and_target_length() {
209 return update_young_list_max_and_target_length(_analytics->predict_rs_lengths());
210 }
211
212 uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) {
213 uint unbounded_target_length = update_young_list_target_length(rs_lengths);
214 update_max_gc_locker_expansion();
215 return unbounded_target_length;
216 }
217
218 uint G1Policy::update_young_list_target_length(size_t rs_lengths) {
219 YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
220 _young_list_target_length = young_lengths.first;
221
222 // Resize dram regions set if called after full collection end.
223 if(_g1h->is_hetero_heap() && (Thread::current()->is_VM_thread() || Heap_lock->owned_by_self())) {
224 static_cast <HeapRegionManagerForHeteroHeap*>(_g1h->hrm())->resize_dram_regions(_young_list_target_length, _g1h->workers());
225 }
226 return young_lengths.second;
227 }
228
229 G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const {
230 YoungTargetLengths result;
231
232 // Calculate the absolute and desired min bounds first.
233
234 // This is how many young regions we already have (currently: the survivors).
235 const uint base_min_length = _g1h->survivor_regions_count();
236 uint desired_min_length = calculate_young_list_desired_min_length(base_min_length);
237 // This is the absolute minimum young length. Ensure that we
238 // will at least have one eden region available for allocation.
239 uint absolute_min_length = base_min_length + MAX2(_g1h->eden_regions_count(), (uint)1);
240 // If we shrank the young list target it should not shrink below the current size.
241 desired_min_length = MAX2(desired_min_length, absolute_min_length);
242 // Calculate the absolute and desired max bounds.
243
244 uint desired_max_length = calculate_young_list_desired_max_length();
245
|