--- old/src/hotspot/share/gc/g1/g1HotCardCache.cpp 2019-11-21 11:57:11.715006606 +0100 +++ new/src/hotspot/share/gc/g1/g1HotCardCache.cpp 2019-11-21 11:57:11.222998294 +0100 @@ -68,7 +68,7 @@ return card_ptr; } // Otherwise, the card is hot. - size_t index = Atomic::add(1u, &_hot_cache_idx) - 1; + size_t index = Atomic::add(&_hot_cache_idx, 1u) - 1; size_t masked_index = index & (_hot_cache_size - 1); CardValue* current_ptr = _hot_cache[masked_index]; @@ -78,9 +78,9 @@ // card_ptr in favor of the other option, which would be starting over. This // should be OK since card_ptr will likely be the older card already when/if // this ever happens. - CardValue* previous_ptr = Atomic::cmpxchg(card_ptr, - &_hot_cache[masked_index], - current_ptr); + CardValue* previous_ptr = Atomic::cmpxchg(&_hot_cache[masked_index], + current_ptr, + card_ptr); return (previous_ptr == current_ptr) ? previous_ptr : card_ptr; } @@ -91,8 +91,8 @@ assert(!use_cache(), "cache should be disabled"); while (_hot_cache_par_claimed_idx < _hot_cache_size) { - size_t end_idx = Atomic::add(_hot_cache_par_chunk_size, - &_hot_cache_par_claimed_idx); + size_t end_idx = Atomic::add(&_hot_cache_par_claimed_idx, + _hot_cache_par_chunk_size); size_t start_idx = end_idx - _hot_cache_par_chunk_size; // The current worker has successfully claimed the chunk [start_idx..end_idx) end_idx = MIN2(end_idx, _hot_cache_size);