RFR: 8377172: Change datatype of CodeEntryAlignment to uint [v2]

Manuel Hässig mhaessig at openjdk.org
Tue Feb 10 11:25:47 UTC 2026


On Tue, 10 Feb 2026 10:04:43 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:

>> The main idea of this change is to remove an implicitly narrowing conversion to int from intx (`int code_alignment()`).
>> 
>> CodeEntryAlignment is constrained to not be bigger than CodeCacheSegmentSize that is itself constrained to be in the range(1, 1024). The data type should really be a uint16_t as its allowed range is [16-1024], but we have no such support for VM flags. uint will do, and will simplify the code greatly (five less casts, six if we count the implicit narrowing cast).
>> 
>> Also add explicit range on the flag.
>> 
>> This change is inspired by my change 8376892: Allow conversion warnings in subsets of the code base.
>> 
>> Completed test tier 1-3.
>
> Leo Korinth has updated the pull request incrementally with one additional commit since the last revision:
> 
>   remove range

Thank you for working on this, @lkorinth. This mostly looks good, I only have a few questions below.

src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp line 169:

> 167:     JVMFlag::printError(verbose,
> 168:                         "CodeCacheSegmentSize  (%zu) must be "
> 169:                         "larger than or equal to CodeEntryAlignment (%d) "

Why `%d` and not `%u`?

src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp line 244:

> 242:   }
> 243: 
> 244:   if (checked_cast<uintx>(OptoLoopAlignment) > CodeEntryAlignment) {

Why not cast it all the way down to `uint` when you are already using a checked cast?

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

PR Review: https://git.openjdk.org/jdk/pull/29637#pullrequestreview-3778346514
PR Review Comment: https://git.openjdk.org/jdk/pull/29637#discussion_r2787367372
PR Review Comment: https://git.openjdk.org/jdk/pull/29637#discussion_r2787381366


More information about the hotspot-dev mailing list