From 5271f4def68a7ad5003c597c60db29fbe9e2742b Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Mon, 26 Jun 2023 12:14:00 +0000 Subject: [PATCH] 8310354: G1: Annotate G1MMUTracker::when_sec with const Reviewed-by: tschatzl, kbarrett --- src/hotspot/share/gc/g1/g1MMUTracker.cpp | 4 ++-- src/hotspot/share/gc/g1/g1MMUTracker.hpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1MMUTracker.cpp b/src/hotspot/share/gc/g1/g1MMUTracker.cpp index 7fb29eb39f1..24776a5334d 100644 --- a/src/hotspot/share/gc/g1/g1MMUTracker.cpp +++ b/src/hotspot/share/gc/g1/g1MMUTracker.cpp @@ -136,7 +136,7 @@ void G1MMUTracker::add_pause(double start, double end) { // // When there are not enough GC events, i.e. we have a surplus budget, a new GC // pause can start right away, so return 0. -double G1MMUTracker::when_sec(double current_timestamp, double pause_time) { +double G1MMUTracker::when_sec(double current_timestamp, double pause_time) const { assert(pause_time > 0.0, "precondition"); // If the pause is over the maximum, just assume that it's the maximum. @@ -148,7 +148,7 @@ double G1MMUTracker::when_sec(double current_timestamp, double pause_time) { // Iterate from newest to oldest. for (int i = 0; i < _no_entries; ++i) { int index = trim_index(_head_index - i); - G1MMUTrackerElem *elem = &_array[index]; + const G1MMUTrackerElem *elem = &_array[index]; // Outside the window. if (elem->end_time() <= limit) { break; diff --git a/src/hotspot/share/gc/g1/g1MMUTracker.hpp b/src/hotspot/share/gc/g1/g1MMUTracker.hpp index b737ea5a5da..23f906f4aeb 100644 --- a/src/hotspot/share/gc/g1/g1MMUTracker.hpp +++ b/src/hotspot/share/gc/g1/g1MMUTracker.hpp @@ -35,9 +35,9 @@ private: double _end_time; public: - inline double start_time() { return _start_time; } - inline double end_time() { return _end_time; } - inline double duration() { return _end_time - _start_time; } + inline double start_time() const { return _start_time; } + inline double end_time() const { return _end_time; } + inline double duration() const { return _end_time - _start_time; } G1MMUTrackerElem() { _start_time = 0.0; @@ -95,7 +95,7 @@ private: int _tail_index; int _no_entries; - inline int trim_index(int index) { + inline int trim_index(int index) const { return (index + QueueLength) % QueueLength; } @@ -110,13 +110,13 @@ public: // Minimum delay required from current_timestamp until a GC pause of duration // pause_time may be scheduled without violating the MMU constraint. - double when_sec(double current_timestamp, double pause_time); + double when_sec(double current_timestamp, double pause_time) const; double max_gc_time() const { return _max_gc_time; } - double when_max_gc_sec(double current_time) { + double when_max_gc_sec(double current_time) const { return when_sec(current_time, max_gc_time()); } };