author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 33753 | 3add06d0880f |
child 35065 | b4ff0249c092 |
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(); |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
32 |
assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set"); |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
33 |
assert_heap_region_set(hr->next() == NULL, "should not already be linked"); |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
34 |
assert_heap_region_set(hr->prev() == NULL, "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); |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
44 |
assert_heap_region_set(hr->next() == NULL, "should already be unlinked"); |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
45 |
assert_heap_region_set(hr->prev() == NULL, "should already be unlinked"); |
7923 | 46 |
|
47 |
hr->set_containing_set(NULL); |
|
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
48 |
assert_heap_region_set(_count.length() > 0, "pre-condition"); |
23450
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) { |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
53 |
assert_free_region_list((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) || |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
54 |
(length() > 0 && _head != NULL && _tail != NULL), |
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
55 |
"invariant"); |
23471
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 |
} |
33753
3add06d0880f
8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents:
33105
diff
changeset
|
131 |
assert_free_region_list(length() > 0 && _head != NULL && _tail != NULL, "invariant"); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
132 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
133 |
HeapRegion* hr; |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
134 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
135 |
if (from_head) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
136 |
hr = remove_from_head_impl(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
137 |
} else { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
138 |
hr = remove_from_tail_impl(); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
23857
diff
changeset
|
139 |
} |
7923 | 140 |
|
23471
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
141 |
if (_last == hr) { |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
142 |
_last = NULL; |
ec9427262f0a
8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents:
23450
diff
changeset
|
143 |
} |
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 |
// remove() will verify the region and check mt safety. |
23450
c7c6202fc7e2
8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents:
13336
diff
changeset
|
146 |
remove(hr); |
7923 | 147 |
return hr; |
148 |
} |
|
149 |
||
30764 | 150 |
#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
|
151 |