Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp @ 4097:dc467e8b2c5e
7112743: G1: Reduce overhead of marking closure during evacuation pauses
Summary: Parallelize the serial code that was used to mark objects reachable from survivor objects in the collection set. Some minor improvments in the timers used to track the freeing of the collection set along with some tweaks to PrintGCDetails.
Reviewed-by: tonyp, brutisso
author | johnc |
---|---|
date | Thu, 17 Nov 2011 12:40:15 -0800 |
parents | 3be7439273c5 |
children | 720b6a76dd9d |
rev | line source |
---|---|
2152 | 1 /* |
3860
3be7439273c5
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
2432
diff
changeset
|
2 * Copyright (c) 2011, 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; | |
36 if (!hr->isHumongous()) { | |
37 _region_num += 1; | |
38 } else { | |
39 _region_num += calculate_region_num(hr); | |
40 } | |
41 _total_used_bytes += hr->used(); | |
42 } | |
43 | |
44 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) { | |
2361 | 45 hrs_assert_region_ok(this, hr, NULL); |
46 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); | |
2152 | 47 |
48 update_for_addition(hr); | |
49 hr->set_containing_set(this); | |
50 } | |
51 | |
52 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) { | |
53 // Assumes the caller has already verified the region. | |
2361 | 54 assert(_length > 0, hrs_ext_msg(this, "pre-condition")); |
2152 | 55 _length -= 1; |
56 | |
57 size_t region_num_diff; | |
58 if (!hr->isHumongous()) { | |
59 region_num_diff = 1; | |
60 } else { | |
61 region_num_diff = calculate_region_num(hr); | |
62 } | |
63 assert(region_num_diff <= _region_num, | |
2361 | 64 hrs_err_msg("[%s] region's region num: "SIZE_FORMAT" " |
2152 | 65 "should be <= region num: "SIZE_FORMAT, |
66 name(), region_num_diff, _region_num)); | |
67 _region_num -= region_num_diff; | |
68 | |
69 size_t used_bytes = hr->used(); | |
70 assert(used_bytes <= _total_used_bytes, | |
2361 | 71 hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " |
2152 | 72 "should be <= used bytes: "SIZE_FORMAT, |
73 name(), used_bytes, _total_used_bytes)); | |
74 _total_used_bytes -= used_bytes; | |
75 } | |
76 | |
77 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { | |
2361 | 78 hrs_assert_region_ok(this, hr, this); |
79 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); | |
2152 | 80 |
81 hr->set_containing_set(NULL); | |
82 update_for_removal(hr); | |
83 } | |
84 | |
85 //////////////////// HeapRegionSet //////////////////// | |
86 | |
87 inline void HeapRegionSet::add(HeapRegion* hr) { | |
2361 | 88 hrs_assert_mt_safety_ok(this); |
2152 | 89 // add_internal() will verify the region. |
90 add_internal(hr); | |
91 } | |
92 | |
93 inline void HeapRegionSet::remove(HeapRegion* hr) { | |
2361 | 94 hrs_assert_mt_safety_ok(this); |
2152 | 95 // remove_internal() will verify the region. |
96 remove_internal(hr); | |
97 } | |
98 | |
99 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr, | |
100 HeapRegionSet* proxy_set) { | |
101 // No need to fo the MT safety check here given that this method | |
102 // does not update the contents of the set but instead accumulates | |
103 // the changes in proxy_set which is assumed to be thread-local. | |
2361 | 104 hrs_assert_sets_match(this, proxy_set); |
105 hrs_assert_region_ok(this, hr, this); | |
2152 | 106 |
107 hr->set_containing_set(NULL); | |
108 proxy_set->update_for_addition(hr); | |
109 } | |
110 | |
111 //////////////////// HeapRegionLinkedList //////////////////// | |
112 | |
2432
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 (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
|
117 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
|
118 // 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
|
119 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
|
120 |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
121 // 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
|
122 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
|
123 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
|
124 } else { |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
125 _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
|
126 } |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
127 _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
|
128 } |
455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents:
2361
diff
changeset
|
129 |
2152 | 130 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) { |
2361 | 131 hrs_assert_mt_safety_ok(this); |
2152 | 132 assert((length() == 0 && _head == NULL && _tail == NULL) || |
133 (length() > 0 && _head != NULL && _tail != NULL), | |
2361 | 134 hrs_ext_msg(this, "invariant")); |
2152 | 135 // add_internal() will verify the region. |
136 add_internal(hr); | |
137 | |
138 // Now link the region. | |
139 if (_tail != NULL) { | |
140 _tail->set_next(hr); | |
141 } else { | |
142 _head = hr; | |
143 } | |
144 _tail = hr; | |
145 } | |
146 | |
147 inline HeapRegion* HeapRegionLinkedList::remove_head() { | |
2361 | 148 hrs_assert_mt_safety_ok(this); |
149 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty")); | |
2152 | 150 assert(length() > 0 && _head != NULL && _tail != NULL, |
2361 | 151 hrs_ext_msg(this, "invariant")); |
2152 | 152 |
153 // We need to unlink it first. | |
154 HeapRegion* hr = _head; | |
155 _head = hr->next(); | |
156 if (_head == NULL) { | |
157 _tail = NULL; | |
158 } | |
159 hr->set_next(NULL); | |
160 | |
161 // remove_internal() will verify the region. | |
162 remove_internal(hr); | |
163 return hr; | |
164 } | |
165 | |
166 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() { | |
2361 | 167 hrs_assert_mt_safety_ok(this); |
2152 | 168 |
169 if (!is_empty()) { | |
170 return remove_head(); | |
171 } else { | |
172 return NULL; | |
173 } | |
174 } | |
175 | |
176 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP |