Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @ 10182:5c93c1f61226
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
Summary: Stack allocate instances of HeapRegionRemSetIterator during RSet scanning.
Reviewed-by: brutisso, jwilhelm
author | johnc |
---|---|
date | Thu, 18 Apr 2013 10:09:23 -0700 |
parents | 859cd1a76f8a |
children | caac22686b17 |
comparison
equal
deleted
inserted
replaced
10181:1cb4795305b9 | 10182:5c93c1f61226 |
---|---|
875 | 875 |
876 bool HeapRegionRemSet::iter_is_complete() { | 876 bool HeapRegionRemSet::iter_is_complete() { |
877 return _iter_state == Complete; | 877 return _iter_state == Complete; |
878 } | 878 } |
879 | 879 |
880 void HeapRegionRemSet::init_iterator(HeapRegionRemSetIterator* iter) const { | |
881 iter->initialize(this); | |
882 } | |
883 | |
884 #ifndef PRODUCT | 880 #ifndef PRODUCT |
885 void HeapRegionRemSet::print() const { | 881 void HeapRegionRemSet::print() const { |
886 HeapRegionRemSetIterator iter; | 882 HeapRegionRemSetIterator iter(this); |
887 init_iterator(&iter); | |
888 size_t card_index; | 883 size_t card_index; |
889 while (iter.has_next(card_index)) { | 884 while (iter.has_next(card_index)) { |
890 HeapWord* card_start = | 885 HeapWord* card_start = |
891 G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); | 886 G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); |
892 gclog_or_tty->print_cr(" Card " PTR_FORMAT, card_start); | 887 gclog_or_tty->print_cr(" Card " PTR_FORMAT, card_start); |
926 _other_regions.scrub(ctbs, region_bm, card_bm); | 921 _other_regions.scrub(ctbs, region_bm, card_bm); |
927 } | 922 } |
928 | 923 |
929 //-------------------- Iteration -------------------- | 924 //-------------------- Iteration -------------------- |
930 | 925 |
931 HeapRegionRemSetIterator:: | 926 HeapRegionRemSetIterator:: HeapRegionRemSetIterator(const HeapRegionRemSet* hrrs) : |
932 HeapRegionRemSetIterator() : | 927 _hrrs(hrrs), |
933 _hrrs(NULL), | |
934 _g1h(G1CollectedHeap::heap()), | 928 _g1h(G1CollectedHeap::heap()), |
935 _bosa(NULL), | 929 _coarse_map(&hrrs->_other_regions._coarse_map), |
936 _sparse_iter() { } | 930 _fine_grain_regions(hrrs->_other_regions._fine_grain_regions), |
937 | 931 _bosa(hrrs->bosa()), |
938 void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) { | 932 _is(Sparse), |
939 _hrrs = hrrs; | |
940 _coarse_map = &_hrrs->_other_regions._coarse_map; | |
941 _fine_grain_regions = _hrrs->_other_regions._fine_grain_regions; | |
942 _bosa = _hrrs->bosa(); | |
943 | |
944 _is = Sparse; | |
945 // Set these values so that we increment to the first region. | 933 // Set these values so that we increment to the first region. |
946 _coarse_cur_region_index = -1; | 934 _coarse_cur_region_index(-1), |
947 _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1); | 935 _coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1), |
948 | 936 _cur_region_cur_card(0), |
949 _cur_region_cur_card = 0; | 937 _fine_array_index(-1), |
950 | 938 _fine_cur_prt(NULL), |
951 _fine_array_index = -1; | 939 _n_yielded_coarse(0), |
952 _fine_cur_prt = NULL; | 940 _n_yielded_fine(0), |
953 | 941 _n_yielded_sparse(0), |
954 _n_yielded_coarse = 0; | 942 _sparse_iter(&hrrs->_other_regions._sparse_table) {} |
955 _n_yielded_fine = 0; | |
956 _n_yielded_sparse = 0; | |
957 | |
958 _sparse_iter.init(&hrrs->_other_regions._sparse_table); | |
959 } | |
960 | 943 |
961 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { | 944 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { |
962 if (_hrrs->_other_regions._n_coarse_entries == 0) return false; | 945 if (_hrrs->_other_regions._n_coarse_entries == 0) return false; |
963 // Go to the next card. | 946 // Go to the next card. |
964 _coarse_cur_region_cur_card++; | 947 _coarse_cur_region_cur_card++; |
1207 // Now cause a coarsening. | 1190 // Now cause a coarsening. |
1208 hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); | 1191 hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); |
1209 hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); | 1192 hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); |
1210 | 1193 |
1211 // Now, does iteration yield these three? | 1194 // Now, does iteration yield these three? |
1212 HeapRegionRemSetIterator iter; | 1195 HeapRegionRemSetIterator iter(hrrs); |
1213 hrrs->init_iterator(&iter); | |
1214 size_t sum = 0; | 1196 size_t sum = 0; |
1215 size_t card_index; | 1197 size_t card_index; |
1216 while (iter.has_next(card_index)) { | 1198 while (iter.has_next(card_index)) { |
1217 HeapWord* card_start = | 1199 HeapWord* card_start = |
1218 G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); | 1200 G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); |