< prev index next >

src/share/vm/gc/g1/g1RemSet.cpp

Print this page
rev 10742 : Make fields used in lock-free algorithms volatile


 206 
 207   _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
 208   _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, scanRScl.strong_code_root_scan_time_sec());
 209 
 210   return scanRScl.cards_done();
 211 }
 212 
 213 // Closure used for updating RSets and recording references that
 214 // point into the collection set. Only called during an
 215 // evacuation pause.
 216 
 217 class RefineRecordRefsIntoCSCardTableEntryClosure: public CardTableEntryClosure {
 218   G1RemSet* _g1rs;
 219   DirtyCardQueue* _into_cset_dcq;
 220 public:
 221   RefineRecordRefsIntoCSCardTableEntryClosure(G1CollectedHeap* g1h,
 222                                               DirtyCardQueue* into_cset_dcq) :
 223     _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq)
 224   {}
 225 
 226   bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
 227     // The only time we care about recording cards that
 228     // contain references that point into the collection set
 229     // is during RSet updating within an evacuation pause.
 230     // In this case worker_i should be the id of a GC worker thread.
 231     assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
 232     assert(worker_i < ParallelGCThreads, "should be a GC worker");
 233 
 234     if (_g1rs->refine_card(card_ptr, worker_i, true)) {
 235       // 'card_ptr' contains references that point into the collection
 236       // set. We need to record the card in the DCQS
 237       // (_into_cset_dirty_card_queue_set)
 238       // that's used for that purpose.
 239       //
 240       // Enqueue the card
 241       _into_cset_dcq->enqueue(card_ptr);
 242     }
 243     return true;
 244   }
 245 };
 246 


 349                                                              OopClosure* oop_cl)  :
 350   _trigger_cl(t_cl), _oop_cl(oop_cl) { }
 351 
 352 G1Mux2Closure::G1Mux2Closure(OopClosure *c1, OopClosure *c2) :
 353   _c1(c1), _c2(c2) { }
 354 
 355 G1UpdateRSOrPushRefOopClosure::
 356 G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
 357                               G1RemSet* rs,
 358                               G1ParPushHeapRSClosure* push_ref_cl,
 359                               bool record_refs_into_cset,
 360                               uint worker_i) :
 361   _g1(g1h), _g1_rem_set(rs), _from(NULL),
 362   _record_refs_into_cset(record_refs_into_cset),
 363   _push_ref_cl(push_ref_cl), _worker_i(worker_i) { }
 364 
 365 // Returns true if the given card contains references that point
 366 // into the collection set, if we're checking for such references;
 367 // false otherwise.
 368 
 369 bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i,
 370                            bool check_for_refs_into_cset) {
 371   assert(_g1->is_in_exact(_ct_bs->addr_for(card_ptr)),
 372          "Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap",
 373          p2i(card_ptr),
 374          _ct_bs->index_for(_ct_bs->addr_for(card_ptr)),
 375          p2i(_ct_bs->addr_for(card_ptr)),
 376          _g1->addr_to_region(_ct_bs->addr_for(card_ptr)));
 377 
 378   // If the card is no longer dirty, nothing to do.
 379   if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
 380     // No need to return that this card contains refs that point
 381     // into the collection set.
 382     return false;
 383   }
 384 
 385   // Construct the region representing the card.
 386   HeapWord* start = _ct_bs->addr_for(card_ptr);
 387   // And find the region containing it.
 388   HeapRegion* r = _g1->heap_region_containing(start);
 389 
 390   // Why do we have to check here whether a card is on a young region,
 391   // given that we dirty young regions and, as a result, the
 392   // post-barrier is supposed to filter them out and never to enqueue
 393   // them? When we allocate a new region as the "allocation region" we




 206 
 207   _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
 208   _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, scanRScl.strong_code_root_scan_time_sec());
 209 
 210   return scanRScl.cards_done();
 211 }
 212 
 213 // Closure used for updating RSets and recording references that
 214 // point into the collection set. Only called during an
 215 // evacuation pause.
 216 
 217 class RefineRecordRefsIntoCSCardTableEntryClosure: public CardTableEntryClosure {
 218   G1RemSet* _g1rs;
 219   DirtyCardQueue* _into_cset_dcq;
 220 public:
 221   RefineRecordRefsIntoCSCardTableEntryClosure(G1CollectedHeap* g1h,
 222                                               DirtyCardQueue* into_cset_dcq) :
 223     _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq)
 224   {}
 225 
 226   bool do_card_ptr(volatile jbyte* card_ptr, uint worker_i) {
 227     // The only time we care about recording cards that
 228     // contain references that point into the collection set
 229     // is during RSet updating within an evacuation pause.
 230     // In this case worker_i should be the id of a GC worker thread.
 231     assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
 232     assert(worker_i < ParallelGCThreads, "should be a GC worker");
 233 
 234     if (_g1rs->refine_card(card_ptr, worker_i, true)) {
 235       // 'card_ptr' contains references that point into the collection
 236       // set. We need to record the card in the DCQS
 237       // (_into_cset_dirty_card_queue_set)
 238       // that's used for that purpose.
 239       //
 240       // Enqueue the card
 241       _into_cset_dcq->enqueue(card_ptr);
 242     }
 243     return true;
 244   }
 245 };
 246 


 349                                                              OopClosure* oop_cl)  :
 350   _trigger_cl(t_cl), _oop_cl(oop_cl) { }
 351 
 352 G1Mux2Closure::G1Mux2Closure(OopClosure *c1, OopClosure *c2) :
 353   _c1(c1), _c2(c2) { }
 354 
 355 G1UpdateRSOrPushRefOopClosure::
 356 G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
 357                               G1RemSet* rs,
 358                               G1ParPushHeapRSClosure* push_ref_cl,
 359                               bool record_refs_into_cset,
 360                               uint worker_i) :
 361   _g1(g1h), _g1_rem_set(rs), _from(NULL),
 362   _record_refs_into_cset(record_refs_into_cset),
 363   _push_ref_cl(push_ref_cl), _worker_i(worker_i) { }
 364 
 365 // Returns true if the given card contains references that point
 366 // into the collection set, if we're checking for such references;
 367 // false otherwise.
 368 
 369 bool G1RemSet::refine_card(volatile jbyte* card_ptr, uint worker_i,
 370                            bool check_for_refs_into_cset) {
 371   assert(_g1->is_in_exact(_ct_bs->addr_for(card_ptr)),
 372          "Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap",
 373          p2i((jbyte*)card_ptr),
 374          _ct_bs->index_for(_ct_bs->addr_for(card_ptr)),
 375          p2i(_ct_bs->addr_for(card_ptr)),
 376          _g1->addr_to_region(_ct_bs->addr_for(card_ptr)));
 377 
 378   // If the card is no longer dirty, nothing to do.
 379   if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
 380     // No need to return that this card contains refs that point
 381     // into the collection set.
 382     return false;
 383   }
 384 
 385   // Construct the region representing the card.
 386   HeapWord* start = _ct_bs->addr_for(card_ptr);
 387   // And find the region containing it.
 388   HeapRegion* r = _g1->heap_region_containing(start);
 389 
 390   // Why do we have to check here whether a card is on a young region,
 391   // given that we dirty young regions and, as a result, the
 392   // post-barrier is supposed to filter them out and never to enqueue
 393   // them? When we allocate a new region as the "allocation region" we


< prev index next >