Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/g1RemSet.cpp @ 1861:c32059ef4dc0
6971296: G1: simplify G1RemSet class hierarchy
Summary: Remove G1RemSet base class and StupidG1RemSet class; rename HRInto_G1RemSet to just G1RemSet.
Reviewed-by: ysr, tonyp
author | johnc |
---|---|
date | Tue, 12 Oct 2010 09:36:48 -0700 |
parents | 8b10f48633dc |
children | 878b57474103 |
comparison
equal
deleted
inserted
replaced
1843:0715f0cf171d | 1861:c32059ef4dc0 |
---|---|
95 } | 95 } |
96 return false; | 96 return false; |
97 } | 97 } |
98 }; | 98 }; |
99 | 99 |
100 void | |
101 StupidG1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, | |
102 int worker_i) { | |
103 IntoCSRegionClosure rc(_g1, oc); | |
104 _g1->heap_region_iterate(&rc); | |
105 } | |
106 | |
107 class VerifyRSCleanCardOopClosure: public OopClosure { | 100 class VerifyRSCleanCardOopClosure: public OopClosure { |
108 G1CollectedHeap* _g1; | 101 G1CollectedHeap* _g1; |
109 public: | 102 public: |
110 VerifyRSCleanCardOopClosure(G1CollectedHeap* g1) : _g1(g1) {} | 103 VerifyRSCleanCardOopClosure(G1CollectedHeap* g1) : _g1(g1) {} |
111 | 104 |
117 guarantee(to == NULL || !to->in_collection_set(), | 110 guarantee(to == NULL || !to->in_collection_set(), |
118 "Missed a rem set member."); | 111 "Missed a rem set member."); |
119 } | 112 } |
120 }; | 113 }; |
121 | 114 |
122 HRInto_G1RemSet::HRInto_G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) | 115 G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) |
123 : G1RemSet(g1), _ct_bs(ct_bs), _g1p(_g1->g1_policy()), | 116 : _g1(g1), _conc_refine_cards(0), |
117 _ct_bs(ct_bs), _g1p(_g1->g1_policy()), | |
124 _cg1r(g1->concurrent_g1_refine()), | 118 _cg1r(g1->concurrent_g1_refine()), |
125 _traversal_in_progress(false), | 119 _traversal_in_progress(false), |
126 _cset_rs_update_cl(NULL), | 120 _cset_rs_update_cl(NULL), |
127 _cards_scanned(NULL), _total_cards_scanned(0) | 121 _cards_scanned(NULL), _total_cards_scanned(0) |
128 { | 122 { |
132 for (uint i = 0; i < n_workers(); i++) { | 126 for (uint i = 0; i < n_workers(); i++) { |
133 _cset_rs_update_cl[i] = NULL; | 127 _cset_rs_update_cl[i] = NULL; |
134 } | 128 } |
135 } | 129 } |
136 | 130 |
137 HRInto_G1RemSet::~HRInto_G1RemSet() { | 131 G1RemSet::~G1RemSet() { |
138 delete _seq_task; | 132 delete _seq_task; |
139 for (uint i = 0; i < n_workers(); i++) { | 133 for (uint i = 0; i < n_workers(); i++) { |
140 assert(_cset_rs_update_cl[i] == NULL, "it should be"); | 134 assert(_cset_rs_update_cl[i] == NULL, "it should be"); |
141 } | 135 } |
142 FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl); | 136 FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl); |
275 // If we have: | 269 // If we have: |
276 // n collection set regions | 270 // n collection set regions |
277 // p threads | 271 // p threads |
278 // Then thread t will start at region t * floor (n/p) | 272 // Then thread t will start at region t * floor (n/p) |
279 | 273 |
280 HeapRegion* HRInto_G1RemSet::calculateStartRegion(int worker_i) { | 274 HeapRegion* G1RemSet::calculateStartRegion(int worker_i) { |
281 HeapRegion* result = _g1p->collection_set(); | 275 HeapRegion* result = _g1p->collection_set(); |
282 if (ParallelGCThreads > 0) { | 276 if (ParallelGCThreads > 0) { |
283 size_t cs_size = _g1p->collection_set_size(); | 277 size_t cs_size = _g1p->collection_set_size(); |
284 int n_workers = _g1->workers()->total_workers(); | 278 int n_workers = _g1->workers()->total_workers(); |
285 size_t cs_spans = cs_size / n_workers; | 279 size_t cs_spans = cs_size / n_workers; |
288 result = result->next_in_collection_set(); | 282 result = result->next_in_collection_set(); |
289 } | 283 } |
290 return result; | 284 return result; |
291 } | 285 } |
292 | 286 |
293 void HRInto_G1RemSet::scanRS(OopsInHeapRegionClosure* oc, int worker_i) { | 287 void G1RemSet::scanRS(OopsInHeapRegionClosure* oc, int worker_i) { |
294 double rs_time_start = os::elapsedTime(); | 288 double rs_time_start = os::elapsedTime(); |
295 HeapRegion *startRegion = calculateStartRegion(worker_i); | 289 HeapRegion *startRegion = calculateStartRegion(worker_i); |
296 | 290 |
297 ScanRSClosure scanRScl(oc, worker_i); | 291 ScanRSClosure scanRScl(oc, worker_i); |
298 _g1->collection_set_iterate_from(startRegion, &scanRScl); | 292 _g1->collection_set_iterate_from(startRegion, &scanRScl); |
338 } | 332 } |
339 return true; | 333 return true; |
340 } | 334 } |
341 }; | 335 }; |
342 | 336 |
343 void HRInto_G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, int worker_i) { | 337 void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, int worker_i) { |
344 double start = os::elapsedTime(); | 338 double start = os::elapsedTime(); |
345 // Apply the given closure to all remaining log entries. | 339 // Apply the given closure to all remaining log entries. |
346 RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq); | 340 RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq); |
347 _g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i); | 341 _g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i); |
348 | 342 |
437 } | 431 } |
438 gclog_or_tty->print_cr(" > %8d %8d", (1 << (MIN+mx-2))+1, _histo[mx-1]); | 432 gclog_or_tty->print_cr(" > %8d %8d", (1 << (MIN+mx-2))+1, _histo[mx-1]); |
439 } | 433 } |
440 }; | 434 }; |
441 | 435 |
442 void HRInto_G1RemSet::cleanupHRRS() { | 436 void G1RemSet::cleanupHRRS() { |
443 HeapRegionRemSet::cleanup(); | 437 HeapRegionRemSet::cleanup(); |
444 } | 438 } |
445 | 439 |
446 void | 440 void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, |
447 HRInto_G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, | |
448 int worker_i) { | 441 int worker_i) { |
449 #if CARD_REPEAT_HISTO | 442 #if CARD_REPEAT_HISTO |
450 ct_freq_update_histo_and_reset(); | 443 ct_freq_update_histo_and_reset(); |
451 #endif | 444 #endif |
452 if (worker_i == 0) { | 445 if (worker_i == 0) { |
506 | 499 |
507 // We now clear the cached values of _cset_rs_update_cl for this worker | 500 // We now clear the cached values of _cset_rs_update_cl for this worker |
508 _cset_rs_update_cl[worker_i] = NULL; | 501 _cset_rs_update_cl[worker_i] = NULL; |
509 } | 502 } |
510 | 503 |
511 void HRInto_G1RemSet:: | 504 void G1RemSet::prepare_for_oops_into_collection_set_do() { |
512 prepare_for_oops_into_collection_set_do() { | |
513 #if G1_REM_SET_LOGGING | 505 #if G1_REM_SET_LOGGING |
514 PrintRSClosure cl; | 506 PrintRSClosure cl; |
515 _g1->collection_set_iterate(&cl); | 507 _g1->collection_set_iterate(&cl); |
516 #endif | 508 #endif |
517 cleanupHRRS(); | 509 cleanupHRRS(); |
579 // * the DCQS to which this closure is applied is used to hold | 571 // * the DCQS to which this closure is applied is used to hold |
580 // references that point into the collection set from the prior | 572 // references that point into the collection set from the prior |
581 // RSet updating, | 573 // RSet updating, |
582 // * the post-write barrier shouldn't be logging updates to young | 574 // * the post-write barrier shouldn't be logging updates to young |
583 // regions (but there is a situation where this can happen - see | 575 // regions (but there is a situation where this can happen - see |
584 // the comment in HRInto_G1RemSet::concurrentRefineOneCard below - | 576 // the comment in G1RemSet::concurrentRefineOneCard below - |
585 // that should not be applicable here), and | 577 // that should not be applicable here), and |
586 // * during actual RSet updating, the filtering of cards in young | 578 // * during actual RSet updating, the filtering of cards in young |
587 // regions in HeapRegion::oops_on_card_seq_iterate_careful is | 579 // regions in HeapRegion::oops_on_card_seq_iterate_careful is |
588 // employed. | 580 // employed. |
589 // As a result, when this closure is applied to "refs into cset" | 581 // As a result, when this closure is applied to "refs into cset" |
599 assert(stop_point == NULL, "saw an unallocated region"); | 591 assert(stop_point == NULL, "saw an unallocated region"); |
600 return true; | 592 return true; |
601 } | 593 } |
602 }; | 594 }; |
603 | 595 |
604 void HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do() { | 596 void G1RemSet::cleanup_after_oops_into_collection_set_do() { |
605 guarantee( _cards_scanned != NULL, "invariant" ); | 597 guarantee( _cards_scanned != NULL, "invariant" ); |
606 _total_cards_scanned = 0; | 598 _total_cards_scanned = 0; |
607 for (uint i = 0; i < n_workers(); ++i) | 599 for (uint i = 0; i < n_workers(); ++i) |
608 _total_cards_scanned += _cards_scanned[i]; | 600 _total_cards_scanned += _cards_scanned[i]; |
609 FREE_C_HEAP_ARRAY(size_t, _cards_scanned); | 601 FREE_C_HEAP_ARRAY(size_t, _cards_scanned); |
690 } | 682 } |
691 return false; | 683 return false; |
692 } | 684 } |
693 }; | 685 }; |
694 | 686 |
695 void HRInto_G1RemSet::scrub(BitMap* region_bm, BitMap* card_bm) { | 687 void G1RemSet::scrub(BitMap* region_bm, BitMap* card_bm) { |
696 ScrubRSClosure scrub_cl(region_bm, card_bm); | 688 ScrubRSClosure scrub_cl(region_bm, card_bm); |
697 _g1->heap_region_iterate(&scrub_cl); | 689 _g1->heap_region_iterate(&scrub_cl); |
698 } | 690 } |
699 | 691 |
700 void HRInto_G1RemSet::scrub_par(BitMap* region_bm, BitMap* card_bm, | 692 void G1RemSet::scrub_par(BitMap* region_bm, BitMap* card_bm, |
701 int worker_num, int claim_val) { | 693 int worker_num, int claim_val) { |
702 ScrubRSClosure scrub_cl(region_bm, card_bm); | 694 ScrubRSClosure scrub_cl(region_bm, card_bm); |
703 _g1->heap_region_par_iterate_chunked(&scrub_cl, worker_num, claim_val); | 695 _g1->heap_region_par_iterate_chunked(&scrub_cl, worker_num, claim_val); |
704 } | 696 } |
705 | 697 |
739 } | 731 } |
740 virtual void do_oop(oop* p) { do_oop_nv(p); } | 732 virtual void do_oop(oop* p) { do_oop_nv(p); } |
741 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | 733 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
742 }; | 734 }; |
743 | 735 |
744 bool HRInto_G1RemSet::concurrentRefineOneCard_impl(jbyte* card_ptr, int worker_i, | 736 bool G1RemSet::concurrentRefineOneCard_impl(jbyte* card_ptr, int worker_i, |
745 bool check_for_refs_into_cset) { | 737 bool check_for_refs_into_cset) { |
746 // Construct the region representing the card. | 738 // Construct the region representing the card. |
747 HeapWord* start = _ct_bs->addr_for(card_ptr); | 739 HeapWord* start = _ct_bs->addr_for(card_ptr); |
748 // And find the region containing it. | 740 // And find the region containing it. |
749 HeapRegion* r = _g1->heap_region_containing(start); | 741 HeapRegion* r = _g1->heap_region_containing(start); |
818 } | 810 } |
819 | 811 |
820 return trigger_cl.value(); | 812 return trigger_cl.value(); |
821 } | 813 } |
822 | 814 |
823 bool HRInto_G1RemSet::concurrentRefineOneCard(jbyte* card_ptr, int worker_i, | 815 bool G1RemSet::concurrentRefineOneCard(jbyte* card_ptr, int worker_i, |
824 bool check_for_refs_into_cset) { | 816 bool check_for_refs_into_cset) { |
825 // If the card is no longer dirty, nothing to do. | 817 // If the card is no longer dirty, nothing to do. |
826 if (*card_ptr != CardTableModRefBS::dirty_card_val()) { | 818 if (*card_ptr != CardTableModRefBS::dirty_card_val()) { |
827 // No need to return that this card contains refs that point | 819 // No need to return that this card contains refs that point |
828 // into the collection set. | 820 // into the collection set. |
993 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t; | 985 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t; |
994 gclog_or_tty->print(" %5.2f", crt->vtime_accum()); | 986 gclog_or_tty->print(" %5.2f", crt->vtime_accum()); |
995 } | 987 } |
996 }; | 988 }; |
997 | 989 |
998 void HRInto_G1RemSet::print_summary_info() { | 990 void G1RemSet::print_summary_info() { |
999 G1CollectedHeap* g1 = G1CollectedHeap::heap(); | 991 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
1000 | 992 |
1001 #if CARD_REPEAT_HISTO | 993 #if CARD_REPEAT_HISTO |
1002 gclog_or_tty->print_cr("\nG1 card_repeat count histogram: "); | 994 gclog_or_tty->print_cr("\nG1 card_repeat count histogram: "); |
1003 gclog_or_tty->print_cr(" # of repeats --> # of cards with that number."); | 995 gclog_or_tty->print_cr(" # of repeats --> # of cards with that number."); |
1027 PrintRSThreadVTimeClosure p; | 1019 PrintRSThreadVTimeClosure p; |
1028 gclog_or_tty->print(" "); | 1020 gclog_or_tty->print(" "); |
1029 g1->concurrent_g1_refine()->threads_do(&p); | 1021 g1->concurrent_g1_refine()->threads_do(&p); |
1030 gclog_or_tty->print_cr(""); | 1022 gclog_or_tty->print_cr(""); |
1031 | 1023 |
1032 if (G1UseHRIntoRS) { | 1024 HRRSStatsIter blk; |
1033 HRRSStatsIter blk; | 1025 g1->heap_region_iterate(&blk); |
1034 g1->heap_region_iterate(&blk); | 1026 gclog_or_tty->print_cr(" Total heap region rem set sizes = " SIZE_FORMAT "K." |
1035 gclog_or_tty->print_cr(" Total heap region rem set sizes = " SIZE_FORMAT "K." | 1027 " Max = " SIZE_FORMAT "K.", |
1036 " Max = " SIZE_FORMAT "K.", | 1028 blk.total_mem_sz()/K, blk.max_mem_sz()/K); |
1037 blk.total_mem_sz()/K, blk.max_mem_sz()/K); | 1029 gclog_or_tty->print_cr(" Static structures = " SIZE_FORMAT "K," |
1038 gclog_or_tty->print_cr(" Static structures = " SIZE_FORMAT "K," | 1030 " free_lists = " SIZE_FORMAT "K.", |
1039 " free_lists = " SIZE_FORMAT "K.", | 1031 HeapRegionRemSet::static_mem_size()/K, |
1040 HeapRegionRemSet::static_mem_size()/K, | 1032 HeapRegionRemSet::fl_mem_size()/K); |
1041 HeapRegionRemSet::fl_mem_size()/K); | 1033 gclog_or_tty->print_cr(" %d occupied cards represented.", |
1042 gclog_or_tty->print_cr(" %d occupied cards represented.", | 1034 blk.occupied()); |
1043 blk.occupied()); | 1035 gclog_or_tty->print_cr(" Max sz region = [" PTR_FORMAT ", " PTR_FORMAT " )" |
1044 gclog_or_tty->print_cr(" Max sz region = [" PTR_FORMAT ", " PTR_FORMAT " )" | 1036 ", cap = " SIZE_FORMAT "K, occ = " SIZE_FORMAT "K.", |
1045 ", cap = " SIZE_FORMAT "K, occ = " SIZE_FORMAT "K.", | 1037 blk.max_mem_sz_region()->bottom(), blk.max_mem_sz_region()->end(), |
1046 blk.max_mem_sz_region()->bottom(), blk.max_mem_sz_region()->end(), | 1038 (blk.max_mem_sz_region()->rem_set()->mem_size() + K - 1)/K, |
1047 (blk.max_mem_sz_region()->rem_set()->mem_size() + K - 1)/K, | 1039 (blk.max_mem_sz_region()->rem_set()->occupied() + K - 1)/K); |
1048 (blk.max_mem_sz_region()->rem_set()->occupied() + K - 1)/K); | 1040 gclog_or_tty->print_cr(" Did %d coarsenings.", HeapRegionRemSet::n_coarsenings()); |
1049 gclog_or_tty->print_cr(" Did %d coarsenings.", | 1041 } |
1050 HeapRegionRemSet::n_coarsenings()); | 1042 |
1051 | 1043 void G1RemSet::prepare_for_verify() { |
1052 } | |
1053 } | |
1054 | |
1055 void HRInto_G1RemSet::prepare_for_verify() { | |
1056 if (G1HRRSFlushLogBuffersOnVerify && | 1044 if (G1HRRSFlushLogBuffersOnVerify && |
1057 (VerifyBeforeGC || VerifyAfterGC) | 1045 (VerifyBeforeGC || VerifyAfterGC) |
1058 && !_g1->full_collection()) { | 1046 && !_g1->full_collection()) { |
1059 cleanupHRRS(); | 1047 cleanupHRRS(); |
1060 _g1->set_refine_cte_cl_concurrency(false); | 1048 _g1->set_refine_cte_cl_concurrency(false); |