46 } |
46 } |
47 void regions_trunc_to(uint i) { _regions.trunc_to((uint) i); } |
47 void regions_trunc_to(uint i) { _regions.trunc_to((uint) i); } |
48 |
48 |
49 // The index of the next candidate old region to be considered for |
49 // The index of the next candidate old region to be considered for |
50 // addition to the CSet. |
50 // addition to the CSet. |
51 uint _curr_index; |
51 uint _front; |
52 |
52 |
53 // The number of candidate old regions added to the CSet chooser. |
53 // The index of the last candidate old region |
54 // Note: this is not updated when removing a region using |
54 uint _end; |
55 // remove_and_move_to_next() below. |
|
56 uint _length; |
|
57 |
55 |
58 // Keeps track of the start of the next array chunk to be claimed by |
56 // Keeps track of the start of the next array chunk to be claimed by |
59 // parallel GC workers. |
57 // parallel GC workers. |
60 uint _first_par_unreserved_idx; |
58 uint _first_par_unreserved_idx; |
61 |
59 |
71 |
69 |
72 // Return the current candidate region to be considered for |
70 // Return the current candidate region to be considered for |
73 // collection without removing it from the CSet chooser. |
71 // collection without removing it from the CSet chooser. |
74 HeapRegion* peek() { |
72 HeapRegion* peek() { |
75 HeapRegion* res = NULL; |
73 HeapRegion* res = NULL; |
76 if (_curr_index < _length) { |
74 if (_front < _end) { |
77 res = regions_at(_curr_index); |
75 res = regions_at(_front); |
78 assert(res != NULL, |
76 assert(res != NULL, |
79 err_msg("Unexpected NULL hr in _regions at index %u", |
77 err_msg("Unexpected NULL hr in _regions at index %u", |
80 _curr_index)); |
78 _front)); |
81 } |
79 } |
82 return res; |
80 return res; |
83 } |
81 } |
84 |
82 |
85 // Remove the given region from the CSet chooser and move to the |
83 // Remove the given region from the CSet chooser and move to the |
86 // next one. The given region should be the current candidate region |
84 // next one. |
87 // in the CSet chooser. |
85 HeapRegion* pop() { |
88 void remove_and_move_to_next(HeapRegion* hr) { |
86 HeapRegion* hr = regions_at(_front); |
89 assert(hr != NULL, "pre-condition"); |
87 assert(hr != NULL, "pre-condition"); |
90 assert(_curr_index < _length, "pre-condition"); |
88 assert(_front < _end, "pre-condition"); |
91 assert(regions_at(_curr_index) == hr, "pre-condition"); |
89 regions_at_put(_front, NULL); |
92 regions_at_put(_curr_index, NULL); |
|
93 assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes, |
90 assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes, |
94 err_msg("remaining reclaimable bytes inconsistent " |
91 err_msg("remaining reclaimable bytes inconsistent " |
95 "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT, |
92 "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT, |
96 hr->reclaimable_bytes(), _remaining_reclaimable_bytes)); |
93 hr->reclaimable_bytes(), _remaining_reclaimable_bytes)); |
97 _remaining_reclaimable_bytes -= hr->reclaimable_bytes(); |
94 _remaining_reclaimable_bytes -= hr->reclaimable_bytes(); |
98 _curr_index += 1; |
95 _front += 1; |
|
96 return hr; |
99 } |
97 } |
|
98 |
|
99 void push(HeapRegion* hr); |
100 |
100 |
101 CollectionSetChooser(); |
101 CollectionSetChooser(); |
102 |
102 |
103 void sort_regions(); |
103 void sort_regions(); |
104 |
104 |
111 return !hr->is_pinned() && |
111 return !hr->is_pinned() && |
112 hr->live_bytes() < _region_live_threshold_bytes; |
112 hr->live_bytes() < _region_live_threshold_bytes; |
113 } |
113 } |
114 |
114 |
115 // Returns the number candidate old regions added |
115 // Returns the number candidate old regions added |
116 uint length() { return _length; } |
116 uint length() { return _end; } |
117 |
117 |
118 // Serial version. |
118 // Serial version. |
119 void add_region(HeapRegion *hr); |
119 void add_region(HeapRegion *hr); |
120 |
120 |
121 // Must be called before calls to claim_array_chunk(). |
121 // Must be called before calls to claim_array_chunk(). |
133 void update_totals(uint region_num, size_t reclaimable_bytes); |
133 void update_totals(uint region_num, size_t reclaimable_bytes); |
134 |
134 |
135 void clear(); |
135 void clear(); |
136 |
136 |
137 // Return the number of candidate regions that remain to be collected. |
137 // Return the number of candidate regions that remain to be collected. |
138 uint remaining_regions() { return _length - _curr_index; } |
138 uint remaining_regions() { return _end - _front; } |
139 |
139 |
140 // Determine whether the CSet chooser has more candidate regions or not. |
140 // Determine whether the CSet chooser has more candidate regions or not. |
141 bool is_empty() { return remaining_regions() == 0; } |
141 bool is_empty() { return remaining_regions() == 0; } |
142 |
142 |
143 // Return the reclaimable bytes that remain to be collected on |
143 // Return the reclaimable bytes that remain to be collected on |