Print this page
rev 3463 : 7114678: G1: various small fixes, code cleanup, and refactoring
Summary: Various cleanups as a prelude to introducing iterators for HeapRegions.
Reviewed-by: johnc
Contributed-by: tonyp
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp
+++ new/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp
1 1 /*
2 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_INLINE_HPP
26 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_INLINE_HPP
27 27
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
28 28 #include "gc_implementation/g1/concurrentMark.inline.hpp"
29 29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 30 #include "gc_implementation/g1/g1OopClosures.hpp"
31 31 #include "gc_implementation/g1/g1RemSet.hpp"
32 32
33 33 /*
34 34 * This really ought to be an inline function, but apparently the C++
35 35 * compiler sometimes sees fit to ignore inline declarations. Sigh.
36 36 */
37 37
38 -// This must a ifdef'ed because the counting it controls is in a
39 -// perf-critical inner loop.
40 -#define FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT 0
41 -
42 38 template <class T>
43 39 inline void FilterIntoCSClosure::do_oop_nv(T* p) {
44 40 T heap_oop = oopDesc::load_heap_oop(p);
45 41 if (!oopDesc::is_null(heap_oop) &&
46 42 _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop))) {
47 43 _oc->do_oop(p);
48 -#if FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT
49 - if (_dcto_cl != NULL)
50 - _dcto_cl->incr_count();
51 -#endif
52 44 }
53 45 }
54 46
55 -#define FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT 0
56 -
57 47 template <class T>
58 48 inline void FilterOutOfRegionClosure::do_oop_nv(T* p) {
59 49 T heap_oop = oopDesc::load_heap_oop(p);
60 50 if (!oopDesc::is_null(heap_oop)) {
61 51 HeapWord* obj_hw = (HeapWord*)oopDesc::decode_heap_oop_not_null(heap_oop);
62 52 if (obj_hw < _r_bottom || obj_hw >= _r_end) {
63 53 _oc->do_oop(p);
64 -#if FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT
65 - _out_of_region++;
66 -#endif
67 54 }
68 55 }
69 56 }
70 57
71 58 // This closure is applied to the fields of the objects that have just been copied.
72 59 template <class T>
73 60 inline void G1ParScanClosure::do_oop_nv(T* p) {
74 61 T heap_oop = oopDesc::load_heap_oop(p);
75 62
76 63 if (!oopDesc::is_null(heap_oop)) {
77 64 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
78 65 if (_g1->in_cset_fast_test(obj)) {
79 66 // We're not going to even bother checking whether the object is
80 67 // already forwarded or not, as this usually causes an immediate
81 68 // stall. We'll try to prefetch the object (for write, given that
82 69 // we might need to install the forwarding reference) and we'll
83 70 // get back to it when pop it from the queue
84 71 Prefetch::write(obj->mark_addr(), 0);
85 72 Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
86 73
87 74 // slightly paranoid test; I'm trying to catch potential
88 75 // problems before we go into push_on_queue to know where the
89 76 // problem is coming from
90 77 assert((obj == oopDesc::load_decode_heap_oop(p)) ||
91 78 (obj->is_forwarded() &&
92 79 obj->forwardee() == oopDesc::load_decode_heap_oop(p)),
93 80 "p should still be pointing to obj or to its forwardee");
94 81
95 82 _par_scan_state->push_on_queue(p);
96 83 } else {
97 84 _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
98 85 }
99 86 }
100 87 }
101 88
102 89 template <class T>
103 90 inline void G1ParPushHeapRSClosure::do_oop_nv(T* p) {
104 91 T heap_oop = oopDesc::load_heap_oop(p);
105 92
106 93 if (!oopDesc::is_null(heap_oop)) {
107 94 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
108 95 if (_g1->in_cset_fast_test(obj)) {
109 96 Prefetch::write(obj->mark_addr(), 0);
110 97 Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
111 98
112 99 // Place on the references queue
113 100 _par_scan_state->push_on_queue(p);
114 101 }
115 102 }
116 103 }
117 104
118 105 template <class T>
119 106 inline void G1CMOopClosure::do_oop_nv(T* p) {
120 107 assert(_g1h->is_in_g1_reserved((HeapWord*) p), "invariant");
121 108 assert(!_g1h->is_on_master_free_list(
122 109 _g1h->heap_region_containing((HeapWord*) p)), "invariant");
123 110
124 111 oop obj = oopDesc::load_decode_heap_oop(p);
125 112 if (_cm->verbose_high()) {
126 113 gclog_or_tty->print_cr("[%d] we're looking at location "
127 114 "*"PTR_FORMAT" = "PTR_FORMAT,
128 115 _task->task_id(), p, (void*) obj);
129 116 }
130 117 _task->deal_with_reference(obj);
131 118 }
132 119
133 120 template <class T>
134 121 inline void G1RootRegionScanClosure::do_oop_nv(T* p) {
135 122 T heap_oop = oopDesc::load_heap_oop(p);
136 123 if (!oopDesc::is_null(heap_oop)) {
137 124 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
138 125 HeapRegion* hr = _g1h->heap_region_containing((HeapWord*) obj);
139 126 if (hr != NULL) {
140 127 _cm->grayRoot(obj, obj->size(), _worker_id, hr);
141 128 }
142 129 }
143 130 }
144 131
145 132 template <class T>
146 133 inline void G1Mux2Closure::do_oop_nv(T* p) {
147 134 // Apply first closure; then apply the second.
148 135 _c1->do_oop(p);
149 136 _c2->do_oop(p);
150 137 }
151 138
152 139 template <class T>
153 140 inline void G1TriggerClosure::do_oop_nv(T* p) {
154 141 // Record that this closure was actually applied (triggered).
155 142 _triggered = true;
156 143 }
157 144
158 145 template <class T>
159 146 inline void G1InvokeIfNotTriggeredClosure::do_oop_nv(T* p) {
160 147 if (!_trigger_cl->triggered()) {
161 148 _oop_cl->do_oop(p);
162 149 }
163 150 }
164 151
165 152 template <class T>
166 153 inline void G1UpdateRSOrPushRefOopClosure::do_oop_nv(T* p) {
167 154 oop obj = oopDesc::load_decode_heap_oop(p);
168 155 #ifdef ASSERT
169 156 // can't do because of races
170 157 // assert(obj == NULL || obj->is_oop(), "expected an oop");
171 158
172 159 // Do the safe subset of is_oop
173 160 if (obj != NULL) {
174 161 #ifdef CHECK_UNHANDLED_OOPS
175 162 oopDesc* o = obj.obj();
176 163 #else
177 164 oopDesc* o = obj;
178 165 #endif // CHECK_UNHANDLED_OOPS
179 166 assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
180 167 assert(Universe::heap()->is_in_reserved(obj), "must be in heap");
181 168 }
182 169 #endif // ASSERT
183 170
184 171 assert(_from != NULL, "from region must be non-NULL");
185 172
186 173 HeapRegion* to = _g1->heap_region_containing(obj);
187 174 if (to != NULL && _from != to) {
188 175 // The _record_refs_into_cset flag is true during the RSet
189 176 // updating part of an evacuation pause. It is false at all
190 177 // other times:
191 178 // * rebuilding the rembered sets after a full GC
192 179 // * during concurrent refinement.
193 180 // * updating the remembered sets of regions in the collection
194 181 // set in the event of an evacuation failure (when deferred
195 182 // updates are enabled).
196 183
197 184 if (_record_refs_into_cset && to->in_collection_set()) {
198 185 // We are recording references that point into the collection
199 186 // set and this particular reference does exactly that...
200 187 // If the referenced object has already been forwarded
201 188 // to itself, we are handling an evacuation failure and
202 189 // we have already visited/tried to copy this object
203 190 // there is no need to retry.
204 191 if (!self_forwarded(obj)) {
205 192 assert(_push_ref_cl != NULL, "should not be null");
206 193 // Push the reference in the refs queue of the G1ParScanThreadState
207 194 // instance for this worker thread.
208 195 _push_ref_cl->do_oop(p);
209 196 }
210 197
211 198 // Deferred updates to the CSet are either discarded (in the normal case),
212 199 // or processed (if an evacuation failure occurs) at the end
213 200 // of the collection.
214 201 // See G1RemSet::cleanup_after_oops_into_collection_set_do().
215 202 } else {
216 203 // We either don't care about pushing references that point into the
217 204 // collection set (i.e. we're not during an evacuation pause) _or_
218 205 // the reference doesn't point into the collection set. Either way
219 206 // we add the reference directly to the RSet of the region containing
220 207 // the referenced object.
221 208 _g1_rem_set->par_write_ref(_from, p, _worker_i);
222 209 }
223 210 }
224 211 }
225 212
226 213 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_INLINE_HPP
↓ open down ↓ |
150 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX