8376969: Shenandoah: GC state getters should be inlineable

Reviewed-by: wkemper, xpeng, kdnilsen
This commit is contained in:
Aleksey Shipilev 2026-02-03 08:44:23 +00:00
parent 8e2bd92bac
commit 692444f071
3 changed files with 13 additions and 14 deletions

View File

@ -2719,18 +2719,6 @@ bool ShenandoahRegionIterator::has_next() const {
return _index < _heap->num_regions();
}
char ShenandoahHeap::gc_state() const {
return _gc_state.raw_value();
}
bool ShenandoahHeap::is_gc_state(GCState state) const {
// If the global gc state has been changed, but hasn't yet been propagated to all threads, then
// the global gc state is the correct value. Once the gc state has been synchronized with all threads,
// _gc_state_changed will be toggled to false and we need to use the thread local state.
return _gc_state_changed ? _gc_state.is_set(state) : ShenandoahThreadLocalData::is_gc_state(state);
}
ShenandoahLiveData* ShenandoahHeap::get_liveness_cache(uint worker_id) {
#ifdef ASSERT
assert(_liveness_cache != nullptr, "sanity");

View File

@ -353,7 +353,7 @@ private:
public:
// This returns the raw value of the singular, global gc state.
char gc_state() const;
inline char gc_state() const;
// Compares the given state against either the global gc state, or the thread local state.
// The global gc state may change on a safepoint and is the correct value to use until
@ -361,7 +361,7 @@ public:
// compare against the thread local state). The thread local gc state may also be changed
// by a handshake operation, in which case, this function continues using the updated thread
// local value.
bool is_gc_state(GCState state) const;
inline bool is_gc_state(GCState state) const;
// This copies the global gc state into a thread local variable for all threads.
// The thread local gc state is primarily intended to support quick access at barriers.

View File

@ -452,6 +452,17 @@ inline bool ShenandoahHeap::in_collection_set_loc(void* p) const {
return collection_set()->is_in_loc(p);
}
inline char ShenandoahHeap::gc_state() const {
return _gc_state.raw_value();
}
inline bool ShenandoahHeap::is_gc_state(GCState state) const {
// If the global gc state has been changed, but hasn't yet been propagated to all threads, then
// the global gc state is the correct value. Once the gc state has been synchronized with all threads,
// _gc_state_changed will be toggled to false and we need to use the thread local state.
return _gc_state_changed ? _gc_state.is_set(state) : ShenandoahThreadLocalData::is_gc_state(state);
}
inline bool ShenandoahHeap::is_idle() const {
return _gc_state_changed ? _gc_state.is_clear() : ShenandoahThreadLocalData::gc_state(Thread::current()) == 0;
}