On Fri, 18 Sep 2026 12:25:06 GMT, Johan Sjölen <[email protected]> wrote:

>> src/hotspot/share/oops/layoutKind.hpp line 98:
>> 
>>> 96:   NULLABLE_NON_ATOMIC_FLAT  = 5,      // flat, include a null marker, 
>>> non-atomic, only used for strict final non-static fields
>>> 97:   UNKNOWN                   = 6,      // used for uninitialized fields 
>>> of type LayoutKind
>>> 98:   COUNT                     = UNKNOWN
>> 
>> Adding COUNT here pollutes the LayoutKind type with something that is not a 
>> layout kind. Could this be a constant outside of the enum?
>
> I would call this fairly standard Hotspot code, we use this in `LogTag`, 
> `MemTag`, `AdapterBlog`, `CompileCommandEnum`. I think it's standard enough 
> to not be considered a pollutant, its reason for existing is clear.

There are many unclean parts of HotSpot that could make do with a cleanup.

This is classical type-smooshing that leads to code that is a tiny bit harder 
to reason about. Maybe this is easy enough to understand here, but it is 
unnecessary, IMHO. All code that now takes a LayoutKind could previously assume 
that the passed in value was one of the valid "layout kinds". That is lost with 
this change. Now we have to at least briefly consider that someone might be 
passing in COUNT. I think that is unfortunate, and it is something that can 
easily be fixed by using a separate integer constant.

Note, this is only needed for iterating over the values. That can be handled 
with the ENUMARATOR_RANGE / ENUMERATOR_VALUE_RANGE and EnumRange.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32276#discussion_r4046835480

Reply via email to