8375978: G1: Convert G1Policy to use Atomic<T>

Reviewed-by: kbarrett
This commit is contained in:
Thomas Schatzl 2026-01-22 08:35:32 +00:00
parent 63be87d7f3
commit 03038d802c
2 changed files with 7 additions and 10 deletions

View File

@ -203,8 +203,8 @@ void G1Policy::update_young_length_bounds(size_t pending_cards, size_t card_rs_l
// allocation.
// That is "fine" - at most this will schedule a GC (hopefully only a little) too
// early or too late.
AtomicAccess::store(&_young_list_desired_length, new_young_list_desired_length);
AtomicAccess::store(&_young_list_target_length, new_young_list_target_length);
_young_list_desired_length.store_relaxed(new_young_list_desired_length);
_young_list_target_length.store_relaxed(new_young_list_target_length);
}
// Calculates desired young gen length. It is calculated from:

View File

@ -35,7 +35,7 @@
#include "gc/g1/g1RemSetTrackingPolicy.hpp"
#include "gc/g1/g1YoungGenSizer.hpp"
#include "gc/shared/gcCause.hpp"
#include "runtime/atomicAccess.hpp"
#include "runtime/atomic.hpp"
#include "utilities/pair.hpp"
#include "utilities/ticks.hpp"
@ -81,12 +81,9 @@ class G1Policy: public CHeapObj<mtGC> {
// Desired young gen length without taking actually available free regions into
// account.
volatile uint _young_list_desired_length;
Atomic<uint> _young_list_desired_length;
// Actual target length given available free memory.
volatile uint _young_list_target_length;
// The max number of regions we can extend the eden by while the GC
// locker is active. This should be >= _young_list_target_length;
volatile uint _young_list_max_length;
Atomic<uint> _young_list_target_length;
// The survivor rate groups below must be initialized after the predictor because they
// indirectly use it through the "this" object passed to their constructor.
@ -362,8 +359,8 @@ public:
// This must be called at the very beginning of an evacuation pause.
void decide_on_concurrent_start_pause();
uint young_list_desired_length() const { return AtomicAccess::load(&_young_list_desired_length); }
uint young_list_target_length() const { return AtomicAccess::load(&_young_list_target_length); }
uint young_list_desired_length() const { return _young_list_desired_length.load_relaxed(); }
uint young_list_target_length() const { return _young_list_target_length.load_relaxed(); }
bool should_allocate_mutator_region() const;
bool should_expand_on_mutator_allocation() const;