From 65670ba43ba0e7f67b3dbabae1fc6c3542a5edf8 Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Tue, 5 May 2026 08:19:53 +0000 Subject: [PATCH] 8383794: G1: Rename refinement sweep duration helper to reflect SwapGlobalCT start Reviewed-by: tschatzl, iwalulya --- src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp | 16 +++++++++------- src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp index 12b6bf2a7bd..d58d980b651 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp @@ -145,16 +145,18 @@ void G1ConcurrentRefineSweepState::enter_state(State state, Ticks timestamp) { _state = state; } -Tickspan G1ConcurrentRefineSweepState::get_duration(State start, State end) const { - assert(end >= start, "precondition"); - return _state_start[static_cast(end)] - _state_start[static_cast(start)]; -} - Tickspan G1ConcurrentRefineSweepState::time_since_start(Ticks completion_time) const { assert(_state >= State::SwapGlobalCT, "precondition"); return completion_time - _state_start[static_cast(State::SwapGlobalCT)]; } +Tickspan G1ConcurrentRefineSweepState::time_until_state(State state) const { + assert(_state >= State::SwapGlobalCT, "precondition"); + assert(state >= State::SwapGlobalCT, "precondition"); + assert(state <= _state, "precondition"); + return _state_start[static_cast(state)] - _state_start[static_cast(State::SwapGlobalCT)]; +} + void G1ConcurrentRefineSweepState::reset_stats() { stats()->reset(); } @@ -333,7 +335,7 @@ void G1ConcurrentRefineSweepState::handle_ongoing_refinement_at_safepoint() { const Ticks completion_time = Ticks::now(); const Tickspan total_duration = time_since_start(completion_time); - const Tickspan pre_sweep_duration = get_duration(State::SwapGlobalCT, MIN2(_state, State::SweepRT)); + const Tickspan pre_sweep_duration = time_until_state(MIN2(_state, State::SweepRT)); print_refinement_stats(total_duration, pre_sweep_duration, &_stats); @@ -370,7 +372,7 @@ void G1ConcurrentRefineSweepState::complete_refinement(jlong total_yield_during_ const Ticks completion_time = Ticks::now(); const Tickspan total_duration = time_since_start(completion_time); - const Tickspan pre_sweep_duration = get_duration(State::SwapGlobalCT, State::SweepRT); + const Tickspan pre_sweep_duration = time_until_state(State::SweepRT); print_refinement_stats(total_duration, pre_sweep_duration, &_stats); diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp b/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp index bbc7d3b6af1..50fb412f3af 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp @@ -146,8 +146,8 @@ class G1ConcurrentRefineSweepState { Ticks _state_start[static_cast(State::Last)]; void enter_state(State state, Ticks timestamp); - Tickspan get_duration(State start, State end) const; Tickspan time_since_start(Ticks completion_time) const; + Tickspan time_until_state(State state) const; G1ConcurrentRefineStats _stats;