author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49725 | e740e1a38c96 |
child 51332 | c25572739e7c |
permissions | -rw-r--r-- |
7923 | 1 |
/* |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
7923 | 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 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_G1_HEAPREGIONSET_HPP |
26 |
#define SHARE_VM_GC_G1_HEAPREGIONSET_HPP |
|
7923 | 27 |
|
30764 | 28 |
#include "gc/g1/heapRegion.hpp" |
49725
e740e1a38c96
8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents:
49632
diff
changeset
|
29 |
#include "utilities/macros.hpp" |
7923 | 30 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
31 |
#define assert_heap_region_set(p, message) \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
32 |
do { \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
33 |
assert((p), "[%s] %s ln: %u", \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
34 |
name(), message, length()); \ |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
35 |
} while (0) |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
36 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
37 |
#define guarantee_heap_region_set(p, message) \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
38 |
do { \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
39 |
guarantee((p), "[%s] %s ln: %u", \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
40 |
name(), message, length()); \ |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
41 |
} while (0) |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
42 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
43 |
#define assert_free_region_list(p, message) \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
44 |
do { \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
45 |
assert((p), "[%s] %s ln: %u hd: " PTR_FORMAT " tl: " PTR_FORMAT, \ |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
46 |
name(), message, length(), p2i(_head), p2i(_tail)); \ |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
47 |
} while (0) |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
48 |
|
7923 | 49 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
50 |
class HRSMtSafeChecker : public CHeapObj<mtGC> { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
51 |
public: |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
52 |
virtual void check() = 0; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
53 |
}; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
54 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
55 |
class MasterFreeRegionListMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
56 |
class HumongousRegionSetMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
57 |
class OldRegionSetMtSafeChecker : public HRSMtSafeChecker { public: void check(); }; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
58 |
|
7923 | 59 |
// Base class for all the classes that represent heap region sets. It |
60 |
// contains the basic attributes that each set needs to maintain |
|
61 |
// (e.g., length, region num, used bytes sum) plus any shared |
|
62 |
// functionality (e.g., verification). |
|
63 |
||
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
64 |
class HeapRegionSetBase { |
11577
0af7e6e062a7
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
10996
diff
changeset
|
65 |
friend class VMStructs; |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
66 |
private: |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
67 |
bool _is_humongous; |
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26316
diff
changeset
|
68 |
bool _is_free; |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
69 |
HRSMtSafeChecker* _mt_safety_checker; |
7923 | 70 |
|
71 |
protected: |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
72 |
// The number of regions in to the set. |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
73 |
uint _length; |
7923 | 74 |
|
75 |
const char* _name; |
|
76 |
||
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
77 |
bool _verify_in_progress; |
10996 | 78 |
|
7923 | 79 |
// verify_region() is used to ensure that the contents of a region |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
80 |
// added to / removed from a set are consistent. |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
81 |
void verify_region(HeapRegion* hr) PRODUCT_RETURN; |
7923 | 82 |
|
83 |
// Indicates whether all regions in the set should be humongous or |
|
84 |
// not. Only used during verification. |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
85 |
bool regions_humongous() { return _is_humongous; } |
7923 | 86 |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26316
diff
changeset
|
87 |
// Indicates whether all regions in the set should be free or |
7923 | 88 |
// not. Only used during verification. |
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26316
diff
changeset
|
89 |
bool regions_free() { return _is_free; } |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
90 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
91 |
void check_mt_safety() { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
92 |
if (_mt_safety_checker != NULL) { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
93 |
_mt_safety_checker->check(); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
94 |
} |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
95 |
} |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
96 |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26316
diff
changeset
|
97 |
HeapRegionSetBase(const char* name, bool humongous, bool free, HRSMtSafeChecker* mt_safety_checker); |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
98 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
99 |
public: |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
100 |
const char* name() { return _name; } |
7923 | 101 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
102 |
uint length() const { return _length; } |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
103 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
104 |
bool is_empty() { return _length == 0; } |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
105 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
106 |
// It updates the fields of the set to reflect hr being added to |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
107 |
// the set and tags the region appropriately. |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
108 |
inline void add(HeapRegion* hr); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
109 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
110 |
// It updates the fields of the set to reflect hr being removed |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
111 |
// from the set and tags the region appropriately. |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
112 |
inline void remove(HeapRegion* hr); |
7923 | 113 |
|
114 |
virtual void verify(); |
|
115 |
void verify_start(); |
|
116 |
void verify_next_region(HeapRegion* hr); |
|
117 |
void verify_end(); |
|
118 |
||
49725
e740e1a38c96
8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents:
49632
diff
changeset
|
119 |
void verify_optional() { DEBUG_ONLY(verify();) } |
7923 | 120 |
|
121 |
virtual void print_on(outputStream* out, bool print_contents = false); |
|
122 |
}; |
|
123 |
||
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
124 |
#define hrs_assert_sets_match(_set1_, _set2_) \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
125 |
do { \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
126 |
assert(((_set1_)->regions_humongous() == (_set2_)->regions_humongous()) && \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
127 |
((_set1_)->regions_free() == (_set2_)->regions_free()), \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
128 |
"the contents of set %s and set %s should match", \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
129 |
(_set1_)->name(), \ |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
30764
diff
changeset
|
130 |
(_set2_)->name()); \ |
7923 | 131 |
} while (0) |
132 |
||
133 |
// This class represents heap region sets whose members are not |
|
134 |
// explicitly tracked. It's helpful to group regions using such sets |
|
135 |
// so that we can reason about all the region groups in the heap using |
|
136 |
// the same interface (namely, the HeapRegionSetBase API). |
|
137 |
||
138 |
class HeapRegionSet : public HeapRegionSetBase { |
|
139 |
public: |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
140 |
HeapRegionSet(const char* name, bool humongous, HRSMtSafeChecker* mt_safety_checker): |
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26316
diff
changeset
|
141 |
HeapRegionSetBase(name, humongous, false /* free */, mt_safety_checker) { } |
7923 | 142 |
|
35065
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
143 |
void bulk_remove(const uint removed) { |
b4ff0249c092
8144996: Replace the HeapRegionSetCount class with an uint
david
parents:
35061
diff
changeset
|
144 |
_length -= removed; |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
145 |
} |
7923 | 146 |
}; |
147 |
||
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
148 |
// A set that links all the regions added to it in a doubly-linked |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
149 |
// sorted list. We should try to avoid doing operations that iterate over |
7923 | 150 |
// such lists in performance critical paths. Typically we should |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
151 |
// add / remove one region at a time or concatenate two lists. |
7923 | 152 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
153 |
class FreeRegionListIterator; |
7923 | 154 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
155 |
class FreeRegionList : public HeapRegionSetBase { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
156 |
friend class FreeRegionListIterator; |
7923 | 157 |
|
158 |
private: |
|
159 |
HeapRegion* _head; |
|
160 |
HeapRegion* _tail; |
|
161 |
||
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
162 |
// _last is used to keep track of where we added an element the last |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
163 |
// time. It helps to improve performance when adding several ordered items in a row. |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
164 |
HeapRegion* _last; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
165 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
166 |
static uint _unrealistically_long_length; |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
167 |
|
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
168 |
inline HeapRegion* remove_from_head_impl(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
169 |
inline HeapRegion* remove_from_tail_impl(); |
7923 | 170 |
|
171 |
protected: |
|
172 |
// See the comment for HeapRegionSetBase::clear() |
|
173 |
virtual void clear(); |
|
174 |
||
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
175 |
public: |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
176 |
FreeRegionList(const char* name, HRSMtSafeChecker* mt_safety_checker = NULL): |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
177 |
HeapRegionSetBase(name, false /* humongous */, true /* empty */, mt_safety_checker) { |
7923 | 178 |
clear(); |
179 |
} |
|
180 |
||
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
181 |
void verify_list(); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
182 |
|
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
183 |
#ifdef ASSERT |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
184 |
bool contains(HeapRegion* hr) const { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
185 |
return hr->containing_set() == this; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
186 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
187 |
#endif |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
188 |
|
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
189 |
static void set_unrealistically_long_length(uint len); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
190 |
|
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
191 |
// Add hr to the list. The region should not be a member of another set. |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
192 |
// Assumes that the list is ordered and will preserve that order. The order |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
193 |
// is determined by hrm_index. |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
194 |
inline void add_ordered(HeapRegion* hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
195 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
196 |
// Removes from head or tail based on the given argument. |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
197 |
HeapRegion* remove_region(bool from_head); |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
198 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
199 |
// Merge two ordered lists. The result is also ordered. The order is |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
200 |
// determined by hrm_index. |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
201 |
void add_ordered(FreeRegionList* from_list); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
202 |
|
7923 | 203 |
// It empties the list by removing all regions from it. |
204 |
void remove_all(); |
|
205 |
||
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
206 |
// Remove all (contiguous) regions from first to first + num_regions -1 from |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
207 |
// this list. |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
208 |
// Num_regions must be > 1. |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
209 |
void remove_starting_at(HeapRegion* first, uint num_regions); |
7923 | 210 |
|
211 |
virtual void verify(); |
|
212 |
}; |
|
213 |
||
8680 | 214 |
// Iterator class that provides a convenient way to iterate over the |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
215 |
// regions of a FreeRegionList. |
7923 | 216 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
217 |
class FreeRegionListIterator : public StackObj { |
7923 | 218 |
private: |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
219 |
FreeRegionList* _list; |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
220 |
HeapRegion* _curr; |
7923 | 221 |
|
222 |
public: |
|
223 |
bool more_available() { |
|
224 |
return _curr != NULL; |
|
225 |
} |
|
226 |
||
227 |
HeapRegion* get_next() { |
|
228 |
assert(more_available(), |
|
229 |
"get_next() should be called when more regions are available"); |
|
230 |
||
231 |
// If we are going to introduce a count in the iterator we should |
|
232 |
// do the "cycle" check. |
|
233 |
||
234 |
HeapRegion* hr = _curr; |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
235 |
_list->verify_region(hr); |
7923 | 236 |
_curr = hr->next(); |
237 |
return hr; |
|
238 |
} |
|
239 |
||
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
240 |
FreeRegionListIterator(FreeRegionList* list) : _curr(NULL), _list(list) { |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
241 |
_curr = list->_head; |
7923 | 242 |
} |
243 |
}; |
|
244 |
||
30764 | 245 |
#endif // SHARE_VM_GC_G1_HEAPREGIONSET_HPP |