267
268 log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " "
269 "units of work for " SIZE_FORMAT " regions.",
270 cl.name(), num_workers, num_chunks, _cur_dirty_region);
271 workers->run_task(&cl, num_workers);
272
273 #ifndef PRODUCT
274 // Need to synchronize with concurrent cleanup since it needs to
275 // finish its card table clearing before we can verify.
276 G1CollectedHeap::heap()->wait_while_free_regions_coming();
277 G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup();
278 #endif
279 }
280 };
281
282 G1RemSet::G1RemSet(G1CollectedHeap* g1,
283 CardTableModRefBS* ct_bs,
284 G1HotCardCache* hot_card_cache) :
285 _g1(g1),
286 _scan_state(new G1RemSetScanState()),
287 _refine_card_concurrently_cl(),
288 _num_conc_refined_cards(0),
289 _ct_bs(ct_bs),
290 _g1p(_g1->g1_policy()),
291 _hot_card_cache(hot_card_cache),
292 _prev_period_summary(),
293 _into_cset_dirty_card_queue_set(false)
294 {
295 // Initialize the card queue set used to hold cards containing
296 // references into the collection set.
297 _into_cset_dirty_card_queue_set.initialize(NULL, // Should never be called by the Java code
298 DirtyCardQ_CBL_mon,
299 DirtyCardQ_FL_lock,
300 -1, // never trigger processing
301 -1, // no limit on length
302 Shared_DirtyCardQ_lock,
303 &JavaThread::dirty_card_queue_set());
304 }
305
306 G1RemSet::~G1RemSet() {
307 if (_scan_state != NULL) {
308 delete _scan_state;
309 }
310 }
311
312 uint G1RemSet::num_par_rem_sets() {
313 return MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads);
314 }
315
316 void G1RemSet::initialize(size_t capacity, uint max_regions) {
317 G1FromCardCache::initialize(num_par_rem_sets(), max_regions);
318 _scan_state->initialize(max_regions);
431 uint worker_i) {
432 double rs_time_start = os::elapsedTime();
433
434 G1ScanObjsDuringScanRSClosure scan_cl(_g1, pss);
435 G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
436 _g1->collection_set_iterate_from(&cl, worker_i);
437
438 double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) -
439 cl.strong_code_root_scan_time_sec();
440
441 G1GCPhaseTimes* p = _g1p->phase_times();
442
443 p->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
444 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_scanned(), G1GCPhaseTimes::ScannedCards);
445 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_claimed(), G1GCPhaseTimes::ClaimedCards);
446 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_skipped(), G1GCPhaseTimes::SkippedCards);
447
448 p->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, cl.strong_code_root_scan_time_sec());
449 }
450
451 bool G1RefineCardConcurrentlyClosure::do_card_ptr(jbyte* card_ptr, uint worker_i) {
452 G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
453
454 if (SuspendibleThreadSet::should_yield()) {
455 // Caller will actually yield.
456 return false;
457 }
458 // Otherwise, we finished successfully; return true.
459 return true;
460 }
461
462 // Closure used for updating RSets and recording references that
463 // point into the collection set. Only called during an
464 // evacuation pause.
465 class G1RefineCardClosure: public CardTableEntryClosure {
466 G1RemSet* _g1rs;
467 DirtyCardQueue* _into_cset_dcq;
468 G1ScanObjsDuringUpdateRSClosure* _update_rs_cl;
469 public:
470 G1RefineCardClosure(G1CollectedHeap* g1h,
471 DirtyCardQueue* into_cset_dcq,
472 G1ScanObjsDuringUpdateRSClosure* update_rs_cl) :
473 _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq), _update_rs_cl(update_rs_cl)
474 {}
475
476 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
477 // The only time we care about recording cards that
478 // contain references that point into the collection set
479 // is during RSet updating within an evacuation pause.
480 // In this case worker_i should be the id of a GC worker thread.
481 assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
796 void G1RemSet::print_periodic_summary_info(const char* header, uint period_count) {
797 if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
798 (period_count % G1SummarizeRSetStatsPeriod == 0)) {
799
800 G1RemSetSummary current(this);
801 _prev_period_summary.subtract_from(¤t);
802
803 Log(gc, remset) log;
804 log.trace("%s", header);
805 ResourceMark rm;
806 _prev_period_summary.print_on(log.trace_stream());
807
808 _prev_period_summary.set(¤t);
809 }
810 }
811
812 void G1RemSet::print_summary_info() {
813 Log(gc, remset, exit) log;
814 if (log.is_trace()) {
815 log.trace(" Cumulative RS summary");
816 G1RemSetSummary current;
817 ResourceMark rm;
818 current.print_on(log.trace_stream());
819 }
820 }
821
822 void G1RemSet::create_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap) {
823 _card_live_data.create(workers, mark_bitmap);
824 }
825
826 void G1RemSet::finalize_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap) {
827 _card_live_data.finalize(workers, mark_bitmap);
828 }
829
830 void G1RemSet::verify_card_live_data(WorkGang* workers, G1CMBitMap* bitmap) {
831 _card_live_data.verify(workers, bitmap);
832 }
833
834 void G1RemSet::clear_card_live_data(WorkGang* workers) {
835 _card_live_data.clear(workers);
836 }
|
267
268 log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " "
269 "units of work for " SIZE_FORMAT " regions.",
270 cl.name(), num_workers, num_chunks, _cur_dirty_region);
271 workers->run_task(&cl, num_workers);
272
273 #ifndef PRODUCT
274 // Need to synchronize with concurrent cleanup since it needs to
275 // finish its card table clearing before we can verify.
276 G1CollectedHeap::heap()->wait_while_free_regions_coming();
277 G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup();
278 #endif
279 }
280 };
281
282 G1RemSet::G1RemSet(G1CollectedHeap* g1,
283 CardTableModRefBS* ct_bs,
284 G1HotCardCache* hot_card_cache) :
285 _g1(g1),
286 _scan_state(new G1RemSetScanState()),
287 _num_conc_refined_cards(0),
288 _ct_bs(ct_bs),
289 _g1p(_g1->g1_policy()),
290 _hot_card_cache(hot_card_cache),
291 _prev_period_summary(),
292 _into_cset_dirty_card_queue_set(false)
293 {
294 // Initialize the card queue set used to hold cards containing
295 // references into the collection set.
296 _into_cset_dirty_card_queue_set.initialize(DirtyCardQ_CBL_mon,
297 DirtyCardQ_FL_lock,
298 -1, // never trigger processing
299 -1, // no limit on length
300 Shared_DirtyCardQ_lock,
301 &JavaThread::dirty_card_queue_set());
302 }
303
304 G1RemSet::~G1RemSet() {
305 if (_scan_state != NULL) {
306 delete _scan_state;
307 }
308 }
309
310 uint G1RemSet::num_par_rem_sets() {
311 return MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads);
312 }
313
314 void G1RemSet::initialize(size_t capacity, uint max_regions) {
315 G1FromCardCache::initialize(num_par_rem_sets(), max_regions);
316 _scan_state->initialize(max_regions);
429 uint worker_i) {
430 double rs_time_start = os::elapsedTime();
431
432 G1ScanObjsDuringScanRSClosure scan_cl(_g1, pss);
433 G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
434 _g1->collection_set_iterate_from(&cl, worker_i);
435
436 double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) -
437 cl.strong_code_root_scan_time_sec();
438
439 G1GCPhaseTimes* p = _g1p->phase_times();
440
441 p->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
442 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_scanned(), G1GCPhaseTimes::ScannedCards);
443 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_claimed(), G1GCPhaseTimes::ClaimedCards);
444 p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_skipped(), G1GCPhaseTimes::SkippedCards);
445
446 p->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, cl.strong_code_root_scan_time_sec());
447 }
448
449 // Closure used for updating RSets and recording references that
450 // point into the collection set. Only called during an
451 // evacuation pause.
452 class G1RefineCardClosure: public CardTableEntryClosure {
453 G1RemSet* _g1rs;
454 DirtyCardQueue* _into_cset_dcq;
455 G1ScanObjsDuringUpdateRSClosure* _update_rs_cl;
456 public:
457 G1RefineCardClosure(G1CollectedHeap* g1h,
458 DirtyCardQueue* into_cset_dcq,
459 G1ScanObjsDuringUpdateRSClosure* update_rs_cl) :
460 _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq), _update_rs_cl(update_rs_cl)
461 {}
462
463 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
464 // The only time we care about recording cards that
465 // contain references that point into the collection set
466 // is during RSet updating within an evacuation pause.
467 // In this case worker_i should be the id of a GC worker thread.
468 assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
783 void G1RemSet::print_periodic_summary_info(const char* header, uint period_count) {
784 if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
785 (period_count % G1SummarizeRSetStatsPeriod == 0)) {
786
787 G1RemSetSummary current(this);
788 _prev_period_summary.subtract_from(¤t);
789
790 Log(gc, remset) log;
791 log.trace("%s", header);
792 ResourceMark rm;
793 _prev_period_summary.print_on(log.trace_stream());
794
795 _prev_period_summary.set(¤t);
796 }
797 }
798
799 void G1RemSet::print_summary_info() {
800 Log(gc, remset, exit) log;
801 if (log.is_trace()) {
802 log.trace(" Cumulative RS summary");
803 G1RemSetSummary current(this);
804 ResourceMark rm;
805 current.print_on(log.trace_stream());
806 }
807 }
808
809 void G1RemSet::create_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap) {
810 _card_live_data.create(workers, mark_bitmap);
811 }
812
813 void G1RemSet::finalize_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap) {
814 _card_live_data.finalize(workers, mark_bitmap);
815 }
816
817 void G1RemSet::verify_card_live_data(WorkGang* workers, G1CMBitMap* bitmap) {
818 _card_live_data.verify(workers, bitmap);
819 }
820
821 void G1RemSet::clear_card_live_data(WorkGang* workers) {
822 _card_live_data.clear(workers);
823 }
|