RFR: 8357053: ZGC: Improved utility for ZPageAge [v2]

Joel Sikström jsikstro at openjdk.org
Fri May 23 12:24:55 UTC 2025


On Fri, 23 May 2025 10:36:25 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Joel Sikström has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Copyright years
>>  - Simplify untype(ZPageAge age)
>
> src/hotspot/share/gc/z/zAllocator.inline.hpp line 38:
> 
>> 36: 
>> 37: inline ZAllocatorForRelocation* ZAllocator::relocation(ZPageAge page_age) {
>> 38:   return _relocation[untype(page_age) - 1];
> 
> I wonder if we should have our own defined ZPageAge operators for `+` and `-` (or maybe inc/dec) and we could add verification that we don't fall out of the range?
> Suggestion:
> 
>   return _relocation[untype(page_age - 1)];

I agree. That also allows us to do something similar to how the offset types are handled in zAddress.inline.hpp, to check if the size being added/substracted is within the underlying type.

> src/hotspot/share/gc/z/zPageAge.hpp line 55:
> 
>> 53:                        static_cast<uint>(ZPageAge::eden),
>> 54:                        ZPageAgeCount);
>> 55: 
> 
> Could this be using the other define to set this up?
> Suggestion:
> 
> ENUMERATOR_VALUE_RANGE(ZPageAge,
>                        ZPageAge::eden,
>                        ZPageAge::old);
> 
> Or does that not work?

Yes, using the other define (`ENUMERATOR_RANGE`) with the enum type instead of the underlying type makes more sense.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25251#discussion_r2104477274
PR Review Comment: https://git.openjdk.org/jdk/pull/25251#discussion_r2104477138


More information about the hotspot-gc-dev mailing list