134 // sorted list. We should try to avoid doing operations that iterate over |
134 // sorted list. We should try to avoid doing operations that iterate over |
135 // such lists in performance critical paths. Typically we should |
135 // such lists in performance critical paths. Typically we should |
136 // add / remove one region at a time or concatenate two lists. |
136 // add / remove one region at a time or concatenate two lists. |
137 |
137 |
138 class FreeRegionListIterator; |
138 class FreeRegionListIterator; |
|
139 class G1NUMA; |
139 |
140 |
140 class FreeRegionList : public HeapRegionSetBase { |
141 class FreeRegionList : public HeapRegionSetBase { |
141 friend class FreeRegionListIterator; |
142 friend class FreeRegionListIterator; |
142 |
143 |
143 private: |
144 private: |
|
145 |
|
146 // This class is only initialized if there are multiple active nodes. |
|
147 class NodeInfo : public CHeapObj<mtGC> { |
|
148 G1NUMA* _numa; |
|
149 uint* _length_of_node; |
|
150 uint _num_nodes; |
|
151 |
|
152 public: |
|
153 NodeInfo(); |
|
154 ~NodeInfo(); |
|
155 |
|
156 inline void increase_length(uint node_index); |
|
157 inline void decrease_length(uint node_index); |
|
158 |
|
159 inline uint length(uint index) const; |
|
160 |
|
161 void clear(); |
|
162 |
|
163 void add(NodeInfo* info); |
|
164 }; |
|
165 |
144 HeapRegion* _head; |
166 HeapRegion* _head; |
145 HeapRegion* _tail; |
167 HeapRegion* _tail; |
146 |
168 |
147 // _last is used to keep track of where we added an element the last |
169 // _last is used to keep track of where we added an element the last |
148 // time. It helps to improve performance when adding several ordered items in a row. |
170 // time. It helps to improve performance when adding several ordered items in a row. |
149 HeapRegion* _last; |
171 HeapRegion* _last; |
150 |
172 |
|
173 NodeInfo* _node_info; |
|
174 |
151 static uint _unrealistically_long_length; |
175 static uint _unrealistically_long_length; |
152 |
176 |
153 inline HeapRegion* remove_from_head_impl(); |
177 inline HeapRegion* remove_from_head_impl(); |
154 inline HeapRegion* remove_from_tail_impl(); |
178 inline HeapRegion* remove_from_tail_impl(); |
|
179 |
|
180 inline void increase_length(uint node_index); |
|
181 inline void decrease_length(uint node_index); |
155 |
182 |
156 protected: |
183 protected: |
157 // See the comment for HeapRegionSetBase::clear() |
184 // See the comment for HeapRegionSetBase::clear() |
158 virtual void clear(); |
185 virtual void clear(); |
159 |
186 |
160 public: |
187 public: |
161 FreeRegionList(const char* name, HeapRegionSetChecker* checker = NULL): |
188 FreeRegionList(const char* name, HeapRegionSetChecker* checker = NULL); |
162 HeapRegionSetBase(name, checker) { |
189 ~FreeRegionList(); |
163 clear(); |
|
164 } |
|
165 |
190 |
166 void verify_list(); |
191 void verify_list(); |
167 |
192 |
168 #ifdef ASSERT |
193 #ifdef ASSERT |
169 bool contains(HeapRegion* hr) const { |
194 bool contains(HeapRegion* hr) const { |
180 |
205 |
181 // Removes from head or tail based on the given argument. |
206 // Removes from head or tail based on the given argument. |
182 HeapRegion* remove_region(bool from_head); |
207 HeapRegion* remove_region(bool from_head); |
183 |
208 |
184 HeapRegion* remove_region_with_node_index(bool from_head, |
209 HeapRegion* remove_region_with_node_index(bool from_head, |
185 const uint requested_node_index, |
210 uint requested_node_index); |
186 uint* region_node_index); |
|
187 |
211 |
188 // Merge two ordered lists. The result is also ordered. The order is |
212 // Merge two ordered lists. The result is also ordered. The order is |
189 // determined by hrm_index. |
213 // determined by hrm_index. |
190 void add_ordered(FreeRegionList* from_list); |
214 void add_ordered(FreeRegionList* from_list); |
191 |
215 |
198 void remove_starting_at(HeapRegion* first, uint num_regions); |
222 void remove_starting_at(HeapRegion* first, uint num_regions); |
199 |
223 |
200 virtual void verify(); |
224 virtual void verify(); |
201 |
225 |
202 uint num_of_regions_in_range(uint start, uint end) const; |
226 uint num_of_regions_in_range(uint start, uint end) const; |
|
227 |
|
228 using HeapRegionSetBase::length; |
|
229 uint length(uint node_index) const; |
203 }; |
230 }; |
204 |
231 |
205 // Iterator class that provides a convenient way to iterate over the |
232 // Iterator class that provides a convenient way to iterate over the |
206 // regions of a FreeRegionList. |
233 // regions of a FreeRegionList. |
207 |
234 |