src/hotspot/share/gc/g1/g1HotCardCache.cpp
changeset 59249 29b0d0b61615
parent 58264 4e96939a5746
child 59252 623722a6aeb9
equal deleted inserted replaced
59248:e92153ed8bdc 59249:29b0d0b61615
    66     // The card is not hot so do not store it in the cache;
    66     // The card is not hot so do not store it in the cache;
    67     // return it for immediate refining.
    67     // return it for immediate refining.
    68     return card_ptr;
    68     return card_ptr;
    69   }
    69   }
    70   // Otherwise, the card is hot.
    70   // Otherwise, the card is hot.
    71   size_t index = Atomic::add(1u, &_hot_cache_idx) - 1;
    71   size_t index = Atomic::add(&_hot_cache_idx, 1u) - 1;
    72   size_t masked_index = index & (_hot_cache_size - 1);
    72   size_t masked_index = index & (_hot_cache_size - 1);
    73   CardValue* current_ptr = _hot_cache[masked_index];
    73   CardValue* current_ptr = _hot_cache[masked_index];
    74 
    74 
    75   // Try to store the new card pointer into the cache. Compare-and-swap to guard
    75   // Try to store the new card pointer into the cache. Compare-and-swap to guard
    76   // against the unlikely event of a race resulting in another card pointer to
    76   // against the unlikely event of a race resulting in another card pointer to
    89 
    89 
    90   assert(_hot_cache != NULL, "Logic");
    90   assert(_hot_cache != NULL, "Logic");
    91   assert(!use_cache(), "cache should be disabled");
    91   assert(!use_cache(), "cache should be disabled");
    92 
    92 
    93   while (_hot_cache_par_claimed_idx < _hot_cache_size) {
    93   while (_hot_cache_par_claimed_idx < _hot_cache_size) {
    94     size_t end_idx = Atomic::add(_hot_cache_par_chunk_size,
    94     size_t end_idx = Atomic::add(&_hot_cache_par_claimed_idx,
    95                                  &_hot_cache_par_claimed_idx);
    95                                  _hot_cache_par_chunk_size);
    96     size_t start_idx = end_idx - _hot_cache_par_chunk_size;
    96     size_t start_idx = end_idx - _hot_cache_par_chunk_size;
    97     // The current worker has successfully claimed the chunk [start_idx..end_idx)
    97     // The current worker has successfully claimed the chunk [start_idx..end_idx)
    98     end_idx = MIN2(end_idx, _hot_cache_size);
    98     end_idx = MIN2(end_idx, _hot_cache_size);
    99     for (size_t i = start_idx; i < end_idx; i++) {
    99     for (size_t i = start_idx; i < end_idx; i++) {
   100       CardValue* card_ptr = _hot_cache[i];
   100       CardValue* card_ptr = _hot_cache[i];