Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/heapRegionSet.hpp @ 17758:ae7336d6337e
8034868: Extract G1 From Card Cache into separate class
Summary: Refactor the From Card Cache into a separate class.
Reviewed-by: jmasa
author | tschatzl |
---|---|
date | Mon, 24 Mar 2014 15:30:50 +0100 |
parents | 58fc1b1523dc |
children | 8ee855b4e667 |
rev | line source |
---|---|
2152 | 1 /* |
4830
0b3d1ec6eaee
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
4072
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
2152 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP | |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP | |
27 | |
28 #include "gc_implementation/g1/heapRegion.hpp" | |
29 | |
30 // Large buffer for some cases where the output might be larger than normal. | |
2361 | 31 #define HRS_ERR_MSG_BUFSZ 512 |
32 typedef FormatBuffer<HRS_ERR_MSG_BUFSZ> hrs_err_msg; | |
2152 | 33 |
34 // Set verification will be forced either if someone defines | |
35 // HEAP_REGION_SET_FORCE_VERIFY to be 1, or in builds in which | |
36 // asserts are compiled in. | |
37 #ifndef HEAP_REGION_SET_FORCE_VERIFY | |
38 #define HEAP_REGION_SET_FORCE_VERIFY defined(ASSERT) | |
39 #endif // HEAP_REGION_SET_FORCE_VERIFY | |
40 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
41 class hrs_ext_msg; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
42 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
43 class HRSMtSafeChecker : public CHeapObj<mtGC> { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
44 public: |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
45 virtual void check() = 0; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
46 }; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
47 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
48 class MasterFreeRegionListMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
49 class SecondaryFreeRegionListMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
50 class HumongousRegionSetMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
51 class OldRegionSetMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
52 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
53 class HeapRegionSetCount VALUE_OBJ_CLASS_SPEC { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
54 friend class VMStructs; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
55 uint _length; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
56 size_t _capacity; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
57 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
58 public: |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
59 HeapRegionSetCount() : _length(0), _capacity(0) { } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
60 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
61 const uint length() const { return _length; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
62 const size_t capacity() const { return _capacity; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
63 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
64 void increment(uint length_to_add, size_t capacity_to_add) { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
65 _length += length_to_add; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
66 _capacity += capacity_to_add; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
67 } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
68 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
69 void decrement(const uint length_to_remove, const size_t capacity_to_remove) { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
70 _length -= length_to_remove; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
71 _capacity -= capacity_to_remove; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
72 } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
73 }; |
2152 | 74 |
75 // Base class for all the classes that represent heap region sets. It | |
76 // contains the basic attributes that each set needs to maintain | |
77 // (e.g., length, region num, used bytes sum) plus any shared | |
78 // functionality (e.g., verification). | |
79 | |
80 class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC { | |
4830
0b3d1ec6eaee
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
4072
diff
changeset
|
81 friend class VMStructs; |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
82 private: |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
83 bool _is_humongous; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
84 bool _is_empty; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
85 HRSMtSafeChecker* _mt_safety_checker; |
2152 | 86 |
87 protected: | |
88 // The number of regions added to the set. If the set contains | |
89 // only humongous regions, this reflects only 'starts humongous' | |
90 // regions and does not include 'continues humongous' ones. | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
91 HeapRegionSetCount _count; |
2152 | 92 |
93 const char* _name; | |
94 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
95 bool _verify_in_progress; |
4072 | 96 |
2152 | 97 // verify_region() is used to ensure that the contents of a region |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
98 // added to / removed from a set are consistent. |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
99 void verify_region(HeapRegion* hr) PRODUCT_RETURN; |
2152 | 100 |
101 // Indicates whether all regions in the set should be humongous or | |
102 // not. Only used during verification. | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
103 bool regions_humongous() { return _is_humongous; } |
2152 | 104 |
105 // Indicates whether all regions in the set should be empty or | |
106 // not. Only used during verification. | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
107 bool regions_empty() { return _is_empty; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
108 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
109 void check_mt_safety() { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
110 if (_mt_safety_checker != NULL) { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
111 _mt_safety_checker->check(); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
112 } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
113 } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
114 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
115 virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg) { } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
116 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
117 HeapRegionSetBase(const char* name, bool humongous, bool empty, HRSMtSafeChecker* mt_safety_checker); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
118 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
119 public: |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
120 const char* name() { return _name; } |
2152 | 121 |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
122 uint length() { return _count.length(); } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
123 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
124 bool is_empty() { return _count.length() == 0; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
125 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
126 size_t total_capacity_bytes() { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
127 return _count.capacity(); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
128 } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
129 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
130 // It updates the fields of the set to reflect hr being added to |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
131 // the set and tags the region appropriately. |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
132 inline void add(HeapRegion* hr); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
133 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
134 // It updates the fields of the set to reflect hr being removed |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
135 // from the set and tags the region appropriately. |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
136 inline void remove(HeapRegion* hr); |
2152 | 137 |
138 // fill_in_ext_msg() writes the the values of the set's attributes | |
2361 | 139 // in the custom err_msg (hrs_ext_msg). fill_in_ext_msg_extra() |
2152 | 140 // allows subclasses to append further information. |
2361 | 141 void fill_in_ext_msg(hrs_ext_msg* msg, const char* message); |
2152 | 142 |
143 virtual void verify(); | |
144 void verify_start(); | |
145 void verify_next_region(HeapRegion* hr); | |
146 void verify_end(); | |
147 | |
148 #if HEAP_REGION_SET_FORCE_VERIFY | |
149 void verify_optional() { | |
150 verify(); | |
151 } | |
152 #else // HEAP_REGION_SET_FORCE_VERIFY | |
153 void verify_optional() { } | |
154 #endif // HEAP_REGION_SET_FORCE_VERIFY | |
155 | |
156 virtual void print_on(outputStream* out, bool print_contents = false); | |
157 }; | |
158 | |
159 // Customized err_msg for heap region sets. Apart from a | |
160 // assert/guarantee-specific message it also prints out the values of | |
161 // the fields of the associated set. This can be very helpful in | |
162 // diagnosing failures. | |
2361 | 163 class hrs_ext_msg : public hrs_err_msg { |
2152 | 164 public: |
2361 | 165 hrs_ext_msg(HeapRegionSetBase* set, const char* message) : hrs_err_msg("") { |
2152 | 166 set->fill_in_ext_msg(this, message); |
167 } | |
168 }; | |
169 | |
2361 | 170 #define hrs_assert_sets_match(_set1_, _set2_) \ |
2152 | 171 do { \ |
172 assert(((_set1_)->regions_humongous() == \ | |
173 (_set2_)->regions_humongous()) && \ | |
174 ((_set1_)->regions_empty() == (_set2_)->regions_empty()), \ | |
2361 | 175 hrs_err_msg("the contents of set %s and set %s should match", \ |
2152 | 176 (_set1_)->name(), (_set2_)->name())); \ |
177 } while (0) | |
178 | |
179 // This class represents heap region sets whose members are not | |
180 // explicitly tracked. It's helpful to group regions using such sets | |
181 // so that we can reason about all the region groups in the heap using | |
182 // the same interface (namely, the HeapRegionSetBase API). | |
183 | |
184 class HeapRegionSet : public HeapRegionSetBase { | |
185 public: | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
186 HeapRegionSet(const char* name, bool humongous, HRSMtSafeChecker* mt_safety_checker): |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
187 HeapRegionSetBase(name, humongous, false /* empty */, mt_safety_checker) { } |
2152 | 188 |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
189 void bulk_remove(const HeapRegionSetCount& removed) { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
190 _count.decrement(removed.length(), removed.capacity()); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
191 } |
2152 | 192 }; |
193 | |
194 // A set that links all the regions added to it in a singly-linked | |
195 // list. We should try to avoid doing operations that iterate over | |
196 // such lists in performance critical paths. Typically we should | |
197 // add / remove one region at a time or concatenate two lists. All | |
198 // those operations are done in constant time. | |
199 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
200 class FreeRegionListIterator; |
2152 | 201 |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
202 class FreeRegionList : public HeapRegionSetBase { |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
203 friend class FreeRegionListIterator; |
2152 | 204 |
205 private: | |
206 HeapRegion* _head; | |
207 HeapRegion* _tail; | |
208 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
209 static uint _unrealistically_long_length; |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
210 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
211 void add_as_head_or_tail(FreeRegionList* from_list, bool as_head); |
2152 | 212 |
213 protected: | |
2361 | 214 virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg); |
2152 | 215 |
216 // See the comment for HeapRegionSetBase::clear() | |
217 virtual void clear(); | |
218 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
219 public: |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
220 FreeRegionList(const char* name, HRSMtSafeChecker* mt_safety_checker = NULL): |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
221 HeapRegionSetBase(name, false /* humongous */, true /* empty */, mt_safety_checker) { |
2152 | 222 clear(); |
223 } | |
224 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
225 void verify_list(); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
226 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
227 HeapRegion* head() { return _head; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
228 HeapRegion* tail() { return _tail; } |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
229 |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
230 static void set_unrealistically_long_length(uint len); |
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
231 |
2432
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
232 // It adds hr to the list as the new head. The region should not be |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
233 // a member of another set. |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
234 inline void add_as_head(HeapRegion* hr); |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
235 |
2152 | 236 // It adds hr to the list as the new tail. The region should not be |
237 // a member of another set. | |
238 inline void add_as_tail(HeapRegion* hr); | |
239 | |
240 // It removes and returns the head of the list. It assumes that the | |
241 // list is not empty so it will return a non-NULL value. | |
242 inline HeapRegion* remove_head(); | |
243 | |
244 // Convenience method. | |
245 inline HeapRegion* remove_head_or_null(); | |
246 | |
247 // It moves the regions from from_list to this list and empties | |
248 // from_list. The new regions will appear in the same order as they | |
2432
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
249 // were in from_list and be linked in the beginning of this list. |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
250 void add_as_head(FreeRegionList* from_list); |
2432
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
251 |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
252 // It moves the regions from from_list to this list and empties |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
253 // from_list. The new regions will appear in the same order as they |
2152 | 254 // were in from_list and be linked in the end of this list. |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
255 void add_as_tail(FreeRegionList* from_list); |
2152 | 256 |
257 // It empties the list by removing all regions from it. | |
258 void remove_all(); | |
259 | |
260 // It removes all regions in the list that are pending for removal | |
261 // (i.e., they have been tagged with "pending_removal"). The list | |
262 // must not be empty, target_count should reflect the exact number | |
263 // of regions that are pending for removal in the list, and | |
264 // target_count should be > 1 (currently, we never need to remove a | |
265 // single region using this). | |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
4830
diff
changeset
|
266 void remove_all_pending(uint target_count); |
2152 | 267 |
268 virtual void verify(); | |
269 | |
270 virtual void print_on(outputStream* out, bool print_contents = false); | |
271 }; | |
272 | |
2361 | 273 // Iterator class that provides a convenient way to iterate over the |
274 // regions of a HeapRegionLinkedList instance. | |
2152 | 275 |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
276 class FreeRegionListIterator : public StackObj { |
2152 | 277 private: |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
278 FreeRegionList* _list; |
2152 | 279 HeapRegion* _curr; |
280 | |
281 public: | |
282 bool more_available() { | |
283 return _curr != NULL; | |
284 } | |
285 | |
286 HeapRegion* get_next() { | |
287 assert(more_available(), | |
288 "get_next() should be called when more regions are available"); | |
289 | |
290 // If we are going to introduce a count in the iterator we should | |
291 // do the "cycle" check. | |
292 | |
293 HeapRegion* hr = _curr; | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
294 _list->verify_region(hr); |
2152 | 295 _curr = hr->next(); |
296 return hr; | |
297 } | |
298 | |
17736
58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
6254
diff
changeset
|
299 FreeRegionListIterator(FreeRegionList* list) |
2152 | 300 : _curr(NULL), _list(list) { |
301 _curr = list->head(); | |
302 } | |
303 }; | |
304 | |
305 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP |