Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 3979:4dfb2df418f2
6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
author | johnc |
---|---|
date | Thu, 22 Sep 2011 10:57:37 -0700 |
parents | f0ecbe78fc7b |
children | 811ec3d0833b |
comparison
equal
deleted
inserted
replaced
3978:f0ecbe78fc7b | 3979:4dfb2df418f2 |
---|---|
43 HeapRegion* hr, OopClosure* cl, | 43 HeapRegion* hr, OopClosure* cl, |
44 CardTableModRefBS::PrecisionStyle precision, | 44 CardTableModRefBS::PrecisionStyle precision, |
45 FilterKind fk) : | 45 FilterKind fk) : |
46 ContiguousSpaceDCTOC(hr, cl, precision, NULL), | 46 ContiguousSpaceDCTOC(hr, cl, precision, NULL), |
47 _hr(hr), _fk(fk), _g1(g1) | 47 _hr(hr), _fk(fk), _g1(g1) |
48 {} | 48 { } |
49 | 49 |
50 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, | 50 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, |
51 OopClosure* oc) : | 51 OopClosure* oc) : |
52 _r_bottom(r->bottom()), _r_end(r->end()), | 52 _r_bottom(r->bottom()), _r_end(r->end()), |
53 _oc(oc), _out_of_region(0) | 53 _oc(oc), _out_of_region(0) |
212 G1CollectedHeap* g1h = _g1; | 212 G1CollectedHeap* g1h = _g1; |
213 | 213 |
214 int oop_size; | 214 int oop_size; |
215 | 215 |
216 OopClosure* cl2 = cl; | 216 OopClosure* cl2 = cl; |
217 FilterIntoCSClosure intoCSFilt(this, g1h, cl); | 217 |
218 // If we are scanning the remembered sets looking for refs | |
219 // into the collection set during an evacuation pause then | |
220 // we will want to 'discover' reference objects that point | |
221 // to referents in the collection set. | |
222 // | |
223 // Unfortunately it is an instance of FilterIntoCSClosure | |
224 // that is iterated over the reference fields of oops in | |
225 // mr (and not the G1ParPushHeapRSClosure - which is the | |
226 // cl parameter). | |
227 // If we set the _ref_processor field in the FilterIntoCSClosure | |
228 // instance, all the reference objects that are walked | |
229 // (regardless of whether their referent object's are in | |
230 // the cset) will be 'discovered'. | |
231 // | |
232 // The G1STWIsAlive closure considers a referent object that | |
233 // is outside the cset as alive. The G1CopyingKeepAliveClosure | |
234 // skips referents that are not in the cset. | |
235 // | |
236 // Therefore reference objects in mr with a referent that is | |
237 // outside the cset should be OK. | |
238 | |
239 ReferenceProcessor* rp = _cl->_ref_processor; | |
240 if (rp != NULL) { | |
241 assert(rp == _g1->ref_processor_stw(), "should be stw"); | |
242 assert(_fk == IntoCSFilterKind, "should be looking for refs into CS"); | |
243 } | |
244 | |
245 FilterIntoCSClosure intoCSFilt(this, g1h, cl, rp); | |
218 FilterOutOfRegionClosure outOfRegionFilt(_hr, cl); | 246 FilterOutOfRegionClosure outOfRegionFilt(_hr, cl); |
247 | |
219 switch (_fk) { | 248 switch (_fk) { |
220 case IntoCSFilterKind: cl2 = &intoCSFilt; break; | 249 case IntoCSFilterKind: cl2 = &intoCSFilt; break; |
221 case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break; | 250 case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break; |
222 } | 251 } |
223 | 252 |
237 // We replicate the loop below for several kinds of possible filters. | 266 // We replicate the loop below for several kinds of possible filters. |
238 switch (_fk) { | 267 switch (_fk) { |
239 case NoFilterKind: | 268 case NoFilterKind: |
240 bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top); | 269 bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top); |
241 break; | 270 break; |
271 | |
242 case IntoCSFilterKind: { | 272 case IntoCSFilterKind: { |
243 FilterIntoCSClosure filt(this, g1h, cl); | 273 FilterIntoCSClosure filt(this, g1h, cl, rp); |
244 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); | 274 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
245 break; | 275 break; |
246 } | 276 } |
277 | |
247 case OutOfRegionFilterKind: { | 278 case OutOfRegionFilterKind: { |
248 FilterOutOfRegionClosure filt(_hr, cl); | 279 FilterOutOfRegionClosure filt(_hr, cl); |
249 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); | 280 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
250 break; | 281 break; |
251 } | 282 } |
283 | |
252 default: | 284 default: |
253 ShouldNotReachHere(); | 285 ShouldNotReachHere(); |
254 } | 286 } |
255 | 287 |
256 // Last object. Need to do dead-obj filtering here too. | 288 // Last object. Need to do dead-obj filtering here too. |
481 | 513 |
482 HeapRegion:: | 514 HeapRegion:: |
483 HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray, | 515 HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray, |
484 MemRegion mr, bool is_zeroed) | 516 MemRegion mr, bool is_zeroed) |
485 : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed), | 517 : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed), |
486 _next_fk(HeapRegionDCTOC::NoFilterKind), _hrs_index(hrs_index), | 518 _hrs_index(hrs_index), |
487 _humongous_type(NotHumongous), _humongous_start_region(NULL), | 519 _humongous_type(NotHumongous), _humongous_start_region(NULL), |
488 _in_collection_set(false), | 520 _in_collection_set(false), |
489 _next_in_special_set(NULL), _orig_end(NULL), | 521 _next_in_special_set(NULL), _orig_end(NULL), |
490 _claimed(InitialClaimValue), _evacuation_failed(false), | 522 _claimed(InitialClaimValue), _evacuation_failed(false), |
491 _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1), | 523 _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1), |