45 |
45 |
46 uint _eden_region_length; |
46 uint _eden_region_length; |
47 uint _survivor_region_length; |
47 uint _survivor_region_length; |
48 uint _old_region_length; |
48 uint _old_region_length; |
49 |
49 |
50 // The head of the list (via "next_in_collection_set()") representing the |
50 // The actual collection set as a set of region indices. |
51 // current collection set. Set from the incrementally built collection |
51 // All entries in _collection_set_regions below _collection_set_cur_length are |
52 // set at the start of the pause. |
52 // assumed to be valid entries. |
53 HeapRegion* _head; |
53 // We assume that at any time there is at most only one writer and (one or more) |
|
54 // concurrent readers. This means we are good with using storestore and loadload |
|
55 // barriers on the writer and reader respectively only. |
|
56 uint* _collection_set_regions; |
|
57 volatile size_t _collection_set_cur_length; |
|
58 size_t _collection_set_max_length; |
54 |
59 |
55 // The number of bytes in the collection set before the pause. Set from |
60 // The number of bytes in the collection set before the pause. Set from |
56 // the incrementally built collection set at the start of an evacuation |
61 // the incrementally built collection set at the start of an evacuation |
57 // pause, and incremented in finalize_old_part() when adding old regions |
62 // pause, and incremented in finalize_old_part() when adding old regions |
58 // (if any) to the collection set. |
63 // (if any) to the collection set. |
68 Active, // We are actively building the collection set |
73 Active, // We are actively building the collection set |
69 Inactive // We are not actively building the collection set |
74 Inactive // We are not actively building the collection set |
70 }; |
75 }; |
71 |
76 |
72 CSetBuildType _inc_build_state; |
77 CSetBuildType _inc_build_state; |
73 |
|
74 // The head of the incrementally built collection set. |
|
75 HeapRegion* _inc_head; |
|
76 |
|
77 // The tail of the incrementally built collection set. |
|
78 HeapRegion* _inc_tail; |
|
79 |
78 |
80 // The number of bytes in the incrementally built collection set. |
79 // The number of bytes in the incrementally built collection set. |
81 // Used to set _collection_set_bytes_used_before at the start of |
80 // Used to set _collection_set_bytes_used_before at the start of |
82 // an evacuation pause. |
81 // an evacuation pause. |
83 size_t _inc_bytes_used_before; |
82 size_t _inc_bytes_used_before; |
103 double _inc_predicted_elapsed_time_ms; |
102 double _inc_predicted_elapsed_time_ms; |
104 |
103 |
105 // See the comment for _inc_recorded_rs_lengths_diffs. |
104 // See the comment for _inc_recorded_rs_lengths_diffs. |
106 double _inc_predicted_elapsed_time_ms_diffs; |
105 double _inc_predicted_elapsed_time_ms_diffs; |
107 |
106 |
108 uint _inc_region_length; |
|
109 |
|
110 G1CollectorState* collector_state(); |
107 G1CollectorState* collector_state(); |
111 G1GCPhaseTimes* phase_times(); |
108 G1GCPhaseTimes* phase_times(); |
112 |
109 |
113 double predict_region_elapsed_time_ms(HeapRegion* hr); |
110 double predict_region_elapsed_time_ms(HeapRegion* hr); |
114 |
111 |
115 void verify_young_cset_indices() const NOT_DEBUG_RETURN; |
112 void verify_young_cset_indices() const NOT_DEBUG_RETURN; |
116 public: |
113 public: |
117 G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy); |
114 G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy); |
118 ~G1CollectionSet(); |
115 ~G1CollectionSet(); |
119 |
116 |
|
117 // Initializes the collection set giving the maximum possible length of the collection set. |
|
118 void initialize(uint max_region_length); |
|
119 |
120 CollectionSetChooser* cset_chooser(); |
120 CollectionSetChooser* cset_chooser(); |
121 |
121 |
122 void init_region_lengths(uint eden_cset_region_length, |
122 void init_region_lengths(uint eden_cset_region_length, |
123 uint survivor_cset_region_length); |
123 uint survivor_cset_region_length); |
124 |
124 |
131 |
131 |
132 uint eden_region_length() const { return _eden_region_length; } |
132 uint eden_region_length() const { return _eden_region_length; } |
133 uint survivor_region_length() const { return _survivor_region_length; } |
133 uint survivor_region_length() const { return _survivor_region_length; } |
134 uint old_region_length() const { return _old_region_length; } |
134 uint old_region_length() const { return _old_region_length; } |
135 |
135 |
136 // Incremental CSet Support |
136 // Incremental collection set support |
137 |
|
138 // The head of the incrementally built collection set. |
|
139 HeapRegion* inc_head() { return _inc_head; } |
|
140 |
|
141 // The tail of the incrementally built collection set. |
|
142 HeapRegion* inc_tail() { return _inc_tail; } |
|
143 |
137 |
144 // Initialize incremental collection set info. |
138 // Initialize incremental collection set info. |
145 void start_incremental_building(); |
139 void start_incremental_building(); |
146 |
140 |
147 // Perform any final calculations on the incremental CSet fields |
141 // Perform any final calculations on the incremental collection set fields |
148 // before we can use them. |
142 // before we can use them. |
149 void finalize_incremental_building(); |
143 void finalize_incremental_building(); |
150 |
144 |
151 void clear_incremental() { |
145 // Reset the contents of the collection set. |
152 _inc_head = NULL; |
146 void clear(); |
153 _inc_tail = NULL; |
147 |
154 _inc_region_length = 0; |
148 // Iterate over the collection set, applying the given HeapRegionClosure on all of them. |
155 } |
149 // If may_be_aborted is true, iteration may be aborted using the return value of the |
156 |
150 // called closure method. |
157 // Stop adding regions to the incremental collection set |
151 void iterate(HeapRegionClosure* cl) const; |
|
152 |
|
153 // Iterate over the collection set, applying the given HeapRegionClosure on all of them, |
|
154 // trying to optimally spread out starting position of total_workers workers given the |
|
155 // caller's worker_id. |
|
156 void iterate_from(HeapRegionClosure* cl, uint worker_id, uint total_workers) const; |
|
157 |
|
158 // Stop adding regions to the incremental collection set. |
158 void stop_incremental_building() { _inc_build_state = Inactive; } |
159 void stop_incremental_building() { _inc_build_state = Inactive; } |
159 |
|
160 // The head of the list (via "next_in_collection_set()") representing the |
|
161 // current collection set. |
|
162 HeapRegion* head() { return _head; } |
|
163 |
|
164 void clear_head() { _head = NULL; } |
|
165 |
160 |
166 size_t recorded_rs_lengths() { return _recorded_rs_lengths; } |
161 size_t recorded_rs_lengths() { return _recorded_rs_lengths; } |
167 |
162 |
168 size_t bytes_used_before() const { |
163 size_t bytes_used_before() const { |
169 return _bytes_used_before; |
164 return _bytes_used_before; |
172 void reset_bytes_used_before() { |
167 void reset_bytes_used_before() { |
173 _bytes_used_before = 0; |
168 _bytes_used_before = 0; |
174 } |
169 } |
175 |
170 |
176 // Choose a new collection set. Marks the chosen regions as being |
171 // Choose a new collection set. Marks the chosen regions as being |
177 // "in_collection_set", and links them together. The head and number of |
172 // "in_collection_set". |
178 // the collection set are available via access methods. |
|
179 double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors); |
173 double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors); |
180 void finalize_old_part(double time_remaining_ms); |
174 void finalize_old_part(double time_remaining_ms); |
181 |
175 |
182 // Add old region "hr" to the CSet. |
176 // Add old region "hr" to the collection set. |
183 void add_old_region(HeapRegion* hr); |
177 void add_old_region(HeapRegion* hr); |
184 |
178 |
185 // Update information about hr in the aggregated information for |
179 // Update information about hr in the aggregated information for |
186 // the incrementally built collection set. |
180 // the incrementally built collection set. |
187 void update_young_region_prediction(HeapRegion* hr, size_t new_rs_length); |
181 void update_young_region_prediction(HeapRegion* hr, size_t new_rs_length); |
188 |
182 |
189 // Add hr to the LHS of the incremental collection set. |
183 // Add eden region to the collection set. |
190 void add_eden_region(HeapRegion* hr); |
184 void add_eden_region(HeapRegion* hr); |
191 |
185 |
192 // Add hr to the RHS of the incremental collection set. |
186 // Add survivor region to the collection set. |
193 void add_survivor_regions(HeapRegion* hr); |
187 void add_survivor_regions(HeapRegion* hr); |
194 |
188 |
195 #ifndef PRODUCT |
189 #ifndef PRODUCT |
196 void print(HeapRegion* list_head, outputStream* st); |
190 bool verify_young_ages(); |
|
191 |
|
192 void print(outputStream* st); |
197 #endif // !PRODUCT |
193 #endif // !PRODUCT |
198 |
194 |
199 private: |
195 private: |
200 // Update the incremental cset information when adding a region |
196 // Update the incremental collection set information when adding a region. |
201 // (should not be called directly). |
|
202 void add_young_region_common(HeapRegion* hr); |
197 void add_young_region_common(HeapRegion* hr); |
203 |
|
204 }; |
198 }; |
205 |
199 |
206 #endif // SHARE_VM_GC_G1_G1COLLECTIONSET_HPP |
200 #endif // SHARE_VM_GC_G1_G1COLLECTIONSET_HPP |
207 |
201 |