11/*
2- * Copyright (c) 2020, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2020, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2929#include " gc/z/zArray.inline.hpp"
3030#include " gc/z/zGlobals.hpp"
3131#include " gc/z/zPage.inline.hpp"
32+ #include " gc/z/zPageAge.inline.hpp"
3233#include " utilities/powerOfTwo.hpp"
3334
3435inline size_t ZRelocationSetSelectorGroupStats::npages_candidates () const {
@@ -60,15 +61,15 @@ inline bool ZRelocationSetSelectorStats::has_relocatable_pages() const {
6061}
6162
6263inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::small (ZPageAge age) const {
63- return _small[static_cast <uint> (age)];
64+ return _small[untype (age)];
6465}
6566
6667inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::medium (ZPageAge age) const {
67- return _medium[static_cast <uint> (age)];
68+ return _medium[untype (age)];
6869}
6970
7071inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::large (ZPageAge age) const {
71- return _large[static_cast <uint> (age)];
72+ return _large[untype (age)];
7273}
7374
7475inline bool ZRelocationSetSelectorGroup::pre_filter_page (const ZPage* page, size_t live_bytes) const {
@@ -113,7 +114,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
113114 }
114115
115116 const size_t size = page->size ();
116- const uint age = static_cast <uint> (page->age ());
117+ const uint age = untype (page->age ());
117118 _stats[age]._npages_candidates ++;
118119 _stats[age]._total += size;
119120 _stats[age]._live += live;
@@ -122,7 +123,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
122123inline void ZRelocationSetSelectorGroup::register_empty_page (ZPage* page) {
123124 const size_t size = page->size ();
124125
125- const uint age = static_cast <uint> (page->age ());
126+ const uint age = untype (page->age ());
126127 _stats[age]._npages_candidates ++;
127128 _stats[age]._total += size;
128129 _stats[age]._empty += size;
@@ -141,7 +142,7 @@ inline size_t ZRelocationSetSelectorGroup::forwarding_entries() const {
141142}
142143
143144inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorGroup::stats (ZPageAge age) const {
144- return _stats[static_cast <uint> (age)];
145+ return _stats[untype (age)];
145146}
146147
147148inline void ZRelocationSetSelector::register_live_page (ZPage* page) {
@@ -188,26 +189,23 @@ inline void ZRelocationSetSelector::clear_empty_pages() {
188189
189190inline size_t ZRelocationSetSelector::total () const {
190191 size_t sum = 0 ;
191- for (uint i = 0 ; i <= ZPageAgeMax; ++i) {
192- const ZPageAge age = static_cast <ZPageAge>(i);
192+ for (ZPageAge age : ZPageAgeRange ()) {
193193 sum += _small.stats (age).total () + _medium.stats (age).total () + _large.stats (age).total ();
194194 }
195195 return sum;
196196}
197197
198198inline size_t ZRelocationSetSelector::empty () const {
199199 size_t sum = 0 ;
200- for (uint i = 0 ; i <= ZPageAgeMax; ++i) {
201- const ZPageAge age = static_cast <ZPageAge>(i);
200+ for (ZPageAge age : ZPageAgeRange ()) {
202201 sum += _small.stats (age).empty () + _medium.stats (age).empty () + _large.stats (age).empty ();
203202 }
204203 return sum;
205204}
206205
207206inline size_t ZRelocationSetSelector::relocate () const {
208207 size_t sum = 0 ;
209- for (uint i = 0 ; i <= ZPageAgeMax; ++i) {
210- const ZPageAge age = static_cast <ZPageAge>(i);
208+ for (ZPageAge age : ZPageAgeRange ()) {
211209 sum += _small.stats (age).relocate () + _medium.stats (age).relocate () + _large.stats (age).relocate ();
212210 }
213211 return sum;
0 commit comments