Mon, 25 Jun 2012 16:00:55 -0700
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
Summary: Remove the per-thread expansion tables (PosParPRT) and associated expansion and compaction from the fine grain RSet entries. This code has been unused for a while.
Reviewed-by: johnc, brutisso
Contributed-by: Thomas Schatzl <thomas.schatzl@jku.at>
ysr@777 | 1 | /* |
tonyp@3713 | 2 | * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "gc_implementation/g1/concurrentG1Refine.hpp" |
stefank@2314 | 27 | #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" |
stefank@2314 | 28 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
stefank@2314 | 29 | #include "gc_implementation/g1/heapRegionRemSet.hpp" |
stefank@2314 | 30 | #include "gc_implementation/g1/heapRegionSeq.inline.hpp" |
stefank@2314 | 31 | #include "memory/allocation.hpp" |
stefank@2314 | 32 | #include "memory/space.inline.hpp" |
johnc@3891 | 33 | #include "oops/oop.inline.hpp" |
stefank@2314 | 34 | #include "utilities/bitMap.inline.hpp" |
stefank@2314 | 35 | #include "utilities/globalDefinitions.hpp" |
ysr@777 | 36 | |
ysr@777 | 37 | // OtherRegionsTable |
ysr@777 | 38 | |
ysr@777 | 39 | class PerRegionTable: public CHeapObj { |
ysr@777 | 40 | friend class OtherRegionsTable; |
ysr@777 | 41 | friend class HeapRegionRemSetIterator; |
ysr@777 | 42 | |
ysr@777 | 43 | HeapRegion* _hr; |
ysr@777 | 44 | BitMap _bm; |
ysr@777 | 45 | jint _occupied; |
ysr@777 | 46 | |
johnc@3891 | 47 | // next pointer for free/allocated lis |
johnc@3891 | 48 | PerRegionTable* _next; |
ysr@777 | 49 | |
ysr@777 | 50 | static PerRegionTable* _free_list; |
ysr@777 | 51 | |
ysr@777 | 52 | #ifdef _MSC_VER |
ysr@777 | 53 | // For some reason even though the classes are marked as friend they are unable |
ysr@777 | 54 | // to access CardsPerRegion when private/protected. Only the windows c++ compiler |
ysr@777 | 55 | // says this Sun CC and linux gcc don't have a problem with access when private |
ysr@777 | 56 | |
ysr@777 | 57 | public: |
ysr@777 | 58 | |
ysr@777 | 59 | #endif // _MSC_VER |
ysr@777 | 60 | |
ysr@777 | 61 | protected: |
ysr@777 | 62 | // We need access in order to union things into the base table. |
ysr@777 | 63 | BitMap* bm() { return &_bm; } |
ysr@777 | 64 | |
ysr@777 | 65 | void recount_occupied() { |
ysr@777 | 66 | _occupied = (jint) bm()->count_one_bits(); |
ysr@777 | 67 | } |
ysr@777 | 68 | |
ysr@777 | 69 | PerRegionTable(HeapRegion* hr) : |
ysr@777 | 70 | _hr(hr), |
ysr@777 | 71 | _occupied(0), |
tonyp@1377 | 72 | _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */) |
ysr@777 | 73 | {} |
ysr@777 | 74 | |
johnc@1242 | 75 | void add_card_work(CardIdx_t from_card, bool par) { |
ysr@777 | 76 | if (!_bm.at(from_card)) { |
ysr@777 | 77 | if (par) { |
ysr@777 | 78 | if (_bm.par_at_put(from_card, 1)) { |
ysr@777 | 79 | Atomic::inc(&_occupied); |
ysr@777 | 80 | } |
ysr@777 | 81 | } else { |
ysr@777 | 82 | _bm.at_put(from_card, 1); |
ysr@777 | 83 | _occupied++; |
ysr@777 | 84 | } |
ysr@777 | 85 | } |
ysr@777 | 86 | } |
ysr@777 | 87 | |
ysr@1280 | 88 | void add_reference_work(OopOrNarrowOopStar from, bool par) { |
ysr@777 | 89 | // Must make this robust in case "from" is not in "_hr", because of |
ysr@777 | 90 | // concurrency. |
ysr@777 | 91 | |
johnc@3891 | 92 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 93 | gclog_or_tty->print_cr(" PRT::Add_reference_work(" PTR_FORMAT "->" PTR_FORMAT").", |
johnc@3891 | 94 | from, |
johnc@3891 | 95 | UseCompressedOops |
johnc@3891 | 96 | ? oopDesc::load_decode_heap_oop((narrowOop*)from) |
johnc@3891 | 97 | : oopDesc::load_decode_heap_oop((oop*)from)); |
johnc@3891 | 98 | } |
ysr@777 | 99 | |
ysr@777 | 100 | HeapRegion* loc_hr = hr(); |
ysr@777 | 101 | // If the test below fails, then this table was reused concurrently |
ysr@777 | 102 | // with this operation. This is OK, since the old table was coarsened, |
ysr@777 | 103 | // and adding a bit to the new table is never incorrect. |
brutisso@3216 | 104 | // If the table used to belong to a continues humongous region and is |
brutisso@3216 | 105 | // now reused for the corresponding start humongous region, we need to |
brutisso@3216 | 106 | // make sure that we detect this. Thus, we call is_in_reserved_raw() |
brutisso@3216 | 107 | // instead of just is_in_reserved() here. |
brutisso@3216 | 108 | if (loc_hr->is_in_reserved_raw(from)) { |
ysr@777 | 109 | size_t hw_offset = pointer_delta((HeapWord*)from, loc_hr->bottom()); |
johnc@1242 | 110 | CardIdx_t from_card = (CardIdx_t) |
johnc@1242 | 111 | hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize); |
ysr@777 | 112 | |
johnc@3182 | 113 | assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion, |
tonyp@1377 | 114 | "Must be in range."); |
johnc@1242 | 115 | add_card_work(from_card, par); |
ysr@777 | 116 | } |
ysr@777 | 117 | } |
ysr@777 | 118 | |
ysr@777 | 119 | public: |
ysr@777 | 120 | |
ysr@777 | 121 | HeapRegion* hr() const { return _hr; } |
ysr@777 | 122 | |
ysr@777 | 123 | jint occupied() const { |
ysr@777 | 124 | // Overkill, but if we ever need it... |
ysr@777 | 125 | // guarantee(_occupied == _bm.count_one_bits(), "Check"); |
ysr@777 | 126 | return _occupied; |
ysr@777 | 127 | } |
ysr@777 | 128 | |
ysr@777 | 129 | void init(HeapRegion* hr) { |
ysr@777 | 130 | _hr = hr; |
johnc@3891 | 131 | _next = NULL; |
ysr@777 | 132 | _occupied = 0; |
ysr@777 | 133 | _bm.clear(); |
ysr@777 | 134 | } |
ysr@777 | 135 | |
ysr@1280 | 136 | void add_reference(OopOrNarrowOopStar from) { |
ysr@777 | 137 | add_reference_work(from, /*parallel*/ true); |
ysr@777 | 138 | } |
ysr@777 | 139 | |
ysr@1280 | 140 | void seq_add_reference(OopOrNarrowOopStar from) { |
ysr@777 | 141 | add_reference_work(from, /*parallel*/ false); |
ysr@777 | 142 | } |
ysr@777 | 143 | |
ysr@777 | 144 | void scrub(CardTableModRefBS* ctbs, BitMap* card_bm) { |
ysr@777 | 145 | HeapWord* hr_bot = hr()->bottom(); |
swamyv@924 | 146 | size_t hr_first_card_index = ctbs->index_for(hr_bot); |
ysr@777 | 147 | bm()->set_intersection_at_offset(*card_bm, hr_first_card_index); |
ysr@777 | 148 | recount_occupied(); |
ysr@777 | 149 | } |
ysr@777 | 150 | |
johnc@1242 | 151 | void add_card(CardIdx_t from_card_index) { |
ysr@777 | 152 | add_card_work(from_card_index, /*parallel*/ true); |
ysr@777 | 153 | } |
ysr@777 | 154 | |
johnc@1242 | 155 | void seq_add_card(CardIdx_t from_card_index) { |
ysr@777 | 156 | add_card_work(from_card_index, /*parallel*/ false); |
ysr@777 | 157 | } |
ysr@777 | 158 | |
ysr@777 | 159 | // (Destructively) union the bitmap of the current table into the given |
ysr@777 | 160 | // bitmap (which is assumed to be of the same size.) |
ysr@777 | 161 | void union_bitmap_into(BitMap* bm) { |
ysr@777 | 162 | bm->set_union(_bm); |
ysr@777 | 163 | } |
ysr@777 | 164 | |
ysr@777 | 165 | // Mem size in bytes. |
ysr@777 | 166 | size_t mem_size() const { |
ysr@777 | 167 | return sizeof(this) + _bm.size_in_words() * HeapWordSize; |
ysr@777 | 168 | } |
ysr@777 | 169 | |
ysr@777 | 170 | // Requires "from" to be in "hr()". |
ysr@1280 | 171 | bool contains_reference(OopOrNarrowOopStar from) const { |
ysr@777 | 172 | assert(hr()->is_in_reserved(from), "Precondition."); |
ysr@777 | 173 | size_t card_ind = pointer_delta(from, hr()->bottom(), |
ysr@777 | 174 | CardTableModRefBS::card_size); |
ysr@777 | 175 | return _bm.at(card_ind); |
ysr@777 | 176 | } |
ysr@777 | 177 | |
johnc@3891 | 178 | PerRegionTable* next() const { return _next; } |
johnc@3891 | 179 | void set_next(PerRegionTable* nxt) { _next = nxt; } |
johnc@3891 | 180 | PerRegionTable** next_addr() { return &_next; } |
ysr@777 | 181 | |
johnc@3891 | 182 | static void free(PerRegionTable* prt) { |
ysr@777 | 183 | while (true) { |
johnc@3891 | 184 | PerRegionTable* fl = _free_list; |
ysr@777 | 185 | prt->set_next(fl); |
johnc@3891 | 186 | PerRegionTable* res = |
johnc@3891 | 187 | (PerRegionTable*) |
ysr@777 | 188 | Atomic::cmpxchg_ptr(prt, &_free_list, fl); |
ysr@777 | 189 | if (res == fl) return; |
ysr@777 | 190 | } |
ysr@777 | 191 | ShouldNotReachHere(); |
ysr@777 | 192 | } |
ysr@777 | 193 | |
johnc@3891 | 194 | static PerRegionTable* alloc(HeapRegion* hr) { |
johnc@3891 | 195 | PerRegionTable* fl = _free_list; |
ysr@777 | 196 | while (fl != NULL) { |
johnc@3891 | 197 | PerRegionTable* nxt = fl->next(); |
johnc@3891 | 198 | PerRegionTable* res = |
johnc@3891 | 199 | (PerRegionTable*) |
ysr@777 | 200 | Atomic::cmpxchg_ptr(nxt, &_free_list, fl); |
ysr@777 | 201 | if (res == fl) { |
ysr@777 | 202 | fl->init(hr); |
ysr@777 | 203 | return fl; |
ysr@777 | 204 | } else { |
ysr@777 | 205 | fl = _free_list; |
ysr@777 | 206 | } |
ysr@777 | 207 | } |
ysr@777 | 208 | assert(fl == NULL, "Loop condition."); |
johnc@3891 | 209 | return new PerRegionTable(hr); |
ysr@777 | 210 | } |
ysr@777 | 211 | |
ysr@777 | 212 | static size_t fl_mem_size() { |
johnc@3891 | 213 | PerRegionTable* cur = _free_list; |
ysr@777 | 214 | size_t res = 0; |
ysr@777 | 215 | while (cur != NULL) { |
johnc@3891 | 216 | res += sizeof(PerRegionTable); |
ysr@777 | 217 | cur = cur->next(); |
ysr@777 | 218 | } |
ysr@777 | 219 | return res; |
ysr@777 | 220 | } |
ysr@777 | 221 | }; |
ysr@777 | 222 | |
johnc@3891 | 223 | PerRegionTable* PerRegionTable::_free_list = NULL; |
ysr@777 | 224 | |
ysr@777 | 225 | size_t OtherRegionsTable::_max_fine_entries = 0; |
ysr@777 | 226 | size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0; |
ysr@777 | 227 | size_t OtherRegionsTable::_fine_eviction_stride = 0; |
ysr@777 | 228 | size_t OtherRegionsTable::_fine_eviction_sample_size = 0; |
ysr@777 | 229 | |
ysr@777 | 230 | OtherRegionsTable::OtherRegionsTable(HeapRegion* hr) : |
ysr@777 | 231 | _g1h(G1CollectedHeap::heap()), |
ysr@777 | 232 | _m(Mutex::leaf, "An OtherRegionsTable lock", true), |
ysr@777 | 233 | _hr(hr), |
ysr@777 | 234 | _coarse_map(G1CollectedHeap::heap()->max_regions(), |
ysr@777 | 235 | false /* in-resource-area */), |
ysr@777 | 236 | _fine_grain_regions(NULL), |
ysr@777 | 237 | _n_fine_entries(0), _n_coarse_entries(0), |
ysr@777 | 238 | _fine_eviction_start(0), |
ysr@777 | 239 | _sparse_table(hr) |
ysr@777 | 240 | { |
johnc@3891 | 241 | typedef PerRegionTable* PerRegionTablePtr; |
johnc@3891 | 242 | |
ysr@777 | 243 | if (_max_fine_entries == 0) { |
ysr@777 | 244 | assert(_mod_max_fine_entries_mask == 0, "Both or none."); |
iveresov@1696 | 245 | size_t max_entries_log = (size_t)log2_long((jlong)G1RSetRegionEntries); |
iveresov@1696 | 246 | _max_fine_entries = (size_t)(1 << max_entries_log); |
ysr@777 | 247 | _mod_max_fine_entries_mask = _max_fine_entries - 1; |
johnc@3891 | 248 | |
ysr@777 | 249 | assert(_fine_eviction_sample_size == 0 |
ysr@777 | 250 | && _fine_eviction_stride == 0, "All init at same time."); |
iveresov@1696 | 251 | _fine_eviction_sample_size = MAX2((size_t)4, max_entries_log); |
ysr@777 | 252 | _fine_eviction_stride = _max_fine_entries / _fine_eviction_sample_size; |
ysr@777 | 253 | } |
johnc@3891 | 254 | |
johnc@3891 | 255 | _fine_grain_regions = new PerRegionTablePtr[_max_fine_entries]; |
johnc@3891 | 256 | |
johnc@3891 | 257 | if (_fine_grain_regions == NULL) { |
ysr@777 | 258 | vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, |
ysr@777 | 259 | "Failed to allocate _fine_grain_entries."); |
johnc@3891 | 260 | } |
johnc@3891 | 261 | |
ysr@777 | 262 | for (size_t i = 0; i < _max_fine_entries; i++) { |
ysr@777 | 263 | _fine_grain_regions[i] = NULL; |
ysr@777 | 264 | } |
ysr@777 | 265 | } |
ysr@777 | 266 | |
johnc@3891 | 267 | int** OtherRegionsTable::_from_card_cache = NULL; |
ysr@777 | 268 | size_t OtherRegionsTable::_from_card_cache_max_regions = 0; |
ysr@777 | 269 | size_t OtherRegionsTable::_from_card_cache_mem_size = 0; |
ysr@777 | 270 | |
ysr@777 | 271 | void OtherRegionsTable::init_from_card_cache(size_t max_regions) { |
ysr@777 | 272 | _from_card_cache_max_regions = max_regions; |
ysr@777 | 273 | |
ysr@777 | 274 | int n_par_rs = HeapRegionRemSet::num_par_rem_sets(); |
ysr@777 | 275 | _from_card_cache = NEW_C_HEAP_ARRAY(int*, n_par_rs); |
ysr@777 | 276 | for (int i = 0; i < n_par_rs; i++) { |
ysr@777 | 277 | _from_card_cache[i] = NEW_C_HEAP_ARRAY(int, max_regions); |
ysr@777 | 278 | for (size_t j = 0; j < max_regions; j++) { |
ysr@777 | 279 | _from_card_cache[i][j] = -1; // An invalid value. |
ysr@777 | 280 | } |
ysr@777 | 281 | } |
ysr@777 | 282 | _from_card_cache_mem_size = n_par_rs * max_regions * sizeof(int); |
ysr@777 | 283 | } |
ysr@777 | 284 | |
ysr@777 | 285 | void OtherRegionsTable::shrink_from_card_cache(size_t new_n_regs) { |
ysr@777 | 286 | for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { |
ysr@777 | 287 | assert(new_n_regs <= _from_card_cache_max_regions, "Must be within max."); |
ysr@777 | 288 | for (size_t j = new_n_regs; j < _from_card_cache_max_regions; j++) { |
ysr@777 | 289 | _from_card_cache[i][j] = -1; // An invalid value. |
ysr@777 | 290 | } |
ysr@777 | 291 | } |
ysr@777 | 292 | } |
ysr@777 | 293 | |
ysr@777 | 294 | #ifndef PRODUCT |
ysr@777 | 295 | void OtherRegionsTable::print_from_card_cache() { |
ysr@777 | 296 | for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { |
ysr@777 | 297 | for (size_t j = 0; j < _from_card_cache_max_regions; j++) { |
ysr@777 | 298 | gclog_or_tty->print_cr("_from_card_cache[%d][%d] = %d.", |
ysr@777 | 299 | i, j, _from_card_cache[i][j]); |
ysr@777 | 300 | } |
ysr@777 | 301 | } |
ysr@777 | 302 | } |
ysr@777 | 303 | #endif |
ysr@777 | 304 | |
ysr@1280 | 305 | void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) { |
tonyp@3713 | 306 | size_t cur_hrs_ind = (size_t) hr()->hrs_index(); |
ysr@777 | 307 | |
johnc@3891 | 308 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 309 | gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").", |
johnc@3891 | 310 | from, |
johnc@3891 | 311 | UseCompressedOops |
johnc@3891 | 312 | ? oopDesc::load_decode_heap_oop((narrowOop*)from) |
johnc@3891 | 313 | : oopDesc::load_decode_heap_oop((oop*)from)); |
johnc@3891 | 314 | } |
ysr@777 | 315 | |
ysr@777 | 316 | int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift); |
ysr@777 | 317 | |
johnc@3891 | 318 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 319 | gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)", |
johnc@3891 | 320 | hr()->bottom(), from_card, |
johnc@3891 | 321 | _from_card_cache[tid][cur_hrs_ind]); |
johnc@3891 | 322 | } |
ysr@777 | 323 | |
ysr@777 | 324 | if (from_card == _from_card_cache[tid][cur_hrs_ind]) { |
johnc@3891 | 325 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 326 | gclog_or_tty->print_cr(" from-card cache hit."); |
johnc@3891 | 327 | } |
ysr@777 | 328 | assert(contains_reference(from), "We just added it!"); |
ysr@777 | 329 | return; |
ysr@777 | 330 | } else { |
ysr@777 | 331 | _from_card_cache[tid][cur_hrs_ind] = from_card; |
ysr@777 | 332 | } |
ysr@777 | 333 | |
ysr@777 | 334 | // Note that this may be a continued H region. |
ysr@777 | 335 | HeapRegion* from_hr = _g1h->heap_region_containing_raw(from); |
johnc@1242 | 336 | RegionIdx_t from_hrs_ind = (RegionIdx_t) from_hr->hrs_index(); |
ysr@777 | 337 | |
ysr@777 | 338 | // If the region is already coarsened, return. |
ysr@777 | 339 | if (_coarse_map.at(from_hrs_ind)) { |
johnc@3891 | 340 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 341 | gclog_or_tty->print_cr(" coarse map hit."); |
johnc@3891 | 342 | } |
ysr@777 | 343 | assert(contains_reference(from), "We just added it!"); |
ysr@777 | 344 | return; |
ysr@777 | 345 | } |
ysr@777 | 346 | |
ysr@777 | 347 | // Otherwise find a per-region table to add it to. |
ysr@777 | 348 | size_t ind = from_hrs_ind & _mod_max_fine_entries_mask; |
johnc@3891 | 349 | PerRegionTable* prt = find_region_table(ind, from_hr); |
ysr@777 | 350 | if (prt == NULL) { |
ysr@777 | 351 | MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag); |
ysr@777 | 352 | // Confirm that it's really not there... |
ysr@777 | 353 | prt = find_region_table(ind, from_hr); |
ysr@777 | 354 | if (prt == NULL) { |
ysr@777 | 355 | |
ysr@777 | 356 | uintptr_t from_hr_bot_card_index = |
ysr@777 | 357 | uintptr_t(from_hr->bottom()) |
ysr@777 | 358 | >> CardTableModRefBS::card_shift; |
johnc@1242 | 359 | CardIdx_t card_index = from_card - from_hr_bot_card_index; |
johnc@3182 | 360 | assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, |
ysr@777 | 361 | "Must be in range."); |
ysr@777 | 362 | if (G1HRRSUseSparseTable && |
johnc@1242 | 363 | _sparse_table.add_card(from_hrs_ind, card_index)) { |
ysr@777 | 364 | if (G1RecordHRRSOops) { |
ysr@777 | 365 | HeapRegionRemSet::record(hr(), from); |
johnc@3891 | 366 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 367 | gclog_or_tty->print(" Added card " PTR_FORMAT " to region " |
johnc@3891 | 368 | "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n", |
johnc@3891 | 369 | align_size_down(uintptr_t(from), |
johnc@3891 | 370 | CardTableModRefBS::card_size), |
johnc@3891 | 371 | hr()->bottom(), from); |
johnc@3891 | 372 | } |
ysr@777 | 373 | } |
johnc@3891 | 374 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 375 | gclog_or_tty->print_cr(" added card to sparse table."); |
johnc@3891 | 376 | } |
ysr@777 | 377 | assert(contains_reference_locked(from), "We just added it!"); |
ysr@777 | 378 | return; |
ysr@777 | 379 | } else { |
johnc@3891 | 380 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 381 | gclog_or_tty->print_cr(" [tid %d] sparse table entry " |
johnc@3891 | 382 | "overflow(f: %d, t: %d)", |
johnc@3891 | 383 | tid, from_hrs_ind, cur_hrs_ind); |
johnc@3891 | 384 | } |
ysr@777 | 385 | } |
ysr@777 | 386 | |
ysr@777 | 387 | if (_n_fine_entries == _max_fine_entries) { |
ysr@777 | 388 | prt = delete_region_table(); |
ysr@777 | 389 | } else { |
johnc@3891 | 390 | prt = PerRegionTable::alloc(from_hr); |
ysr@777 | 391 | } |
ysr@777 | 392 | prt->init(from_hr); |
ysr@777 | 393 | |
johnc@3891 | 394 | PerRegionTable* first_prt = _fine_grain_regions[ind]; |
ysr@777 | 395 | prt->set_next(first_prt); // XXX Maybe move to init? |
ysr@777 | 396 | _fine_grain_regions[ind] = prt; |
ysr@777 | 397 | _n_fine_entries++; |
ysr@777 | 398 | |
ysr@777 | 399 | if (G1HRRSUseSparseTable) { |
iveresov@1696 | 400 | // Transfer from sparse to fine-grain. |
iveresov@1696 | 401 | SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrs_ind); |
iveresov@1696 | 402 | assert(sprt_entry != NULL, "There should have been an entry"); |
iveresov@1696 | 403 | for (int i = 0; i < SparsePRTEntry::cards_num(); i++) { |
iveresov@1696 | 404 | CardIdx_t c = sprt_entry->card(i); |
ysr@777 | 405 | if (c != SparsePRTEntry::NullEntry) { |
ysr@777 | 406 | prt->add_card(c); |
ysr@777 | 407 | } |
ysr@777 | 408 | } |
ysr@777 | 409 | // Now we can delete the sparse entry. |
johnc@1242 | 410 | bool res = _sparse_table.delete_entry(from_hrs_ind); |
ysr@777 | 411 | assert(res, "It should have been there."); |
ysr@777 | 412 | } |
ysr@777 | 413 | } |
ysr@777 | 414 | assert(prt != NULL && prt->hr() == from_hr, "consequence"); |
ysr@777 | 415 | } |
ysr@777 | 416 | // Note that we can't assert "prt->hr() == from_hr", because of the |
ysr@777 | 417 | // possibility of concurrent reuse. But see head comment of |
ysr@777 | 418 | // OtherRegionsTable for why this is OK. |
ysr@777 | 419 | assert(prt != NULL, "Inv"); |
ysr@777 | 420 | |
johnc@3891 | 421 | prt->add_reference(from); |
johnc@3891 | 422 | |
ysr@777 | 423 | if (G1RecordHRRSOops) { |
ysr@777 | 424 | HeapRegionRemSet::record(hr(), from); |
johnc@3891 | 425 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 426 | gclog_or_tty->print("Added card " PTR_FORMAT " to region " |
johnc@3891 | 427 | "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n", |
johnc@3891 | 428 | align_size_down(uintptr_t(from), |
johnc@3891 | 429 | CardTableModRefBS::card_size), |
johnc@3891 | 430 | hr()->bottom(), from); |
johnc@3891 | 431 | } |
ysr@777 | 432 | } |
ysr@777 | 433 | assert(contains_reference(from), "We just added it!"); |
ysr@777 | 434 | } |
ysr@777 | 435 | |
johnc@3891 | 436 | PerRegionTable* |
ysr@777 | 437 | OtherRegionsTable::find_region_table(size_t ind, HeapRegion* hr) const { |
ysr@777 | 438 | assert(0 <= ind && ind < _max_fine_entries, "Preconditions."); |
johnc@3891 | 439 | PerRegionTable* prt = _fine_grain_regions[ind]; |
ysr@777 | 440 | while (prt != NULL && prt->hr() != hr) { |
ysr@777 | 441 | prt = prt->next(); |
ysr@777 | 442 | } |
ysr@777 | 443 | // Loop postcondition is the method postcondition. |
ysr@777 | 444 | return prt; |
ysr@777 | 445 | } |
ysr@777 | 446 | |
ysr@777 | 447 | jint OtherRegionsTable::_n_coarsenings = 0; |
ysr@777 | 448 | |
johnc@3891 | 449 | PerRegionTable* OtherRegionsTable::delete_region_table() { |
ysr@777 | 450 | assert(_m.owned_by_self(), "Precondition"); |
ysr@777 | 451 | assert(_n_fine_entries == _max_fine_entries, "Precondition"); |
johnc@3891 | 452 | PerRegionTable* max = NULL; |
ysr@777 | 453 | jint max_occ = 0; |
johnc@3891 | 454 | PerRegionTable** max_prev; |
ysr@777 | 455 | size_t max_ind; |
ysr@777 | 456 | |
ysr@777 | 457 | size_t i = _fine_eviction_start; |
ysr@777 | 458 | for (size_t k = 0; k < _fine_eviction_sample_size; k++) { |
ysr@777 | 459 | size_t ii = i; |
ysr@777 | 460 | // Make sure we get a non-NULL sample. |
ysr@777 | 461 | while (_fine_grain_regions[ii] == NULL) { |
ysr@777 | 462 | ii++; |
ysr@777 | 463 | if (ii == _max_fine_entries) ii = 0; |
ysr@777 | 464 | guarantee(ii != i, "We must find one."); |
ysr@777 | 465 | } |
johnc@3891 | 466 | PerRegionTable** prev = &_fine_grain_regions[ii]; |
johnc@3891 | 467 | PerRegionTable* cur = *prev; |
ysr@777 | 468 | while (cur != NULL) { |
ysr@777 | 469 | jint cur_occ = cur->occupied(); |
ysr@777 | 470 | if (max == NULL || cur_occ > max_occ) { |
ysr@777 | 471 | max = cur; |
ysr@777 | 472 | max_prev = prev; |
ysr@777 | 473 | max_ind = i; |
ysr@777 | 474 | max_occ = cur_occ; |
ysr@777 | 475 | } |
ysr@777 | 476 | prev = cur->next_addr(); |
ysr@777 | 477 | cur = cur->next(); |
ysr@777 | 478 | } |
ysr@777 | 479 | i = i + _fine_eviction_stride; |
ysr@777 | 480 | if (i >= _n_fine_entries) i = i - _n_fine_entries; |
ysr@777 | 481 | } |
johnc@3891 | 482 | |
ysr@777 | 483 | _fine_eviction_start++; |
johnc@3891 | 484 | |
johnc@3891 | 485 | if (_fine_eviction_start >= _n_fine_entries) { |
ysr@777 | 486 | _fine_eviction_start -= _n_fine_entries; |
ysr@777 | 487 | } |
johnc@3891 | 488 | |
ysr@777 | 489 | guarantee(max != NULL, "Since _n_fine_entries > 0"); |
ysr@777 | 490 | |
ysr@777 | 491 | // Set the corresponding coarse bit. |
tonyp@3713 | 492 | size_t max_hrs_index = (size_t) max->hr()->hrs_index(); |
ysr@777 | 493 | if (!_coarse_map.at(max_hrs_index)) { |
ysr@777 | 494 | _coarse_map.at_put(max_hrs_index, true); |
ysr@777 | 495 | _n_coarse_entries++; |
johnc@3891 | 496 | if (G1TraceHeapRegionRememberedSet) { |
johnc@3891 | 497 | gclog_or_tty->print("Coarsened entry in region [" PTR_FORMAT "...] " |
johnc@3891 | 498 | "for region [" PTR_FORMAT "...] (%d coarse entries).\n", |
johnc@3891 | 499 | hr()->bottom(), |
johnc@3891 | 500 | max->hr()->bottom(), |
johnc@3891 | 501 | _n_coarse_entries); |
johnc@3891 | 502 | } |
ysr@777 | 503 | } |
ysr@777 | 504 | |
ysr@777 | 505 | // Unsplice. |
ysr@777 | 506 | *max_prev = max->next(); |
ysr@777 | 507 | Atomic::inc(&_n_coarsenings); |
ysr@777 | 508 | _n_fine_entries--; |
ysr@777 | 509 | return max; |
ysr@777 | 510 | } |
ysr@777 | 511 | |
ysr@777 | 512 | |
ysr@777 | 513 | // At present, this must be called stop-world single-threaded. |
ysr@777 | 514 | void OtherRegionsTable::scrub(CardTableModRefBS* ctbs, |
ysr@777 | 515 | BitMap* region_bm, BitMap* card_bm) { |
ysr@777 | 516 | // First eliminated garbage regions from the coarse map. |
tonyp@3713 | 517 | if (G1RSScrubVerbose) { |
tonyp@3713 | 518 | gclog_or_tty->print_cr("Scrubbing region %u:", hr()->hrs_index()); |
tonyp@3713 | 519 | } |
ysr@777 | 520 | |
ysr@777 | 521 | assert(_coarse_map.size() == region_bm->size(), "Precondition"); |
tonyp@3713 | 522 | if (G1RSScrubVerbose) { |
tonyp@3713 | 523 | gclog_or_tty->print(" Coarse map: before = "SIZE_FORMAT"...", |
tonyp@3713 | 524 | _n_coarse_entries); |
tonyp@3713 | 525 | } |
ysr@777 | 526 | _coarse_map.set_intersection(*region_bm); |
ysr@777 | 527 | _n_coarse_entries = _coarse_map.count_one_bits(); |
tonyp@3713 | 528 | if (G1RSScrubVerbose) { |
tonyp@3713 | 529 | gclog_or_tty->print_cr(" after = "SIZE_FORMAT".", _n_coarse_entries); |
tonyp@3713 | 530 | } |
ysr@777 | 531 | |
ysr@777 | 532 | // Now do the fine-grained maps. |
ysr@777 | 533 | for (size_t i = 0; i < _max_fine_entries; i++) { |
johnc@3891 | 534 | PerRegionTable* cur = _fine_grain_regions[i]; |
johnc@3891 | 535 | PerRegionTable** prev = &_fine_grain_regions[i]; |
ysr@777 | 536 | while (cur != NULL) { |
johnc@3891 | 537 | PerRegionTable* nxt = cur->next(); |
ysr@777 | 538 | // If the entire region is dead, eliminate. |
tonyp@3713 | 539 | if (G1RSScrubVerbose) { |
tonyp@3713 | 540 | gclog_or_tty->print_cr(" For other region %u:", |
tonyp@2963 | 541 | cur->hr()->hrs_index()); |
tonyp@3713 | 542 | } |
tonyp@3713 | 543 | if (!region_bm->at((size_t) cur->hr()->hrs_index())) { |
ysr@777 | 544 | *prev = nxt; |
ysr@777 | 545 | cur->set_next(NULL); |
ysr@777 | 546 | _n_fine_entries--; |
tonyp@3713 | 547 | if (G1RSScrubVerbose) { |
ysr@777 | 548 | gclog_or_tty->print_cr(" deleted via region map."); |
tonyp@3713 | 549 | } |
johnc@3891 | 550 | PerRegionTable::free(cur); |
ysr@777 | 551 | } else { |
ysr@777 | 552 | // Do fine-grain elimination. |
tonyp@3713 | 553 | if (G1RSScrubVerbose) { |
ysr@777 | 554 | gclog_or_tty->print(" occ: before = %4d.", cur->occupied()); |
tonyp@3713 | 555 | } |
ysr@777 | 556 | cur->scrub(ctbs, card_bm); |
tonyp@3713 | 557 | if (G1RSScrubVerbose) { |
ysr@777 | 558 | gclog_or_tty->print_cr(" after = %4d.", cur->occupied()); |
tonyp@3713 | 559 | } |
ysr@777 | 560 | // Did that empty the table completely? |
ysr@777 | 561 | if (cur->occupied() == 0) { |
ysr@777 | 562 | *prev = nxt; |
ysr@777 | 563 | cur->set_next(NULL); |
ysr@777 | 564 | _n_fine_entries--; |
johnc@3891 | 565 | PerRegionTable::free(cur); |
ysr@777 | 566 | } else { |
ysr@777 | 567 | prev = cur->next_addr(); |
ysr@777 | 568 | } |
ysr@777 | 569 | } |
ysr@777 | 570 | cur = nxt; |
ysr@777 | 571 | } |
ysr@777 | 572 | } |
ysr@777 | 573 | // Since we may have deleted a from_card_cache entry from the RS, clear |
ysr@777 | 574 | // the FCC. |
ysr@777 | 575 | clear_fcc(); |
ysr@777 | 576 | } |
ysr@777 | 577 | |
ysr@777 | 578 | |
ysr@777 | 579 | size_t OtherRegionsTable::occupied() const { |
ysr@777 | 580 | // Cast away const in this case. |
ysr@777 | 581 | MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag); |
ysr@777 | 582 | size_t sum = occ_fine(); |
ysr@777 | 583 | sum += occ_sparse(); |
ysr@777 | 584 | sum += occ_coarse(); |
ysr@777 | 585 | return sum; |
ysr@777 | 586 | } |
ysr@777 | 587 | |
ysr@777 | 588 | size_t OtherRegionsTable::occ_fine() const { |
ysr@777 | 589 | size_t sum = 0; |
ysr@777 | 590 | for (size_t i = 0; i < _max_fine_entries; i++) { |
johnc@3891 | 591 | PerRegionTable* cur = _fine_grain_regions[i]; |
ysr@777 | 592 | while (cur != NULL) { |
ysr@777 | 593 | sum += cur->occupied(); |
ysr@777 | 594 | cur = cur->next(); |
ysr@777 | 595 | } |
ysr@777 | 596 | } |
ysr@777 | 597 | return sum; |
ysr@777 | 598 | } |
ysr@777 | 599 | |
ysr@777 | 600 | size_t OtherRegionsTable::occ_coarse() const { |
tonyp@1377 | 601 | return (_n_coarse_entries * HeapRegion::CardsPerRegion); |
ysr@777 | 602 | } |
ysr@777 | 603 | |
ysr@777 | 604 | size_t OtherRegionsTable::occ_sparse() const { |
ysr@777 | 605 | return _sparse_table.occupied(); |
ysr@777 | 606 | } |
ysr@777 | 607 | |
ysr@777 | 608 | size_t OtherRegionsTable::mem_size() const { |
ysr@777 | 609 | // Cast away const in this case. |
ysr@777 | 610 | MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag); |
ysr@777 | 611 | size_t sum = 0; |
ysr@777 | 612 | for (size_t i = 0; i < _max_fine_entries; i++) { |
johnc@3891 | 613 | PerRegionTable* cur = _fine_grain_regions[i]; |
ysr@777 | 614 | while (cur != NULL) { |
ysr@777 | 615 | sum += cur->mem_size(); |
ysr@777 | 616 | cur = cur->next(); |
ysr@777 | 617 | } |
ysr@777 | 618 | } |
johnc@3891 | 619 | sum += (sizeof(PerRegionTable*) * _max_fine_entries); |
ysr@777 | 620 | sum += (_coarse_map.size_in_words() * HeapWordSize); |
ysr@777 | 621 | sum += (_sparse_table.mem_size()); |
ysr@777 | 622 | sum += sizeof(*this) - sizeof(_sparse_table); // Avoid double counting above. |
ysr@777 | 623 | return sum; |
ysr@777 | 624 | } |
ysr@777 | 625 | |
ysr@777 | 626 | size_t OtherRegionsTable::static_mem_size() { |
ysr@777 | 627 | return _from_card_cache_mem_size; |
ysr@777 | 628 | } |
ysr@777 | 629 | |
ysr@777 | 630 | size_t OtherRegionsTable::fl_mem_size() { |
johnc@3891 | 631 | return PerRegionTable::fl_mem_size(); |
ysr@777 | 632 | } |
ysr@777 | 633 | |
ysr@777 | 634 | void OtherRegionsTable::clear_fcc() { |
ysr@777 | 635 | for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { |
ysr@777 | 636 | _from_card_cache[i][hr()->hrs_index()] = -1; |
ysr@777 | 637 | } |
ysr@777 | 638 | } |
ysr@777 | 639 | |
ysr@777 | 640 | void OtherRegionsTable::clear() { |
ysr@777 | 641 | MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag); |
ysr@777 | 642 | for (size_t i = 0; i < _max_fine_entries; i++) { |
johnc@3891 | 643 | PerRegionTable* cur = _fine_grain_regions[i]; |
ysr@777 | 644 | while (cur != NULL) { |
johnc@3891 | 645 | PerRegionTable* nxt = cur->next(); |
johnc@3891 | 646 | PerRegionTable::free(cur); |
ysr@777 | 647 | cur = nxt; |
ysr@777 | 648 | } |
ysr@777 | 649 | _fine_grain_regions[i] = NULL; |
ysr@777 | 650 | } |
ysr@777 | 651 | _sparse_table.clear(); |
ysr@777 | 652 | _coarse_map.clear(); |
ysr@777 | 653 | _n_fine_entries = 0; |
ysr@777 | 654 | _n_coarse_entries = 0; |
ysr@777 | 655 | |
ysr@777 | 656 | clear_fcc(); |
ysr@777 | 657 | } |
ysr@777 | 658 | |
ysr@777 | 659 | void OtherRegionsTable::clear_incoming_entry(HeapRegion* from_hr) { |
ysr@777 | 660 | MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag); |
tonyp@3713 | 661 | size_t hrs_ind = (size_t) from_hr->hrs_index(); |
ysr@777 | 662 | size_t ind = hrs_ind & _mod_max_fine_entries_mask; |
ysr@777 | 663 | if (del_single_region_table(ind, from_hr)) { |
ysr@777 | 664 | assert(!_coarse_map.at(hrs_ind), "Inv"); |
ysr@777 | 665 | } else { |
ysr@777 | 666 | _coarse_map.par_at_put(hrs_ind, 0); |
ysr@777 | 667 | } |
ysr@777 | 668 | // Check to see if any of the fcc entries come from here. |
tonyp@3713 | 669 | size_t hr_ind = (size_t) hr()->hrs_index(); |
ysr@777 | 670 | for (int tid = 0; tid < HeapRegionRemSet::num_par_rem_sets(); tid++) { |
ysr@777 | 671 | int fcc_ent = _from_card_cache[tid][hr_ind]; |
ysr@777 | 672 | if (fcc_ent != -1) { |
ysr@777 | 673 | HeapWord* card_addr = (HeapWord*) |
ysr@777 | 674 | (uintptr_t(fcc_ent) << CardTableModRefBS::card_shift); |
ysr@777 | 675 | if (hr()->is_in_reserved(card_addr)) { |
ysr@777 | 676 | // Clear the from card cache. |
ysr@777 | 677 | _from_card_cache[tid][hr_ind] = -1; |
ysr@777 | 678 | } |
ysr@777 | 679 | } |
ysr@777 | 680 | } |
ysr@777 | 681 | } |
ysr@777 | 682 | |
ysr@777 | 683 | bool OtherRegionsTable::del_single_region_table(size_t ind, |
ysr@777 | 684 | HeapRegion* hr) { |
ysr@777 | 685 | assert(0 <= ind && ind < _max_fine_entries, "Preconditions."); |
johnc@3891 | 686 | PerRegionTable** prev_addr = &_fine_grain_regions[ind]; |
johnc@3891 | 687 | PerRegionTable* prt = *prev_addr; |
ysr@777 | 688 | while (prt != NULL && prt->hr() != hr) { |
ysr@777 | 689 | prev_addr = prt->next_addr(); |
ysr@777 | 690 | prt = prt->next(); |
ysr@777 | 691 | } |
ysr@777 | 692 | if (prt != NULL) { |
ysr@777 | 693 | assert(prt->hr() == hr, "Loop postcondition."); |
ysr@777 | 694 | *prev_addr = prt->next(); |
johnc@3891 | 695 | PerRegionTable::free(prt); |
ysr@777 | 696 | _n_fine_entries--; |
ysr@777 | 697 | return true; |
ysr@777 | 698 | } else { |
ysr@777 | 699 | return false; |
ysr@777 | 700 | } |
ysr@777 | 701 | } |
ysr@777 | 702 | |
ysr@1280 | 703 | bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const { |
ysr@777 | 704 | // Cast away const in this case. |
ysr@777 | 705 | MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag); |
ysr@777 | 706 | return contains_reference_locked(from); |
ysr@777 | 707 | } |
ysr@777 | 708 | |
ysr@1280 | 709 | bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const { |
ysr@777 | 710 | HeapRegion* hr = _g1h->heap_region_containing_raw(from); |
ysr@777 | 711 | if (hr == NULL) return false; |
johnc@1242 | 712 | RegionIdx_t hr_ind = (RegionIdx_t) hr->hrs_index(); |
ysr@777 | 713 | // Is this region in the coarse map? |
ysr@777 | 714 | if (_coarse_map.at(hr_ind)) return true; |
ysr@777 | 715 | |
johnc@3891 | 716 | PerRegionTable* prt = find_region_table(hr_ind & _mod_max_fine_entries_mask, |
ysr@777 | 717 | hr); |
ysr@777 | 718 | if (prt != NULL) { |
ysr@777 | 719 | return prt->contains_reference(from); |
ysr@777 | 720 | |
ysr@777 | 721 | } else { |
ysr@777 | 722 | uintptr_t from_card = |
ysr@777 | 723 | (uintptr_t(from) >> CardTableModRefBS::card_shift); |
ysr@777 | 724 | uintptr_t hr_bot_card_index = |
ysr@777 | 725 | uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift; |
ysr@777 | 726 | assert(from_card >= hr_bot_card_index, "Inv"); |
johnc@1242 | 727 | CardIdx_t card_index = from_card - hr_bot_card_index; |
johnc@3182 | 728 | assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, |
tonyp@1377 | 729 | "Must be in range."); |
johnc@1242 | 730 | return _sparse_table.contains_card(hr_ind, card_index); |
ysr@777 | 731 | } |
ysr@777 | 732 | |
ysr@777 | 733 | |
ysr@777 | 734 | } |
ysr@777 | 735 | |
tonyp@2493 | 736 | void |
tonyp@2493 | 737 | OtherRegionsTable::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) { |
tonyp@2493 | 738 | _sparse_table.do_cleanup_work(hrrs_cleanup_task); |
tonyp@2493 | 739 | } |
tonyp@2493 | 740 | |
iveresov@1230 | 741 | // Determines how many threads can add records to an rset in parallel. |
iveresov@1230 | 742 | // This can be done by either mutator threads together with the |
iveresov@1230 | 743 | // concurrent refinement threads or GC threads. |
ysr@777 | 744 | int HeapRegionRemSet::num_par_rem_sets() { |
iveresov@1230 | 745 | return (int)MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads); |
ysr@777 | 746 | } |
ysr@777 | 747 | |
ysr@777 | 748 | HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa, |
ysr@777 | 749 | HeapRegion* hr) |
tonyp@2974 | 750 | : _bosa(bosa), _other_regions(hr) { |
tonyp@2974 | 751 | reset_for_par_iteration(); |
tonyp@2974 | 752 | } |
ysr@777 | 753 | |
iveresov@1696 | 754 | void HeapRegionRemSet::setup_remset_size() { |
iveresov@1696 | 755 | // Setup sparse and fine-grain tables sizes. |
iveresov@1696 | 756 | // table_size = base * (log(region_size / 1M) + 1) |
brutisso@3810 | 757 | const int LOG_M = 20; |
brutisso@3810 | 758 | int region_size_log_mb = MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0); |
iveresov@1696 | 759 | if (FLAG_IS_DEFAULT(G1RSetSparseRegionEntries)) { |
iveresov@1696 | 760 | G1RSetSparseRegionEntries = G1RSetSparseRegionEntriesBase * (region_size_log_mb + 1); |
iveresov@1696 | 761 | } |
iveresov@1696 | 762 | if (FLAG_IS_DEFAULT(G1RSetRegionEntries)) { |
iveresov@1696 | 763 | G1RSetRegionEntries = G1RSetRegionEntriesBase * (region_size_log_mb + 1); |
iveresov@1696 | 764 | } |
iveresov@1696 | 765 | guarantee(G1RSetSparseRegionEntries > 0 && G1RSetRegionEntries > 0 , "Sanity"); |
iveresov@1696 | 766 | } |
iveresov@1696 | 767 | |
ysr@777 | 768 | bool HeapRegionRemSet::claim_iter() { |
ysr@777 | 769 | if (_iter_state != Unclaimed) return false; |
ysr@777 | 770 | jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_state), Unclaimed); |
ysr@777 | 771 | return (res == Unclaimed); |
ysr@777 | 772 | } |
ysr@777 | 773 | |
ysr@777 | 774 | void HeapRegionRemSet::set_iter_complete() { |
ysr@777 | 775 | _iter_state = Complete; |
ysr@777 | 776 | } |
ysr@777 | 777 | |
ysr@777 | 778 | bool HeapRegionRemSet::iter_is_complete() { |
ysr@777 | 779 | return _iter_state == Complete; |
ysr@777 | 780 | } |
ysr@777 | 781 | |
ysr@777 | 782 | void HeapRegionRemSet::init_iterator(HeapRegionRemSetIterator* iter) const { |
ysr@777 | 783 | iter->initialize(this); |
ysr@777 | 784 | } |
ysr@777 | 785 | |
ysr@777 | 786 | #ifndef PRODUCT |
ysr@777 | 787 | void HeapRegionRemSet::print() const { |
ysr@777 | 788 | HeapRegionRemSetIterator iter; |
ysr@777 | 789 | init_iterator(&iter); |
ysr@777 | 790 | size_t card_index; |
ysr@777 | 791 | while (iter.has_next(card_index)) { |
ysr@777 | 792 | HeapWord* card_start = |
ysr@777 | 793 | G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); |
tonyp@2974 | 794 | gclog_or_tty->print_cr(" Card " PTR_FORMAT, card_start); |
ysr@777 | 795 | } |
johnc@3891 | 796 | |
ysr@777 | 797 | if (iter.n_yielded() != occupied()) { |
ysr@777 | 798 | gclog_or_tty->print_cr("Yielded disagrees with occupied:"); |
ysr@777 | 799 | gclog_or_tty->print_cr(" %6d yielded (%6d coarse, %6d fine).", |
ysr@777 | 800 | iter.n_yielded(), |
ysr@777 | 801 | iter.n_yielded_coarse(), iter.n_yielded_fine()); |
ysr@777 | 802 | gclog_or_tty->print_cr(" %6d occ (%6d coarse, %6d fine).", |
ysr@777 | 803 | occupied(), occ_coarse(), occ_fine()); |
ysr@777 | 804 | } |
ysr@777 | 805 | guarantee(iter.n_yielded() == occupied(), |
ysr@777 | 806 | "We should have yielded all the represented cards."); |
ysr@777 | 807 | } |
ysr@777 | 808 | #endif |
ysr@777 | 809 | |
ysr@777 | 810 | void HeapRegionRemSet::cleanup() { |
ysr@777 | 811 | SparsePRT::cleanup_all(); |
ysr@777 | 812 | } |
ysr@777 | 813 | |
ysr@777 | 814 | void HeapRegionRemSet::clear() { |
ysr@777 | 815 | _other_regions.clear(); |
ysr@777 | 816 | assert(occupied() == 0, "Should be clear."); |
tonyp@2974 | 817 | reset_for_par_iteration(); |
tonyp@2974 | 818 | } |
tonyp@2974 | 819 | |
tonyp@2974 | 820 | void HeapRegionRemSet::reset_for_par_iteration() { |
tonyp@2974 | 821 | _iter_state = Unclaimed; |
tonyp@2974 | 822 | _iter_claimed = 0; |
tonyp@2974 | 823 | // It's good to check this to make sure that the two methods are in sync. |
tonyp@2974 | 824 | assert(verify_ready_for_par_iteration(), "post-condition"); |
ysr@777 | 825 | } |
ysr@777 | 826 | |
ysr@777 | 827 | void HeapRegionRemSet::scrub(CardTableModRefBS* ctbs, |
ysr@777 | 828 | BitMap* region_bm, BitMap* card_bm) { |
ysr@777 | 829 | _other_regions.scrub(ctbs, region_bm, card_bm); |
ysr@777 | 830 | } |
ysr@777 | 831 | |
ysr@777 | 832 | //-------------------- Iteration -------------------- |
ysr@777 | 833 | |
ysr@777 | 834 | HeapRegionRemSetIterator:: |
ysr@777 | 835 | HeapRegionRemSetIterator() : |
ysr@777 | 836 | _hrrs(NULL), |
ysr@777 | 837 | _g1h(G1CollectedHeap::heap()), |
ysr@777 | 838 | _bosa(NULL), |
tonyp@2239 | 839 | _sparse_iter() { } |
ysr@777 | 840 | |
ysr@777 | 841 | void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) { |
ysr@777 | 842 | _hrrs = hrrs; |
ysr@777 | 843 | _coarse_map = &_hrrs->_other_regions._coarse_map; |
ysr@777 | 844 | _fine_grain_regions = _hrrs->_other_regions._fine_grain_regions; |
ysr@777 | 845 | _bosa = _hrrs->bosa(); |
ysr@777 | 846 | |
ysr@777 | 847 | _is = Sparse; |
ysr@777 | 848 | // Set these values so that we increment to the first region. |
ysr@777 | 849 | _coarse_cur_region_index = -1; |
johnc@3182 | 850 | _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1); |
ysr@777 | 851 | |
ysr@777 | 852 | _cur_region_cur_card = 0; |
ysr@777 | 853 | |
ysr@777 | 854 | _fine_array_index = -1; |
ysr@777 | 855 | _fine_cur_prt = NULL; |
ysr@777 | 856 | |
ysr@777 | 857 | _n_yielded_coarse = 0; |
ysr@777 | 858 | _n_yielded_fine = 0; |
ysr@777 | 859 | _n_yielded_sparse = 0; |
ysr@777 | 860 | |
ysr@777 | 861 | _sparse_iter.init(&hrrs->_other_regions._sparse_table); |
ysr@777 | 862 | } |
ysr@777 | 863 | |
ysr@777 | 864 | bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { |
ysr@777 | 865 | if (_hrrs->_other_regions._n_coarse_entries == 0) return false; |
ysr@777 | 866 | // Go to the next card. |
ysr@777 | 867 | _coarse_cur_region_cur_card++; |
ysr@777 | 868 | // Was the last the last card in the current region? |
tonyp@1377 | 869 | if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) { |
ysr@777 | 870 | // Yes: find the next region. This may leave _coarse_cur_region_index |
ysr@777 | 871 | // Set to the last index, in which case there are no more coarse |
ysr@777 | 872 | // regions. |
ysr@777 | 873 | _coarse_cur_region_index = |
ysr@777 | 874 | (int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1); |
ysr@777 | 875 | if ((size_t)_coarse_cur_region_index < _coarse_map->size()) { |
ysr@777 | 876 | _coarse_cur_region_cur_card = 0; |
ysr@777 | 877 | HeapWord* r_bot = |
tonyp@3713 | 878 | _g1h->region_at((uint) _coarse_cur_region_index)->bottom(); |
ysr@777 | 879 | _cur_region_card_offset = _bosa->index_for(r_bot); |
ysr@777 | 880 | } else { |
ysr@777 | 881 | return false; |
ysr@777 | 882 | } |
ysr@777 | 883 | } |
ysr@777 | 884 | // If we didn't return false above, then we can yield a card. |
ysr@777 | 885 | card_index = _cur_region_card_offset + _coarse_cur_region_cur_card; |
ysr@777 | 886 | return true; |
ysr@777 | 887 | } |
ysr@777 | 888 | |
ysr@777 | 889 | void HeapRegionRemSetIterator::fine_find_next_non_null_prt() { |
ysr@777 | 890 | // Otherwise, find the next bucket list in the array. |
ysr@777 | 891 | _fine_array_index++; |
ysr@777 | 892 | while (_fine_array_index < (int) OtherRegionsTable::_max_fine_entries) { |
ysr@777 | 893 | _fine_cur_prt = _fine_grain_regions[_fine_array_index]; |
ysr@777 | 894 | if (_fine_cur_prt != NULL) return; |
ysr@777 | 895 | else _fine_array_index++; |
ysr@777 | 896 | } |
ysr@777 | 897 | assert(_fine_cur_prt == NULL, "Loop post"); |
ysr@777 | 898 | } |
ysr@777 | 899 | |
ysr@777 | 900 | bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) { |
ysr@777 | 901 | if (fine_has_next()) { |
ysr@777 | 902 | _cur_region_cur_card = |
ysr@777 | 903 | _fine_cur_prt->_bm.get_next_one_offset(_cur_region_cur_card + 1); |
ysr@777 | 904 | } |
ysr@777 | 905 | while (!fine_has_next()) { |
tonyp@1377 | 906 | if (_cur_region_cur_card == (size_t) HeapRegion::CardsPerRegion) { |
ysr@777 | 907 | _cur_region_cur_card = 0; |
ysr@777 | 908 | _fine_cur_prt = _fine_cur_prt->next(); |
ysr@777 | 909 | } |
ysr@777 | 910 | if (_fine_cur_prt == NULL) { |
ysr@777 | 911 | fine_find_next_non_null_prt(); |
ysr@777 | 912 | if (_fine_cur_prt == NULL) return false; |
ysr@777 | 913 | } |
ysr@777 | 914 | assert(_fine_cur_prt != NULL && _cur_region_cur_card == 0, |
ysr@777 | 915 | "inv."); |
ysr@777 | 916 | HeapWord* r_bot = |
ysr@777 | 917 | _fine_cur_prt->hr()->bottom(); |
ysr@777 | 918 | _cur_region_card_offset = _bosa->index_for(r_bot); |
ysr@777 | 919 | _cur_region_cur_card = _fine_cur_prt->_bm.get_next_one_offset(0); |
ysr@777 | 920 | } |
ysr@777 | 921 | assert(fine_has_next(), "Or else we exited the loop via the return."); |
ysr@777 | 922 | card_index = _cur_region_card_offset + _cur_region_cur_card; |
ysr@777 | 923 | return true; |
ysr@777 | 924 | } |
ysr@777 | 925 | |
ysr@777 | 926 | bool HeapRegionRemSetIterator::fine_has_next() { |
ysr@777 | 927 | return |
ysr@777 | 928 | _fine_cur_prt != NULL && |
johnc@3182 | 929 | _cur_region_cur_card < HeapRegion::CardsPerRegion; |
ysr@777 | 930 | } |
ysr@777 | 931 | |
ysr@777 | 932 | bool HeapRegionRemSetIterator::has_next(size_t& card_index) { |
ysr@777 | 933 | switch (_is) { |
ysr@777 | 934 | case Sparse: |
ysr@777 | 935 | if (_sparse_iter.has_next(card_index)) { |
ysr@777 | 936 | _n_yielded_sparse++; |
ysr@777 | 937 | return true; |
ysr@777 | 938 | } |
ysr@777 | 939 | // Otherwise, deliberate fall-through |
ysr@777 | 940 | _is = Fine; |
ysr@777 | 941 | case Fine: |
ysr@777 | 942 | if (fine_has_next(card_index)) { |
ysr@777 | 943 | _n_yielded_fine++; |
ysr@777 | 944 | return true; |
ysr@777 | 945 | } |
ysr@777 | 946 | // Otherwise, deliberate fall-through |
ysr@777 | 947 | _is = Coarse; |
ysr@777 | 948 | case Coarse: |
ysr@777 | 949 | if (coarse_has_next(card_index)) { |
ysr@777 | 950 | _n_yielded_coarse++; |
ysr@777 | 951 | return true; |
ysr@777 | 952 | } |
ysr@777 | 953 | // Otherwise... |
ysr@777 | 954 | break; |
ysr@777 | 955 | } |
ysr@777 | 956 | assert(ParallelGCThreads > 1 || |
ysr@777 | 957 | n_yielded() == _hrrs->occupied(), |
ysr@777 | 958 | "Should have yielded all the cards in the rem set " |
ysr@777 | 959 | "(in the non-par case)."); |
ysr@777 | 960 | return false; |
ysr@777 | 961 | } |
ysr@777 | 962 | |
ysr@777 | 963 | |
ysr@777 | 964 | |
ysr@1280 | 965 | OopOrNarrowOopStar* HeapRegionRemSet::_recorded_oops = NULL; |
ysr@1280 | 966 | HeapWord** HeapRegionRemSet::_recorded_cards = NULL; |
ysr@1280 | 967 | HeapRegion** HeapRegionRemSet::_recorded_regions = NULL; |
ysr@1280 | 968 | int HeapRegionRemSet::_n_recorded = 0; |
ysr@777 | 969 | |
ysr@777 | 970 | HeapRegionRemSet::Event* HeapRegionRemSet::_recorded_events = NULL; |
ysr@777 | 971 | int* HeapRegionRemSet::_recorded_event_index = NULL; |
ysr@777 | 972 | int HeapRegionRemSet::_n_recorded_events = 0; |
ysr@777 | 973 | |
ysr@1280 | 974 | void HeapRegionRemSet::record(HeapRegion* hr, OopOrNarrowOopStar f) { |
ysr@777 | 975 | if (_recorded_oops == NULL) { |
ysr@777 | 976 | assert(_n_recorded == 0 |
ysr@777 | 977 | && _recorded_cards == NULL |
ysr@777 | 978 | && _recorded_regions == NULL, |
ysr@777 | 979 | "Inv"); |
ysr@1280 | 980 | _recorded_oops = NEW_C_HEAP_ARRAY(OopOrNarrowOopStar, MaxRecorded); |
ysr@1280 | 981 | _recorded_cards = NEW_C_HEAP_ARRAY(HeapWord*, MaxRecorded); |
ysr@1280 | 982 | _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*, MaxRecorded); |
ysr@777 | 983 | } |
ysr@777 | 984 | if (_n_recorded == MaxRecorded) { |
ysr@777 | 985 | gclog_or_tty->print_cr("Filled up 'recorded' (%d).", MaxRecorded); |
ysr@777 | 986 | } else { |
ysr@777 | 987 | _recorded_cards[_n_recorded] = |
ysr@777 | 988 | (HeapWord*)align_size_down(uintptr_t(f), |
ysr@777 | 989 | CardTableModRefBS::card_size); |
ysr@777 | 990 | _recorded_oops[_n_recorded] = f; |
ysr@777 | 991 | _recorded_regions[_n_recorded] = hr; |
ysr@777 | 992 | _n_recorded++; |
ysr@777 | 993 | } |
ysr@777 | 994 | } |
ysr@777 | 995 | |
ysr@777 | 996 | void HeapRegionRemSet::record_event(Event evnt) { |
ysr@777 | 997 | if (!G1RecordHRRSEvents) return; |
ysr@777 | 998 | |
ysr@777 | 999 | if (_recorded_events == NULL) { |
ysr@777 | 1000 | assert(_n_recorded_events == 0 |
ysr@777 | 1001 | && _recorded_event_index == NULL, |
ysr@777 | 1002 | "Inv"); |
ysr@777 | 1003 | _recorded_events = NEW_C_HEAP_ARRAY(Event, MaxRecordedEvents); |
ysr@777 | 1004 | _recorded_event_index = NEW_C_HEAP_ARRAY(int, MaxRecordedEvents); |
ysr@777 | 1005 | } |
ysr@777 | 1006 | if (_n_recorded_events == MaxRecordedEvents) { |
ysr@777 | 1007 | gclog_or_tty->print_cr("Filled up 'recorded_events' (%d).", MaxRecordedEvents); |
ysr@777 | 1008 | } else { |
ysr@777 | 1009 | _recorded_events[_n_recorded_events] = evnt; |
ysr@777 | 1010 | _recorded_event_index[_n_recorded_events] = _n_recorded; |
ysr@777 | 1011 | _n_recorded_events++; |
ysr@777 | 1012 | } |
ysr@777 | 1013 | } |
ysr@777 | 1014 | |
ysr@777 | 1015 | void HeapRegionRemSet::print_event(outputStream* str, Event evnt) { |
ysr@777 | 1016 | switch (evnt) { |
ysr@777 | 1017 | case Event_EvacStart: |
ysr@777 | 1018 | str->print("Evac Start"); |
ysr@777 | 1019 | break; |
ysr@777 | 1020 | case Event_EvacEnd: |
ysr@777 | 1021 | str->print("Evac End"); |
ysr@777 | 1022 | break; |
ysr@777 | 1023 | case Event_RSUpdateEnd: |
ysr@777 | 1024 | str->print("RS Update End"); |
ysr@777 | 1025 | break; |
ysr@777 | 1026 | } |
ysr@777 | 1027 | } |
ysr@777 | 1028 | |
ysr@777 | 1029 | void HeapRegionRemSet::print_recorded() { |
ysr@777 | 1030 | int cur_evnt = 0; |
ysr@777 | 1031 | Event cur_evnt_kind; |
ysr@777 | 1032 | int cur_evnt_ind = 0; |
ysr@777 | 1033 | if (_n_recorded_events > 0) { |
ysr@777 | 1034 | cur_evnt_kind = _recorded_events[cur_evnt]; |
ysr@777 | 1035 | cur_evnt_ind = _recorded_event_index[cur_evnt]; |
ysr@777 | 1036 | } |
ysr@777 | 1037 | |
ysr@777 | 1038 | for (int i = 0; i < _n_recorded; i++) { |
ysr@777 | 1039 | while (cur_evnt < _n_recorded_events && i == cur_evnt_ind) { |
ysr@777 | 1040 | gclog_or_tty->print("Event: "); |
ysr@777 | 1041 | print_event(gclog_or_tty, cur_evnt_kind); |
ysr@777 | 1042 | gclog_or_tty->print_cr(""); |
ysr@777 | 1043 | cur_evnt++; |
ysr@777 | 1044 | if (cur_evnt < MaxRecordedEvents) { |
ysr@777 | 1045 | cur_evnt_kind = _recorded_events[cur_evnt]; |
ysr@777 | 1046 | cur_evnt_ind = _recorded_event_index[cur_evnt]; |
ysr@777 | 1047 | } |
ysr@777 | 1048 | } |
ysr@777 | 1049 | gclog_or_tty->print("Added card " PTR_FORMAT " to region [" PTR_FORMAT "...]" |
ysr@777 | 1050 | " for ref " PTR_FORMAT ".\n", |
ysr@777 | 1051 | _recorded_cards[i], _recorded_regions[i]->bottom(), |
ysr@777 | 1052 | _recorded_oops[i]); |
ysr@777 | 1053 | } |
ysr@777 | 1054 | } |
ysr@777 | 1055 | |
tonyp@2493 | 1056 | void HeapRegionRemSet::reset_for_cleanup_tasks() { |
tonyp@2493 | 1057 | SparsePRT::reset_for_cleanup_tasks(); |
tonyp@2493 | 1058 | } |
tonyp@2493 | 1059 | |
tonyp@2493 | 1060 | void HeapRegionRemSet::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) { |
tonyp@2493 | 1061 | _other_regions.do_cleanup_work(hrrs_cleanup_task); |
tonyp@2493 | 1062 | } |
tonyp@2493 | 1063 | |
tonyp@2493 | 1064 | void |
tonyp@2493 | 1065 | HeapRegionRemSet::finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task) { |
tonyp@2493 | 1066 | SparsePRT::finish_cleanup_task(hrrs_cleanup_task); |
tonyp@2493 | 1067 | } |
tonyp@2493 | 1068 | |
ysr@777 | 1069 | #ifndef PRODUCT |
ysr@777 | 1070 | void HeapRegionRemSet::test() { |
ysr@777 | 1071 | os::sleep(Thread::current(), (jlong)5000, false); |
ysr@777 | 1072 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 1073 | |
iveresov@1696 | 1074 | // Run with "-XX:G1LogRSetRegionEntries=2", so that 1 and 5 end up in same |
ysr@777 | 1075 | // hash bucket. |
ysr@777 | 1076 | HeapRegion* hr0 = g1h->region_at(0); |
ysr@777 | 1077 | HeapRegion* hr1 = g1h->region_at(1); |
ysr@777 | 1078 | HeapRegion* hr2 = g1h->region_at(5); |
ysr@777 | 1079 | HeapRegion* hr3 = g1h->region_at(6); |
ysr@777 | 1080 | HeapRegion* hr4 = g1h->region_at(7); |
ysr@777 | 1081 | HeapRegion* hr5 = g1h->region_at(8); |
ysr@777 | 1082 | |
ysr@777 | 1083 | HeapWord* hr1_start = hr1->bottom(); |
ysr@777 | 1084 | HeapWord* hr1_mid = hr1_start + HeapRegion::GrainWords/2; |
ysr@777 | 1085 | HeapWord* hr1_last = hr1->end() - 1; |
ysr@777 | 1086 | |
ysr@777 | 1087 | HeapWord* hr2_start = hr2->bottom(); |
ysr@777 | 1088 | HeapWord* hr2_mid = hr2_start + HeapRegion::GrainWords/2; |
ysr@777 | 1089 | HeapWord* hr2_last = hr2->end() - 1; |
ysr@777 | 1090 | |
ysr@777 | 1091 | HeapWord* hr3_start = hr3->bottom(); |
ysr@777 | 1092 | HeapWord* hr3_mid = hr3_start + HeapRegion::GrainWords/2; |
ysr@777 | 1093 | HeapWord* hr3_last = hr3->end() - 1; |
ysr@777 | 1094 | |
ysr@777 | 1095 | HeapRegionRemSet* hrrs = hr0->rem_set(); |
ysr@777 | 1096 | |
ysr@777 | 1097 | // Make three references from region 0x101... |
ysr@1280 | 1098 | hrrs->add_reference((OopOrNarrowOopStar)hr1_start); |
ysr@1280 | 1099 | hrrs->add_reference((OopOrNarrowOopStar)hr1_mid); |
ysr@1280 | 1100 | hrrs->add_reference((OopOrNarrowOopStar)hr1_last); |
ysr@777 | 1101 | |
ysr@1280 | 1102 | hrrs->add_reference((OopOrNarrowOopStar)hr2_start); |
ysr@1280 | 1103 | hrrs->add_reference((OopOrNarrowOopStar)hr2_mid); |
ysr@1280 | 1104 | hrrs->add_reference((OopOrNarrowOopStar)hr2_last); |
ysr@777 | 1105 | |
ysr@1280 | 1106 | hrrs->add_reference((OopOrNarrowOopStar)hr3_start); |
ysr@1280 | 1107 | hrrs->add_reference((OopOrNarrowOopStar)hr3_mid); |
ysr@1280 | 1108 | hrrs->add_reference((OopOrNarrowOopStar)hr3_last); |
ysr@777 | 1109 | |
ysr@777 | 1110 | // Now cause a coarsening. |
ysr@1280 | 1111 | hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); |
ysr@1280 | 1112 | hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); |
ysr@777 | 1113 | |
ysr@777 | 1114 | // Now, does iteration yield these three? |
ysr@777 | 1115 | HeapRegionRemSetIterator iter; |
ysr@777 | 1116 | hrrs->init_iterator(&iter); |
ysr@777 | 1117 | size_t sum = 0; |
ysr@777 | 1118 | size_t card_index; |
ysr@777 | 1119 | while (iter.has_next(card_index)) { |
ysr@777 | 1120 | HeapWord* card_start = |
ysr@777 | 1121 | G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); |
ysr@777 | 1122 | gclog_or_tty->print_cr(" Card " PTR_FORMAT ".", card_start); |
ysr@777 | 1123 | sum++; |
ysr@777 | 1124 | } |
ysr@777 | 1125 | guarantee(sum == 11 - 3 + 2048, "Failure"); |
ysr@777 | 1126 | guarantee(sum == hrrs->occupied(), "Failure"); |
ysr@777 | 1127 | } |
ysr@777 | 1128 | #endif |