< prev index next >

src/hotspot/share/gc/g1/g1HotCardCache.cpp

Print this page
rev 56673 : imported patch 8227739-merge-scan-rs-update-rs-cost

*** 30,40 **** #include "runtime/atomic.hpp" G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h): _g1h(g1h), _use_cache(false), _card_counts(g1h), _hot_cache(NULL), _hot_cache_size(0), _hot_cache_par_chunk_size(0), ! _hot_cache_idx(0), _hot_cache_par_claimed_idx(0) {} void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) { if (default_use_cache()) { _use_cache = true; --- 30,40 ---- #include "runtime/atomic.hpp" G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h): _g1h(g1h), _use_cache(false), _card_counts(g1h), _hot_cache(NULL), _hot_cache_size(0), _hot_cache_par_chunk_size(0), ! _hot_cache_idx(0), _hot_cache_par_claimed_idx(0), _cache_wrapped_around(false) {} void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) { if (default_use_cache()) { _use_cache = true;
*** 46,55 **** --- 46,57 ---- // For refining the cards in the hot cache in parallel _hot_cache_par_chunk_size = ClaimChunkSize; _hot_cache_par_claimed_idx = 0; + _cache_wrapped_around = false; + _card_counts.initialize(card_counts_storage); } } G1HotCardCache::~G1HotCardCache() {
*** 67,76 **** --- 69,83 ---- // return it for immediate refining. return card_ptr; } // Otherwise, the card is hot. size_t index = Atomic::add(1u, &_hot_cache_idx) - 1; + // This does not need an atomic update. Racing threads may at most write the + // same value. + if (index == _hot_cache_size) { + _cache_wrapped_around = true; + } size_t masked_index = index & (_hot_cache_size - 1); CardValue* current_ptr = _hot_cache[masked_index]; // Try to store the new card pointer into the cache. Compare-and-swap to guard // against the unlikely event of a race resulting in another card pointer to
< prev index next >