author | pliden |
Wed, 13 May 2015 15:16:06 +0200 | |
changeset 30764 | fec48bf5a827 |
parent 26316 | hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp@93f6b40c038b |
child 33105 | 294e48b4f704 |
permissions | -rw-r--r-- |
7923 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2011, 2015, 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_INLINE_HPP |
26 |
#define SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP |
|
7923 | 27 |
|
30764 | 28 |
#include "gc/g1/heapRegionSet.hpp" |
7923 | 29 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
30 |
inline void HeapRegionSetBase::add(HeapRegion* hr) { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
31 |
check_mt_safety(); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
32 |
assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u")); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
33 |
assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
34 |
assert(hr->prev() == NULL, hrs_ext_msg(this, "should not already be linked")); |
7923 | 35 |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
36 |
_count.increment(1u, hr->capacity()); |
7923 | 37 |
hr->set_containing_set(this); |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
38 |
verify_region(hr); |
7923 | 39 |
} |
40 |
||
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
41 |
inline void HeapRegionSetBase::remove(HeapRegion* hr) { |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
42 |
check_mt_safety(); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
43 |
verify_region(hr); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
44 |
assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
45 |
assert(hr->prev() == NULL, hrs_ext_msg(this, "should already be unlinked")); |
7923 | 46 |
|
47 |
hr->set_containing_set(NULL); |
|
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
48 |
assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition")); |
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
49 |
_count.decrement(1u, hr->capacity()); |
7923 | 50 |
} |
51 |
||
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
52 |
inline void FreeRegionList::add_ordered(HeapRegion* hr) { |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
53 |
assert((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) || |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
54 |
(length() > 0 && _head != NULL && _tail != NULL), |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
55 |
hrs_ext_msg(this, "invariant")); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
56 |
// add() will verify the region and check mt safety. |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
57 |
add(hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
58 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
59 |
// Now link the region |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
60 |
if (_head != NULL) { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
61 |
HeapRegion* curr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
62 |
|
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
63 |
if (_last != NULL && _last->hrm_index() < hr->hrm_index()) { |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
64 |
curr = _last; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
65 |
} else { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
66 |
curr = _head; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
67 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
68 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
69 |
// Find first entry with a Region Index larger than entry to insert. |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
70 |
while (curr != NULL && curr->hrm_index() < hr->hrm_index()) { |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
71 |
curr = curr->next(); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
72 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
73 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
74 |
hr->set_next(curr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
75 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
76 |
if (curr == NULL) { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
77 |
// Adding at the end |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
78 |
hr->set_prev(_tail); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
79 |
_tail->set_next(hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
80 |
_tail = hr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
81 |
} else if (curr->prev() == NULL) { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
82 |
// Adding at the beginning |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
83 |
hr->set_prev(NULL); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
84 |
_head = hr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
85 |
curr->set_prev(hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
86 |
} else { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
87 |
hr->set_prev(curr->prev()); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
88 |
hr->prev()->set_next(hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
89 |
curr->set_prev(hr); |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
90 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
91 |
} else { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
92 |
// The list was empty |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
93 |
_tail = hr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
94 |
_head = hr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
95 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
96 |
_last = hr; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
97 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
98 |
|
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
99 |
inline HeapRegion* FreeRegionList::remove_from_head_impl() { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
100 |
HeapRegion* result = _head; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
101 |
_head = result->next(); |
7923 | 102 |
if (_head == NULL) { |
103 |
_tail = NULL; |
|
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
104 |
} else { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
105 |
_head->set_prev(NULL); |
7923 | 106 |
} |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
107 |
result->set_next(NULL); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
108 |
return result; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
109 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
110 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
111 |
inline HeapRegion* FreeRegionList::remove_from_tail_impl() { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
112 |
HeapRegion* result = _tail; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
113 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
114 |
_tail = result->prev(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
115 |
if (_tail == NULL) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
116 |
_head = NULL; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
117 |
} else { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
118 |
_tail->set_next(NULL); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
119 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
120 |
result->set_prev(NULL); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
121 |
return result; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
122 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
123 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
124 |
inline HeapRegion* FreeRegionList::remove_region(bool from_head) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
125 |
check_mt_safety(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
126 |
verify_optional(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
127 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
128 |
if (is_empty()) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
129 |
return NULL; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
130 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
131 |
assert(length() > 0 && _head != NULL && _tail != NULL, |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
132 |
hrs_ext_msg(this, "invariant")); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
133 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
134 |
HeapRegion* hr; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
135 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
136 |
if (from_head) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
137 |
hr = remove_from_head_impl(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
138 |
} else { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
139 |
hr = remove_from_tail_impl(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
140 |
} |
7923 | 141 |
|
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
142 |
if (_last == hr) { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
143 |
_last = NULL; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
144 |
} |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
145 |
|
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
146 |
// remove() will verify the region and check mt safety. |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
147 |
remove(hr); |
7923 | 148 |
return hr; |
149 |
} |
|
150 |
||
30764 | 151 |
#endif // SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP |
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
152 |