comparison src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp @ 20335:eec72fa4b108

8040722: G1: Clean up usages of heap_region_containing Reviewed-by: tschatzl, jmasa
author brutisso
date Tue, 19 Aug 2014 12:39:06 +0200
parents a3953c777565
children 7848fc12602b
comparison
equal deleted inserted replaced
20334:ff3169f25621 20335:eec72fa4b108
128 inline void G1RootRegionScanClosure::do_oop_nv(T* p) { 128 inline void G1RootRegionScanClosure::do_oop_nv(T* p) {
129 T heap_oop = oopDesc::load_heap_oop(p); 129 T heap_oop = oopDesc::load_heap_oop(p);
130 if (!oopDesc::is_null(heap_oop)) { 130 if (!oopDesc::is_null(heap_oop)) {
131 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 131 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
132 HeapRegion* hr = _g1h->heap_region_containing((HeapWord*) obj); 132 HeapRegion* hr = _g1h->heap_region_containing((HeapWord*) obj);
133 if (hr != NULL) { 133 _cm->grayRoot(obj, obj->size(), _worker_id, hr);
134 _cm->grayRoot(obj, obj->size(), _worker_id, hr);
135 }
136 } 134 }
137 } 135 }
138 136
139 template <class T> 137 template <class T>
140 inline void G1Mux2Closure::do_oop_nv(T* p) { 138 inline void G1Mux2Closure::do_oop_nv(T* p) {
157 } 155 }
158 156
159 template <class T> 157 template <class T>
160 inline void G1UpdateRSOrPushRefOopClosure::do_oop_nv(T* p) { 158 inline void G1UpdateRSOrPushRefOopClosure::do_oop_nv(T* p) {
161 oop obj = oopDesc::load_decode_heap_oop(p); 159 oop obj = oopDesc::load_decode_heap_oop(p);
160 if (obj == NULL) {
161 return;
162 }
162 #ifdef ASSERT 163 #ifdef ASSERT
163 // can't do because of races 164 // can't do because of races
164 // assert(obj == NULL || obj->is_oop(), "expected an oop"); 165 // assert(obj == NULL || obj->is_oop(), "expected an oop");
165 166
166 // Do the safe subset of is_oop 167 // Do the safe subset of is_oop
167 if (obj != NULL) {
168 #ifdef CHECK_UNHANDLED_OOPS 168 #ifdef CHECK_UNHANDLED_OOPS
169 oopDesc* o = obj.obj(); 169 oopDesc* o = obj.obj();
170 #else 170 #else
171 oopDesc* o = obj; 171 oopDesc* o = obj;
172 #endif // CHECK_UNHANDLED_OOPS 172 #endif // CHECK_UNHANDLED_OOPS
173 assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned"); 173 assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
174 assert(Universe::heap()->is_in_reserved(obj), "must be in heap"); 174 assert(Universe::heap()->is_in_reserved(obj), "must be in heap");
175 }
176 #endif // ASSERT 175 #endif // ASSERT
177 176
178 assert(_from != NULL, "from region must be non-NULL"); 177 assert(_from != NULL, "from region must be non-NULL");
179 assert(_from->is_in_reserved(p), "p is not in from"); 178 assert(_from->is_in_reserved(p), "p is not in from");
180 179
181 HeapRegion* to = _g1->heap_region_containing(obj); 180 HeapRegion* to = _g1->heap_region_containing(obj);
182 if (to != NULL && _from != to) { 181 if (_from == to) {
183 // The _record_refs_into_cset flag is true during the RSet 182 // Normally this closure should only be called with cross-region references.
184 // updating part of an evacuation pause. It is false at all 183 // But since Java threads are manipulating the references concurrently and we
185 // other times: 184 // reload the values things may have changed.
186 // * rebuilding the rembered sets after a full GC 185 return;
187 // * during concurrent refinement. 186 }
188 // * updating the remembered sets of regions in the collection 187 // The _record_refs_into_cset flag is true during the RSet
189 // set in the event of an evacuation failure (when deferred 188 // updating part of an evacuation pause. It is false at all
190 // updates are enabled). 189 // other times:
191 190 // * rebuilding the remembered sets after a full GC
192 if (_record_refs_into_cset && to->in_collection_set()) { 191 // * during concurrent refinement.
193 // We are recording references that point into the collection 192 // * updating the remembered sets of regions in the collection
194 // set and this particular reference does exactly that... 193 // set in the event of an evacuation failure (when deferred
195 // If the referenced object has already been forwarded 194 // updates are enabled).
196 // to itself, we are handling an evacuation failure and 195
197 // we have already visited/tried to copy this object 196 if (_record_refs_into_cset && to->in_collection_set()) {
198 // there is no need to retry. 197 // We are recording references that point into the collection
199 if (!self_forwarded(obj)) { 198 // set and this particular reference does exactly that...
200 assert(_push_ref_cl != NULL, "should not be null"); 199 // If the referenced object has already been forwarded
201 // Push the reference in the refs queue of the G1ParScanThreadState 200 // to itself, we are handling an evacuation failure and
202 // instance for this worker thread. 201 // we have already visited/tried to copy this object
203 _push_ref_cl->do_oop(p); 202 // there is no need to retry.
204 } 203 if (!self_forwarded(obj)) {
205 204 assert(_push_ref_cl != NULL, "should not be null");
206 // Deferred updates to the CSet are either discarded (in the normal case), 205 // Push the reference in the refs queue of the G1ParScanThreadState
207 // or processed (if an evacuation failure occurs) at the end 206 // instance for this worker thread.
208 // of the collection. 207 _push_ref_cl->do_oop(p);
209 // See G1RemSet::cleanup_after_oops_into_collection_set_do(). 208 }
210 return; 209
211 } 210 // Deferred updates to the CSet are either discarded (in the normal case),
212 211 // or processed (if an evacuation failure occurs) at the end
212 // of the collection.
213 // See G1RemSet::cleanup_after_oops_into_collection_set_do().
214 } else {
213 // We either don't care about pushing references that point into the 215 // We either don't care about pushing references that point into the
214 // collection set (i.e. we're not during an evacuation pause) _or_ 216 // collection set (i.e. we're not during an evacuation pause) _or_
215 // the reference doesn't point into the collection set. Either way 217 // the reference doesn't point into the collection set. Either way
216 // we add the reference directly to the RSet of the region containing 218 // we add the reference directly to the RSet of the region containing
217 // the referenced object. 219 // the referenced object.