annotate src/share/vm/gc_implementation/g1/heapRegionSet.hpp @ 20481:c02ec279b062

8057768: Make heap region region type in G1 HeapRegion explicit Reviewed-by: brutisso, tschatzl
author brutisso
date Tue, 16 Sep 2014 14:27:40 +0200
parents a8ea2f110d87
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
1 /*
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
4 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
7 * published by the Free Software Foundation.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
8 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
13 * accompanied this code).
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
14 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
18 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
21 * questions.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
22 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
23 */
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
24
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
27
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
28 #include "gc_implementation/g1/heapRegion.hpp"
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
29
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
30 // Large buffer for some cases where the output might be larger than normal.
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
31 #define HRS_ERR_MSG_BUFSZ 512
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
32 typedef FormatBuffer<HRS_ERR_MSG_BUFSZ> hrs_err_msg;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
33
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
34 // Set verification will be forced either if someone defines
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
35 // HEAP_REGION_SET_FORCE_VERIFY to be 1, or in builds in which
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
36 // asserts are compiled in.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
37 #ifndef HEAP_REGION_SET_FORCE_VERIFY
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
38 #define HEAP_REGION_SET_FORCE_VERIFY defined(ASSERT)
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
39 #endif // HEAP_REGION_SET_FORCE_VERIFY
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
74
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
75 // Base class for all the classes that represent heap region sets. It
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
76 // contains the basic attributes that each set needs to maintain
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
77 // (e.g., length, region num, used bytes sum) plus any shared
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
78 // functionality (e.g., verification).
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
79
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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;
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
84 bool _is_free;
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
85 HRSMtSafeChecker* _mt_safety_checker;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
86
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
87 protected:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
88 // The number of regions added to the set. If the set contains
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
89 // only humongous regions, this reflects only 'starts humongous'
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
92
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
93 const char* _name;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
94
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
95 bool _verify_in_progress;
4072
8aae2050e83e 7092309: G1: introduce old region set
tonyp
parents: 3765
diff changeset
96
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
100
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
101 // Indicates whether all regions in the set should be humongous or
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
104
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
105 // Indicates whether all regions in the set should be free or
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
106 // not. Only used during verification.
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
107 bool regions_free() { return _is_free; }
17736
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
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
117 HeapRegionSetBase(const char* name, bool humongous, bool free, HRSMtSafeChecker* mt_safety_checker);
17736
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
121
20295
3f2894c5052e 8048112: G1 Full GC needs to support the case when the very first region is not available
tschatzl
parents: 17937
diff changeset
122 uint length() const { return _count.length(); }
17736
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
137
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
138 // fill_in_ext_msg() writes the the values of the set's attributes
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
139 // in the custom err_msg (hrs_ext_msg). fill_in_ext_msg_extra()
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
140 // allows subclasses to append further information.
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
141 void fill_in_ext_msg(hrs_ext_msg* msg, const char* message);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
142
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
143 virtual void verify();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
144 void verify_start();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
145 void verify_next_region(HeapRegion* hr);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
146 void verify_end();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
147
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
148 #if HEAP_REGION_SET_FORCE_VERIFY
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
149 void verify_optional() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
150 verify();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
151 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
152 #else // HEAP_REGION_SET_FORCE_VERIFY
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
153 void verify_optional() { }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
154 #endif // HEAP_REGION_SET_FORCE_VERIFY
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
155
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
156 virtual void print_on(outputStream* out, bool print_contents = false);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
157 };
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
158
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
159 // Customized err_msg for heap region sets. Apart from a
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
160 // assert/guarantee-specific message it also prints out the values of
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
161 // the fields of the associated set. This can be very helpful in
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
162 // diagnosing failures.
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
163 class hrs_ext_msg : public hrs_err_msg {
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
164 public:
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
165 hrs_ext_msg(HeapRegionSetBase* set, const char* message) : hrs_err_msg("%s", "") {
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
166 set->fill_in_ext_msg(this, message);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
167 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
168 };
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
169
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
170 #define hrs_assert_sets_match(_set1_, _set2_) \
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
171 do { \
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
172 assert(((_set1_)->regions_humongous() == \
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
173 (_set2_)->regions_humongous()) && \
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
174 ((_set1_)->regions_free() == (_set2_)->regions_free()), \
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
175 hrs_err_msg("the contents of set %s and set %s should match", \
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
176 (_set1_)->name(), (_set2_)->name())); \
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
177 } while (0)
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
178
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
179 // This class represents heap region sets whose members are not
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
180 // explicitly tracked. It's helpful to group regions using such sets
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
181 // so that we can reason about all the region groups in the heap using
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
182 // the same interface (namely, the HeapRegionSetBase API).
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
183
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
184 class HeapRegionSet : public HeapRegionSetBase {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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):
20481
c02ec279b062 8057768: Make heap region region type in G1 HeapRegion explicit
brutisso
parents: 20377
diff changeset
187 HeapRegionSetBase(name, humongous, false /* free */, mt_safety_checker) { }
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
192 };
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
193
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
194 // A set that links all the regions added to it in a doubly-linked
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
195 // sorted list. We should try to avoid doing operations that iterate over
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
196 // such lists in performance critical paths. Typically we should
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
197 // add / remove one region at a time or concatenate two lists.
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
198
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
199 class FreeRegionListIterator;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
200
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
201 class FreeRegionList : public HeapRegionSetBase {
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
202 friend class FreeRegionListIterator;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
203
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
204 private:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
205 HeapRegion* _head;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
206 HeapRegion* _tail;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
207
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
208 // _last is used to keep track of where we added an element the last
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
209 // time. It helps to improve performance when adding several ordered items in a row.
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
210 HeapRegion* _last;
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
211
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
212 static uint _unrealistically_long_length;
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
213
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
214 inline HeapRegion* remove_from_head_impl();
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
215 inline HeapRegion* remove_from_tail_impl();
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
216
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
217 protected:
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
218 virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
219
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
220 // See the comment for HeapRegionSetBase::clear()
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
221 virtual void clear();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
222
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
223 public:
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
224 FreeRegionList(const char* name, HRSMtSafeChecker* mt_safety_checker = NULL):
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
225 HeapRegionSetBase(name, false /* humongous */, true /* empty */, mt_safety_checker) {
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
226 clear();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
227 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
228
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
229 void verify_list();
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
230
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
231 #ifdef ASSERT
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
232 bool contains(HeapRegion* hr) const {
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
233 return hr->containing_set() == this;
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
234 }
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
235 #endif
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
236
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
237 static void set_unrealistically_long_length(uint len);
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
238
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
239 // Add hr to the list. The region should not be a member of another set.
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
240 // Assumes that the list is ordered and will preserve that order. The order
20377
a8ea2f110d87 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 20336
diff changeset
241 // is determined by hrm_index.
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
242 inline void add_ordered(HeapRegion* hr);
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
243
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
244 // Removes from head or tail based on the given argument.
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
245 HeapRegion* remove_region(bool from_head);
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
246
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
247 // Merge two ordered lists. The result is also ordered. The order is
20377
a8ea2f110d87 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 20336
diff changeset
248 // determined by hrm_index.
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
249 void add_ordered(FreeRegionList* from_list);
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
250
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
251 // It empties the list by removing all regions from it.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
252 void remove_all();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
253
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
254 // Remove all (contiguous) regions from first to first + num_regions -1 from
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
255 // this list.
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
256 // Num_regions must be > 1.
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
257 void remove_starting_at(HeapRegion* first, uint num_regions);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
258
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
259 virtual void verify();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
260
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
261 virtual void print_on(outputStream* out, bool print_contents = false);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
262 };
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
263
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
264 // Iterator class that provides a convenient way to iterate over the
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
265 // regions of a FreeRegionList.
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
266
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
267 class FreeRegionListIterator : public StackObj {
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
268 private:
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
269 FreeRegionList* _list;
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
270 HeapRegion* _curr;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
271
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
272 public:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
273 bool more_available() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
274 return _curr != NULL;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
275 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
276
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
277 HeapRegion* get_next() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
278 assert(more_available(),
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
279 "get_next() should be called when more regions are available");
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
280
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
281 // If we are going to introduce a count in the iterator we should
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
282 // do the "cycle" check.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
283
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
284 HeapRegion* hr = _curr;
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
285 _list->verify_region(hr);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
286 _curr = hr->next();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
287 return hr;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
288 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
289
17773
8ee855b4e667 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 17736
diff changeset
290 FreeRegionListIterator(FreeRegionList* list) : _curr(NULL), _list(list) {
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20295
diff changeset
291 _curr = list->_head;
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
292 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
293 };
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
294
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
295 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_HPP