Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp @ 8500:992f62c457b0
-More bug fixes
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Tue, 05 Mar 2013 18:53:26 +0100 |
parents | a2f7274eb6ef |
children | 86b4965f0c9a |
rev | line source |
---|---|
2152 | 1 /* |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3394
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
2152 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP | |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP | |
27 | |
28 #include "gc_implementation/g1/heapRegionSet.hpp" | |
29 | |
30 //////////////////// HeapRegionSetBase //////////////////// | |
31 | |
32 inline void HeapRegionSetBase::update_for_addition(HeapRegion* hr) { | |
33 // Assumes the caller has already verified the region. | |
34 | |
35 _length += 1; | |
6254
a2f7274eb6ef
7114678: G1: various small fixes, code cleanup, and refactoring
tonyp
parents:
6010
diff
changeset
|
36 _region_num += hr->region_num(); |
2152 | 37 _total_used_bytes += hr->used(); |
38 } | |
39 | |
40 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) { | |
2361 | 41 hrs_assert_region_ok(this, hr, NULL); |
42 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); | |
2152 | 43 |
44 update_for_addition(hr); | |
45 hr->set_containing_set(this); | |
46 } | |
47 | |
48 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) { | |
49 // Assumes the caller has already verified the region. | |
2361 | 50 assert(_length > 0, hrs_ext_msg(this, "pre-condition")); |
2152 | 51 _length -= 1; |
52 | |
6254
a2f7274eb6ef
7114678: G1: various small fixes, code cleanup, and refactoring
tonyp
parents:
6010
diff
changeset
|
53 uint region_num_diff = hr->region_num(); |
2152 | 54 assert(region_num_diff <= _region_num, |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3394
diff
changeset
|
55 hrs_err_msg("[%s] region's region num: %u " |
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3394
diff
changeset
|
56 "should be <= region num: %u", |
2152 | 57 name(), region_num_diff, _region_num)); |
58 _region_num -= region_num_diff; | |
59 | |
60 size_t used_bytes = hr->used(); | |
61 assert(used_bytes <= _total_used_bytes, | |
2361 | 62 hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " |
2152 | 63 "should be <= used bytes: "SIZE_FORMAT, |
64 name(), used_bytes, _total_used_bytes)); | |
8500
992f62c457b0
-More bug fixes
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
6254
diff
changeset
|
65 |
992f62c457b0
-More bug fixes
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
6254
diff
changeset
|
66 //printf("[%s] region's used bytes: "SIZE_FORMAT" " |
992f62c457b0
-More bug fixes
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
6254
diff
changeset
|
67 // "should be <= used bytes: "SIZE_FORMAT"\n", |
992f62c457b0
-More bug fixes
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
6254
diff
changeset
|
68 // name(), used_bytes, _total_used_bytes); |
2152 | 69 _total_used_bytes -= used_bytes; |
8500
992f62c457b0
-More bug fixes
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
6254
diff
changeset
|
70 //printf("TOTAL USED BYTES 4 %lu\n", _total_used_bytes); |
2152 | 71 } |
72 | |
73 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { | |
2361 | 74 hrs_assert_region_ok(this, hr, this); |
75 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); | |
2152 | 76 |
77 hr->set_containing_set(NULL); | |
78 update_for_removal(hr); | |
79 } | |
80 | |
81 //////////////////// HeapRegionSet //////////////////// | |
82 | |
83 inline void HeapRegionSet::add(HeapRegion* hr) { | |
2361 | 84 hrs_assert_mt_safety_ok(this); |
2152 | 85 // add_internal() will verify the region. |
86 add_internal(hr); | |
87 } | |
88 | |
89 inline void HeapRegionSet::remove(HeapRegion* hr) { | |
2361 | 90 hrs_assert_mt_safety_ok(this); |
2152 | 91 // remove_internal() will verify the region. |
92 remove_internal(hr); | |
93 } | |
94 | |
95 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr, | |
96 HeapRegionSet* proxy_set) { | |
97 // No need to fo the MT safety check here given that this method | |
98 // does not update the contents of the set but instead accumulates | |
99 // the changes in proxy_set which is assumed to be thread-local. | |
2361 | 100 hrs_assert_sets_match(this, proxy_set); |
101 hrs_assert_region_ok(this, hr, this); | |
2152 | 102 |
103 hr->set_containing_set(NULL); | |
104 proxy_set->update_for_addition(hr); | |
105 } | |
106 | |
107 //////////////////// HeapRegionLinkedList //////////////////// | |
108 | |
2432
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
109 inline void HeapRegionLinkedList::add_as_head(HeapRegion* hr) { |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
110 hrs_assert_mt_safety_ok(this); |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
111 assert((length() == 0 && _head == NULL && _tail == NULL) || |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
112 (length() > 0 && _head != NULL && _tail != NULL), |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
113 hrs_ext_msg(this, "invariant")); |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
114 // add_internal() will verify the region. |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
115 add_internal(hr); |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
116 |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
117 // Now link the region. |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
118 if (_head != NULL) { |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
119 hr->set_next(_head); |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
120 } else { |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
121 _tail = hr; |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
122 } |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
123 _head = hr; |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
124 } |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
125 |
2152 | 126 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) { |
2361 | 127 hrs_assert_mt_safety_ok(this); |
2152 | 128 assert((length() == 0 && _head == NULL && _tail == NULL) || |
129 (length() > 0 && _head != NULL && _tail != NULL), | |
2361 | 130 hrs_ext_msg(this, "invariant")); |
2152 | 131 // add_internal() will verify the region. |
132 add_internal(hr); | |
133 | |
134 // Now link the region. | |
135 if (_tail != NULL) { | |
136 _tail->set_next(hr); | |
137 } else { | |
138 _head = hr; | |
139 } | |
140 _tail = hr; | |
141 } | |
142 | |
143 inline HeapRegion* HeapRegionLinkedList::remove_head() { | |
2361 | 144 hrs_assert_mt_safety_ok(this); |
145 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty")); | |
2152 | 146 assert(length() > 0 && _head != NULL && _tail != NULL, |
2361 | 147 hrs_ext_msg(this, "invariant")); |
2152 | 148 |
149 // We need to unlink it first. | |
150 HeapRegion* hr = _head; | |
151 _head = hr->next(); | |
152 if (_head == NULL) { | |
153 _tail = NULL; | |
154 } | |
155 hr->set_next(NULL); | |
156 | |
157 // remove_internal() will verify the region. | |
158 remove_internal(hr); | |
159 return hr; | |
160 } | |
161 | |
162 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() { | |
2361 | 163 hrs_assert_mt_safety_ok(this); |
2152 | 164 |
165 if (!is_empty()) { | |
166 return remove_head(); | |
167 } else { | |
168 return NULL; | |
169 } | |
170 } | |
171 | |
172 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP |