comparison src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @ 942:2c79770d1f6e

6819085: G1: use larger and/or user settable region size Summary: Instead of the region size being hard-coded, allow the user to set it. Reviewed-by: jmasa, johnc, apetrusenko
author tonyp
date Thu, 30 Jul 2009 16:22:58 -0400
parents df6caf649ff7
children 9eee977dd1a9
comparison
equal deleted inserted replaced
941:8b46c4d82093 942:2c79770d1f6e
55 55
56 public: 56 public:
57 57
58 #endif // _MSC_VER 58 #endif // _MSC_VER
59 59
60 enum SomePrivateConstants {
61 CardsPerRegion = HeapRegion::GrainBytes >> CardTableModRefBS::card_shift
62 };
63
64 protected: 60 protected:
65 // We need access in order to union things into the base table. 61 // We need access in order to union things into the base table.
66 BitMap* bm() { return &_bm; } 62 BitMap* bm() { return &_bm; }
67 63
68 #if PRT_COUNT_OCCUPIED 64 #if PRT_COUNT_OCCUPIED
74 PerRegionTable(HeapRegion* hr) : 70 PerRegionTable(HeapRegion* hr) :
75 _hr(hr), 71 _hr(hr),
76 #if PRT_COUNT_OCCUPIED 72 #if PRT_COUNT_OCCUPIED
77 _occupied(0), 73 _occupied(0),
78 #endif 74 #endif
79 _bm(CardsPerRegion, false /* in-resource-area */) 75 _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */)
80 {} 76 {}
81 77
82 static void free(PerRegionTable* prt) { 78 static void free(PerRegionTable* prt) {
83 while (true) { 79 while (true) {
84 PerRegionTable* fl = _free_list; 80 PerRegionTable* fl = _free_list;
142 if (loc_hr->is_in_reserved(from)) { 138 if (loc_hr->is_in_reserved(from)) {
143 size_t hw_offset = pointer_delta((HeapWord*)from, loc_hr->bottom()); 139 size_t hw_offset = pointer_delta((HeapWord*)from, loc_hr->bottom());
144 CardIdx_t from_card = (CardIdx_t) 140 CardIdx_t from_card = (CardIdx_t)
145 hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize); 141 hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
146 142
147 assert(0 <= from_card && from_card < CardsPerRegion, "Must be in range."); 143 assert(0 <= from_card && from_card < HeapRegion::CardsPerRegion,
144 "Must be in range.");
148 add_card_work(from_card, par); 145 add_card_work(from_card, par);
149 } 146 }
150 } 147 }
151 148
152 public: 149 public:
629 626
630 uintptr_t from_hr_bot_card_index = 627 uintptr_t from_hr_bot_card_index =
631 uintptr_t(from_hr->bottom()) 628 uintptr_t(from_hr->bottom())
632 >> CardTableModRefBS::card_shift; 629 >> CardTableModRefBS::card_shift;
633 CardIdx_t card_index = from_card - from_hr_bot_card_index; 630 CardIdx_t card_index = from_card - from_hr_bot_card_index;
634 assert(0 <= card_index && card_index < PosParPRT::CardsPerRegion, 631 assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
635 "Must be in range."); 632 "Must be in range.");
636 if (G1HRRSUseSparseTable && 633 if (G1HRRSUseSparseTable &&
637 _sparse_table.add_card(from_hrs_ind, card_index)) { 634 _sparse_table.add_card(from_hrs_ind, card_index)) {
638 if (G1RecordHRRSOops) { 635 if (G1RecordHRRSOops) {
639 HeapRegionRemSet::record(hr(), from); 636 HeapRegionRemSet::record(hr(), from);
920 } 917 }
921 return sum; 918 return sum;
922 } 919 }
923 920
924 size_t OtherRegionsTable::occ_coarse() const { 921 size_t OtherRegionsTable::occ_coarse() const {
925 return (_n_coarse_entries * PosParPRT::CardsPerRegion); 922 return (_n_coarse_entries * HeapRegion::CardsPerRegion);
926 } 923 }
927 924
928 size_t OtherRegionsTable::occ_sparse() const { 925 size_t OtherRegionsTable::occ_sparse() const {
929 return _sparse_table.occupied(); 926 return _sparse_table.occupied();
930 } 927 }
1047 (uintptr_t(from) >> CardTableModRefBS::card_shift); 1044 (uintptr_t(from) >> CardTableModRefBS::card_shift);
1048 uintptr_t hr_bot_card_index = 1045 uintptr_t hr_bot_card_index =
1049 uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift; 1046 uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
1050 assert(from_card >= hr_bot_card_index, "Inv"); 1047 assert(from_card >= hr_bot_card_index, "Inv");
1051 CardIdx_t card_index = from_card - hr_bot_card_index; 1048 CardIdx_t card_index = from_card - hr_bot_card_index;
1052 assert(0 <= card_index && card_index < PosParPRT::CardsPerRegion, "Must be in range."); 1049 assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
1050 "Must be in range.");
1053 return _sparse_table.contains_card(hr_ind, card_index); 1051 return _sparse_table.contains_card(hr_ind, card_index);
1054 } 1052 }
1055 1053
1056 1054
1057 } 1055 }
1174 _bosa = _hrrs->bosa(); 1172 _bosa = _hrrs->bosa();
1175 1173
1176 _is = Sparse; 1174 _is = Sparse;
1177 // Set these values so that we increment to the first region. 1175 // Set these values so that we increment to the first region.
1178 _coarse_cur_region_index = -1; 1176 _coarse_cur_region_index = -1;
1179 _coarse_cur_region_cur_card = (PosParPRT::CardsPerRegion-1);; 1177 _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);;
1180 1178
1181 _cur_region_cur_card = 0; 1179 _cur_region_cur_card = 0;
1182 1180
1183 _fine_array_index = -1; 1181 _fine_array_index = -1;
1184 _fine_cur_prt = NULL; 1182 _fine_cur_prt = NULL;
1193 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { 1191 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
1194 if (_hrrs->_other_regions._n_coarse_entries == 0) return false; 1192 if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
1195 // Go to the next card. 1193 // Go to the next card.
1196 _coarse_cur_region_cur_card++; 1194 _coarse_cur_region_cur_card++;
1197 // Was the last the last card in the current region? 1195 // Was the last the last card in the current region?
1198 if (_coarse_cur_region_cur_card == PosParPRT::CardsPerRegion) { 1196 if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) {
1199 // Yes: find the next region. This may leave _coarse_cur_region_index 1197 // Yes: find the next region. This may leave _coarse_cur_region_index
1200 // Set to the last index, in which case there are no more coarse 1198 // Set to the last index, in which case there are no more coarse
1201 // regions. 1199 // regions.
1202 _coarse_cur_region_index = 1200 _coarse_cur_region_index =
1203 (int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1); 1201 (int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1);
1230 if (fine_has_next()) { 1228 if (fine_has_next()) {
1231 _cur_region_cur_card = 1229 _cur_region_cur_card =
1232 _fine_cur_prt->_bm.get_next_one_offset(_cur_region_cur_card + 1); 1230 _fine_cur_prt->_bm.get_next_one_offset(_cur_region_cur_card + 1);
1233 } 1231 }
1234 while (!fine_has_next()) { 1232 while (!fine_has_next()) {
1235 if (_cur_region_cur_card == PosParPRT::CardsPerRegion) { 1233 if (_cur_region_cur_card == (size_t) HeapRegion::CardsPerRegion) {
1236 _cur_region_cur_card = 0; 1234 _cur_region_cur_card = 0;
1237 _fine_cur_prt = _fine_cur_prt->next(); 1235 _fine_cur_prt = _fine_cur_prt->next();
1238 } 1236 }
1239 if (_fine_cur_prt == NULL) { 1237 if (_fine_cur_prt == NULL) {
1240 fine_find_next_non_null_prt(); 1238 fine_find_next_non_null_prt();
1253 } 1251 }
1254 1252
1255 bool HeapRegionRemSetIterator::fine_has_next() { 1253 bool HeapRegionRemSetIterator::fine_has_next() {
1256 return 1254 return
1257 _fine_cur_prt != NULL && 1255 _fine_cur_prt != NULL &&
1258 _cur_region_cur_card < PosParPRT::CardsPerRegion; 1256 _cur_region_cur_card < (size_t) HeapRegion::CardsPerRegion;
1259 } 1257 }
1260 1258
1261 bool HeapRegionRemSetIterator::has_next(size_t& card_index) { 1259 bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
1262 switch (_is) { 1260 switch (_is) {
1263 case Sparse: 1261 case Sparse: