src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 8604
04d83ba48607
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONREMSET_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONREMSET_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/g1/g1CodeCacheRemSet.hpp"
aoqi@0 29 #include "gc_implementation/g1/sparsePRT.hpp"
aoqi@0 30
aoqi@0 31 // Remembered set for a heap region. Represent a set of "cards" that
aoqi@0 32 // contain pointers into the owner heap region. Cards are defined somewhat
aoqi@0 33 // abstractly, in terms of what the "BlockOffsetTable" in use can parse.
aoqi@0 34
aoqi@0 35 class G1CollectedHeap;
aoqi@0 36 class G1BlockOffsetSharedArray;
aoqi@0 37 class HeapRegion;
aoqi@0 38 class HeapRegionRemSetIterator;
aoqi@0 39 class PerRegionTable;
aoqi@0 40 class SparsePRT;
aoqi@0 41 class nmethod;
aoqi@0 42
aoqi@0 43 // Essentially a wrapper around SparsePRTCleanupTask. See
aoqi@0 44 // sparsePRT.hpp for more details.
aoqi@0 45 class HRRSCleanupTask : public SparsePRTCleanupTask {
aoqi@0 46 };
aoqi@0 47
aoqi@0 48 // The FromCardCache remembers the most recently processed card on the heap on
aoqi@0 49 // a per-region and per-thread basis.
aoqi@0 50 class FromCardCache : public AllStatic {
aoqi@0 51 private:
aoqi@0 52 // Array of card indices. Indexed by thread X and heap region to minimize
aoqi@0 53 // thread contention.
aoqi@0 54 static int** _cache;
aoqi@0 55 static uint _max_regions;
aoqi@0 56 static size_t _static_mem_size;
aoqi@0 57
aoqi@0 58 public:
aoqi@0 59 enum {
aoqi@0 60 InvalidCard = -1 // Card value of an invalid card, i.e. a card index not otherwise used.
aoqi@0 61 };
aoqi@0 62
aoqi@0 63 static void clear(uint region_idx);
aoqi@0 64
aoqi@0 65 // Returns true if the given card is in the cache at the given location, or
aoqi@0 66 // replaces the card at that location and returns false.
aoqi@0 67 static bool contains_or_replace(uint worker_id, uint region_idx, int card) {
aoqi@0 68 int card_in_cache = at(worker_id, region_idx);
aoqi@0 69 if (card_in_cache == card) {
aoqi@0 70 return true;
aoqi@0 71 } else {
aoqi@0 72 set(worker_id, region_idx, card);
aoqi@0 73 return false;
aoqi@0 74 }
aoqi@0 75 }
aoqi@0 76
aoqi@0 77 static int at(uint worker_id, uint region_idx) {
aoqi@0 78 return _cache[worker_id][region_idx];
aoqi@0 79 }
aoqi@0 80
aoqi@0 81 static void set(uint worker_id, uint region_idx, int val) {
aoqi@0 82 _cache[worker_id][region_idx] = val;
aoqi@0 83 }
aoqi@0 84
aoqi@0 85 static void initialize(uint n_par_rs, uint max_num_regions);
aoqi@0 86
tschatzl@7051 87 static void invalidate(uint start_idx, size_t num_regions);
aoqi@0 88
aoqi@0 89 static void print(outputStream* out = gclog_or_tty) PRODUCT_RETURN;
aoqi@0 90
aoqi@0 91 static size_t static_mem_size() {
aoqi@0 92 return _static_mem_size;
aoqi@0 93 }
aoqi@0 94 };
aoqi@0 95
aoqi@0 96 // The "_coarse_map" is a bitmap with one bit for each region, where set
aoqi@0 97 // bits indicate that the corresponding region may contain some pointer
aoqi@0 98 // into the owning region.
aoqi@0 99
aoqi@0 100 // The "_fine_grain_entries" array is an open hash table of PerRegionTables
aoqi@0 101 // (PRTs), indicating regions for which we're keeping the RS as a set of
aoqi@0 102 // cards. The strategy is to cap the size of the fine-grain table,
aoqi@0 103 // deleting an entry and setting the corresponding coarse-grained bit when
aoqi@0 104 // we would overflow this cap.
aoqi@0 105
aoqi@0 106 // We use a mixture of locking and lock-free techniques here. We allow
aoqi@0 107 // threads to locate PRTs without locking, but threads attempting to alter
aoqi@0 108 // a bucket list obtain a lock. This means that any failing attempt to
aoqi@0 109 // find a PRT must be retried with the lock. It might seem dangerous that
aoqi@0 110 // a read can find a PRT that is concurrently deleted. This is all right,
aoqi@0 111 // because:
aoqi@0 112 //
aoqi@0 113 // 1) We only actually free PRT's at safe points (though we reuse them at
aoqi@0 114 // other times).
aoqi@0 115 // 2) We find PRT's in an attempt to add entries. If a PRT is deleted,
aoqi@0 116 // it's _coarse_map bit is set, so the that we were attempting to add
aoqi@0 117 // is represented. If a deleted PRT is re-used, a thread adding a bit,
aoqi@0 118 // thinking the PRT is for a different region, does no harm.
aoqi@0 119
aoqi@0 120 class OtherRegionsTable VALUE_OBJ_CLASS_SPEC {
aoqi@0 121 friend class HeapRegionRemSetIterator;
aoqi@0 122
aoqi@0 123 G1CollectedHeap* _g1h;
aoqi@0 124 Mutex* _m;
aoqi@0 125 HeapRegion* _hr;
aoqi@0 126
aoqi@0 127 // These are protected by "_m".
aoqi@0 128 BitMap _coarse_map;
aoqi@0 129 size_t _n_coarse_entries;
aoqi@0 130 static jint _n_coarsenings;
aoqi@0 131
aoqi@0 132 PerRegionTable** _fine_grain_regions;
aoqi@0 133 size_t _n_fine_entries;
aoqi@0 134
aoqi@0 135 // The fine grain remembered sets are doubly linked together using
aoqi@0 136 // their 'next' and 'prev' fields.
aoqi@0 137 // This allows fast bulk freeing of all the fine grain remembered
aoqi@0 138 // set entries, and fast finding of all of them without iterating
aoqi@0 139 // over the _fine_grain_regions table.
aoqi@0 140 PerRegionTable * _first_all_fine_prts;
aoqi@0 141 PerRegionTable * _last_all_fine_prts;
aoqi@0 142
aoqi@0 143 // Used to sample a subset of the fine grain PRTs to determine which
aoqi@0 144 // PRT to evict and coarsen.
aoqi@0 145 size_t _fine_eviction_start;
aoqi@0 146 static size_t _fine_eviction_stride;
aoqi@0 147 static size_t _fine_eviction_sample_size;
aoqi@0 148
aoqi@0 149 SparsePRT _sparse_table;
aoqi@0 150
aoqi@0 151 // These are static after init.
aoqi@0 152 static size_t _max_fine_entries;
aoqi@0 153 static size_t _mod_max_fine_entries_mask;
aoqi@0 154
aoqi@0 155 // Requires "prt" to be the first element of the bucket list appropriate
aoqi@0 156 // for "hr". If this list contains an entry for "hr", return it,
aoqi@0 157 // otherwise return "NULL".
aoqi@0 158 PerRegionTable* find_region_table(size_t ind, HeapRegion* hr) const;
aoqi@0 159
aoqi@0 160 // Find, delete, and return a candidate PerRegionTable, if any exists,
aoqi@0 161 // adding the deleted region to the coarse bitmap. Requires the caller
aoqi@0 162 // to hold _m, and the fine-grain table to be full.
aoqi@0 163 PerRegionTable* delete_region_table();
aoqi@0 164
aoqi@0 165 // If a PRT for "hr" is in the bucket list indicated by "ind" (which must
aoqi@0 166 // be the correct index for "hr"), delete it and return true; else return
aoqi@0 167 // false.
aoqi@0 168 bool del_single_region_table(size_t ind, HeapRegion* hr);
aoqi@0 169
aoqi@0 170 // link/add the given fine grain remembered set into the "all" list
aoqi@0 171 void link_to_all(PerRegionTable * prt);
aoqi@0 172 // unlink/remove the given fine grain remembered set into the "all" list
aoqi@0 173 void unlink_from_all(PerRegionTable * prt);
aoqi@0 174
aoqi@0 175 public:
aoqi@0 176 OtherRegionsTable(HeapRegion* hr, Mutex* m);
aoqi@0 177
aoqi@0 178 HeapRegion* hr() const { return _hr; }
aoqi@0 179
aoqi@0 180 // For now. Could "expand" some tables in the future, so that this made
aoqi@0 181 // sense.
aoqi@0 182 void add_reference(OopOrNarrowOopStar from, int tid);
aoqi@0 183
tschatzl@7828 184 // Returns whether this remembered set (and all sub-sets) have an occupancy
tschatzl@7828 185 // that is less or equal than the given occupancy.
tschatzl@7828 186 bool occupancy_less_or_equal_than(size_t limit) const;
tschatzl@7828 187
aoqi@0 188 // Removes any entries shown by the given bitmaps to contain only dead
aoqi@0 189 // objects.
aoqi@0 190 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm);
aoqi@0 191
tschatzl@7010 192 // Returns whether this remembered set (and all sub-sets) contain no entries.
tschatzl@7010 193 bool is_empty() const;
tschatzl@7010 194
aoqi@0 195 size_t occupied() const;
aoqi@0 196 size_t occ_fine() const;
aoqi@0 197 size_t occ_coarse() const;
aoqi@0 198 size_t occ_sparse() const;
aoqi@0 199
aoqi@0 200 static jint n_coarsenings() { return _n_coarsenings; }
aoqi@0 201
aoqi@0 202 // Returns size in bytes.
aoqi@0 203 // Not const because it takes a lock.
aoqi@0 204 size_t mem_size() const;
aoqi@0 205 static size_t static_mem_size();
aoqi@0 206 static size_t fl_mem_size();
aoqi@0 207
aoqi@0 208 bool contains_reference(OopOrNarrowOopStar from) const;
aoqi@0 209 bool contains_reference_locked(OopOrNarrowOopStar from) const;
aoqi@0 210
aoqi@0 211 void clear();
aoqi@0 212
aoqi@0 213 // Specifically clear the from_card_cache.
aoqi@0 214 void clear_fcc();
aoqi@0 215
aoqi@0 216 void do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task);
aoqi@0 217
aoqi@0 218 // Declare the heap size (in # of regions) to the OtherRegionsTable.
aoqi@0 219 // (Uses it to initialize from_card_cache).
tschatzl@7051 220 static void initialize(uint max_regions);
aoqi@0 221
tschatzl@7051 222 // Declares that regions between start_idx <= i < start_idx + num_regions are
tschatzl@7051 223 // not in use. Make sure that any entries for these regions are invalid.
tschatzl@7051 224 static void invalidate(uint start_idx, size_t num_regions);
aoqi@0 225
aoqi@0 226 static void print_from_card_cache();
aoqi@0 227 };
aoqi@0 228
aoqi@0 229 class HeapRegionRemSet : public CHeapObj<mtGC> {
aoqi@0 230 friend class VMStructs;
aoqi@0 231 friend class HeapRegionRemSetIterator;
aoqi@0 232
aoqi@0 233 public:
aoqi@0 234 enum Event {
csahu@8316 235 Event_EvacStart, Event_EvacEnd, Event_RSUpdateEnd, Event_illegal
aoqi@0 236 };
aoqi@0 237
aoqi@0 238 private:
aoqi@0 239 G1BlockOffsetSharedArray* _bosa;
aoqi@0 240 G1BlockOffsetSharedArray* bosa() const { return _bosa; }
aoqi@0 241
aoqi@0 242 // A set of code blobs (nmethods) whose code contains pointers into
aoqi@0 243 // the region that owns this RSet.
aoqi@0 244 G1CodeRootSet _code_roots;
aoqi@0 245
aoqi@0 246 Mutex _m;
aoqi@0 247
aoqi@0 248 OtherRegionsTable _other_regions;
aoqi@0 249
aoqi@0 250 enum ParIterState { Unclaimed, Claimed, Complete };
aoqi@0 251 volatile ParIterState _iter_state;
aoqi@0 252 volatile jlong _iter_claimed;
aoqi@0 253
aoqi@0 254 // Unused unless G1RecordHRRSOops is true.
aoqi@0 255
aoqi@0 256 static const int MaxRecorded = 1000000;
aoqi@0 257 static OopOrNarrowOopStar* _recorded_oops;
aoqi@0 258 static HeapWord** _recorded_cards;
aoqi@0 259 static HeapRegion** _recorded_regions;
aoqi@0 260 static int _n_recorded;
aoqi@0 261
aoqi@0 262 static const int MaxRecordedEvents = 1000;
aoqi@0 263 static Event* _recorded_events;
aoqi@0 264 static int* _recorded_event_index;
aoqi@0 265 static int _n_recorded_events;
aoqi@0 266
aoqi@0 267 static void print_event(outputStream* str, Event evnt);
aoqi@0 268
aoqi@0 269 public:
aoqi@0 270 HeapRegionRemSet(G1BlockOffsetSharedArray* bosa, HeapRegion* hr);
aoqi@0 271
aoqi@0 272 static uint num_par_rem_sets();
aoqi@0 273 static void setup_remset_size();
aoqi@0 274
aoqi@0 275 HeapRegion* hr() const {
aoqi@0 276 return _other_regions.hr();
aoqi@0 277 }
aoqi@0 278
tschatzl@7010 279 bool is_empty() const {
tschatzl@7010 280 return (strong_code_roots_list_length() == 0) && _other_regions.is_empty();
tschatzl@7010 281 }
tschatzl@7010 282
tschatzl@7828 283 bool occupancy_less_or_equal_than(size_t occ) const {
tschatzl@7828 284 return (strong_code_roots_list_length() == 0) && _other_regions.occupancy_less_or_equal_than(occ);
tschatzl@7828 285 }
tschatzl@7828 286
aoqi@0 287 size_t occupied() {
aoqi@0 288 MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag);
aoqi@0 289 return occupied_locked();
aoqi@0 290 }
aoqi@0 291 size_t occupied_locked() {
aoqi@0 292 return _other_regions.occupied();
aoqi@0 293 }
aoqi@0 294 size_t occ_fine() const {
aoqi@0 295 return _other_regions.occ_fine();
aoqi@0 296 }
aoqi@0 297 size_t occ_coarse() const {
aoqi@0 298 return _other_regions.occ_coarse();
aoqi@0 299 }
aoqi@0 300 size_t occ_sparse() const {
aoqi@0 301 return _other_regions.occ_sparse();
aoqi@0 302 }
aoqi@0 303
aoqi@0 304 static jint n_coarsenings() { return OtherRegionsTable::n_coarsenings(); }
aoqi@0 305
aoqi@0 306 // Used in the sequential case.
aoqi@0 307 void add_reference(OopOrNarrowOopStar from) {
aoqi@0 308 _other_regions.add_reference(from, 0);
aoqi@0 309 }
aoqi@0 310
aoqi@0 311 // Used in the parallel case.
aoqi@0 312 void add_reference(OopOrNarrowOopStar from, int tid) {
aoqi@0 313 _other_regions.add_reference(from, tid);
aoqi@0 314 }
aoqi@0 315
aoqi@0 316 // Removes any entries shown by the given bitmaps to contain only dead
aoqi@0 317 // objects.
aoqi@0 318 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm);
aoqi@0 319
aoqi@0 320 // The region is being reclaimed; clear its remset, and any mention of
aoqi@0 321 // entries for this region in other remsets.
aoqi@0 322 void clear();
aoqi@0 323 void clear_locked();
aoqi@0 324
aoqi@0 325 // Attempt to claim the region. Returns true iff this call caused an
aoqi@0 326 // atomic transition from Unclaimed to Claimed.
aoqi@0 327 bool claim_iter();
aoqi@0 328 // Sets the iteration state to "complete".
aoqi@0 329 void set_iter_complete();
aoqi@0 330 // Returns "true" iff the region's iteration is complete.
aoqi@0 331 bool iter_is_complete();
aoqi@0 332
aoqi@0 333 // Support for claiming blocks of cards during iteration
aoqi@0 334 size_t iter_claimed() const { return (size_t)_iter_claimed; }
aoqi@0 335 // Claim the next block of cards
aoqi@0 336 size_t iter_claimed_next(size_t step) {
aoqi@0 337 size_t current, next;
aoqi@0 338 do {
aoqi@0 339 current = iter_claimed();
aoqi@0 340 next = current + step;
aoqi@0 341 } while (Atomic::cmpxchg((jlong)next, &_iter_claimed, (jlong)current) != (jlong)current);
aoqi@0 342 return current;
aoqi@0 343 }
aoqi@0 344 void reset_for_par_iteration();
aoqi@0 345
aoqi@0 346 bool verify_ready_for_par_iteration() {
aoqi@0 347 return (_iter_state == Unclaimed) && (_iter_claimed == 0);
aoqi@0 348 }
aoqi@0 349
aoqi@0 350 // The actual # of bytes this hr_remset takes up.
aoqi@0 351 // Note also includes the strong code root set.
aoqi@0 352 size_t mem_size() {
aoqi@0 353 MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag);
aoqi@0 354 return _other_regions.mem_size()
aoqi@0 355 // This correction is necessary because the above includes the second
aoqi@0 356 // part.
tschatzl@6932 357 + (sizeof(HeapRegionRemSet) - sizeof(OtherRegionsTable))
aoqi@0 358 + strong_code_roots_mem_size();
aoqi@0 359 }
aoqi@0 360
aoqi@0 361 // Returns the memory occupancy of all static data structures associated
aoqi@0 362 // with remembered sets.
aoqi@0 363 static size_t static_mem_size() {
aoqi@0 364 return OtherRegionsTable::static_mem_size() + G1CodeRootSet::static_mem_size();
aoqi@0 365 }
aoqi@0 366
aoqi@0 367 // Returns the memory occupancy of all free_list data structures associated
aoqi@0 368 // with remembered sets.
aoqi@0 369 static size_t fl_mem_size() {
mgerdin@7208 370 return OtherRegionsTable::fl_mem_size();
aoqi@0 371 }
aoqi@0 372
aoqi@0 373 bool contains_reference(OopOrNarrowOopStar from) const {
aoqi@0 374 return _other_regions.contains_reference(from);
aoqi@0 375 }
aoqi@0 376
aoqi@0 377 // Routines for managing the list of code roots that point into
aoqi@0 378 // the heap region that owns this RSet.
aoqi@0 379 void add_strong_code_root(nmethod* nm);
mgerdin@7208 380 void add_strong_code_root_locked(nmethod* nm);
aoqi@0 381 void remove_strong_code_root(nmethod* nm);
aoqi@0 382
aoqi@0 383 // Applies blk->do_code_blob() to each of the entries in
aoqi@0 384 // the strong code roots list
aoqi@0 385 void strong_code_roots_do(CodeBlobClosure* blk) const;
aoqi@0 386
mgerdin@7208 387 void clean_strong_code_roots(HeapRegion* hr);
mgerdin@7208 388
aoqi@0 389 // Returns the number of elements in the strong code roots list
tschatzl@7010 390 size_t strong_code_roots_list_length() const {
aoqi@0 391 return _code_roots.length();
aoqi@0 392 }
aoqi@0 393
aoqi@0 394 // Returns true if the strong code roots contains the given
aoqi@0 395 // nmethod.
aoqi@0 396 bool strong_code_roots_list_contains(nmethod* nm) {
aoqi@0 397 return _code_roots.contains(nm);
aoqi@0 398 }
aoqi@0 399
aoqi@0 400 // Returns the amount of memory, in bytes, currently
aoqi@0 401 // consumed by the strong code roots.
aoqi@0 402 size_t strong_code_roots_mem_size();
aoqi@0 403
aoqi@0 404 void print() PRODUCT_RETURN;
aoqi@0 405
aoqi@0 406 // Called during a stop-world phase to perform any deferred cleanups.
aoqi@0 407 static void cleanup();
aoqi@0 408
aoqi@0 409 // Declare the heap size (in # of regions) to the HeapRegionRemSet(s).
aoqi@0 410 // (Uses it to initialize from_card_cache).
aoqi@0 411 static void init_heap(uint max_regions) {
tschatzl@7051 412 OtherRegionsTable::initialize(max_regions);
aoqi@0 413 }
aoqi@0 414
tschatzl@7051 415 static void invalidate(uint start_idx, uint num_regions) {
tschatzl@7051 416 OtherRegionsTable::invalidate(start_idx, num_regions);
aoqi@0 417 }
aoqi@0 418
aoqi@0 419 #ifndef PRODUCT
aoqi@0 420 static void print_from_card_cache() {
aoqi@0 421 OtherRegionsTable::print_from_card_cache();
aoqi@0 422 }
aoqi@0 423 #endif
aoqi@0 424
aoqi@0 425 static void record(HeapRegion* hr, OopOrNarrowOopStar f);
aoqi@0 426 static void print_recorded();
aoqi@0 427 static void record_event(Event evnt);
aoqi@0 428
aoqi@0 429 // These are wrappers for the similarly-named methods on
aoqi@0 430 // SparsePRT. Look at sparsePRT.hpp for more details.
aoqi@0 431 static void reset_for_cleanup_tasks();
aoqi@0 432 void do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task);
aoqi@0 433 static void finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task);
aoqi@0 434
aoqi@0 435 // Run unit tests.
aoqi@0 436 #ifndef PRODUCT
aoqi@0 437 static void test_prt();
aoqi@0 438 static void test();
aoqi@0 439 #endif
aoqi@0 440 };
aoqi@0 441
aoqi@0 442 class HeapRegionRemSetIterator : public StackObj {
tschatzl@6927 443 private:
tschatzl@6927 444 // The region RSet over which we are iterating.
aoqi@0 445 HeapRegionRemSet* _hrrs;
aoqi@0 446
aoqi@0 447 // Local caching of HRRS fields.
aoqi@0 448 const BitMap* _coarse_map;
aoqi@0 449
aoqi@0 450 G1BlockOffsetSharedArray* _bosa;
aoqi@0 451 G1CollectedHeap* _g1h;
aoqi@0 452
tschatzl@6927 453 // The number of cards yielded since initialization.
aoqi@0 454 size_t _n_yielded_fine;
aoqi@0 455 size_t _n_yielded_coarse;
aoqi@0 456 size_t _n_yielded_sparse;
aoqi@0 457
tschatzl@6927 458 // Indicates what granularity of table that we are currently iterating over.
aoqi@0 459 // We start iterating over the sparse table, progress to the fine grain
aoqi@0 460 // table, and then finish with the coarse table.
aoqi@0 461 enum IterState {
aoqi@0 462 Sparse,
aoqi@0 463 Fine,
aoqi@0 464 Coarse
aoqi@0 465 };
aoqi@0 466 IterState _is;
aoqi@0 467
tschatzl@6927 468 // For both Coarse and Fine remembered set iteration this contains the
tschatzl@6927 469 // first card number of the heap region we currently iterate over.
aoqi@0 470 size_t _cur_region_card_offset;
aoqi@0 471
tschatzl@6927 472 // Current region index for the Coarse remembered set iteration.
aoqi@0 473 int _coarse_cur_region_index;
aoqi@0 474 size_t _coarse_cur_region_cur_card;
aoqi@0 475
aoqi@0 476 bool coarse_has_next(size_t& card_index);
aoqi@0 477
tschatzl@6927 478 // The PRT we are currently iterating over.
tschatzl@6927 479 PerRegionTable* _fine_cur_prt;
tschatzl@6927 480 // Card offset within the current PRT.
tschatzl@6927 481 size_t _cur_card_in_prt;
aoqi@0 482
tschatzl@6927 483 // Update internal variables when switching to the given PRT.
tschatzl@6927 484 void switch_to_prt(PerRegionTable* prt);
aoqi@0 485 bool fine_has_next();
aoqi@0 486 bool fine_has_next(size_t& card_index);
aoqi@0 487
tschatzl@6927 488 // The Sparse remembered set iterator.
tschatzl@6927 489 SparsePRTIter _sparse_iter;
tschatzl@6927 490
tschatzl@6927 491 public:
aoqi@0 492 HeapRegionRemSetIterator(HeapRegionRemSet* hrrs);
aoqi@0 493
aoqi@0 494 // If there remains one or more cards to be yielded, returns true and
aoqi@0 495 // sets "card_index" to one of those cards (which is then considered
aoqi@0 496 // yielded.) Otherwise, returns false (and leaves "card_index"
aoqi@0 497 // undefined.)
aoqi@0 498 bool has_next(size_t& card_index);
aoqi@0 499
aoqi@0 500 size_t n_yielded_fine() { return _n_yielded_fine; }
aoqi@0 501 size_t n_yielded_coarse() { return _n_yielded_coarse; }
aoqi@0 502 size_t n_yielded_sparse() { return _n_yielded_sparse; }
aoqi@0 503 size_t n_yielded() {
aoqi@0 504 return n_yielded_fine() + n_yielded_coarse() + n_yielded_sparse();
aoqi@0 505 }
aoqi@0 506 };
aoqi@0 507
aoqi@0 508 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONREMSET_HPP

mercurial