RFR: 8377172: Change datatype of CodeEntryAlignment to uint

Leo Korinth lkorinth at openjdk.org
Tue Feb 10 09:27:19 UTC 2026


On Tue, 10 Feb 2026 08:20:58 GMT, Albert Mingkun Yang <ayang 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.
>
> src/hotspot/share/runtime/globals.hpp line 1514:
> 
>> 1512:           "Code entry alignment for generated code"                         \
>> 1513:           " (in bytes, power of two)")                                      \
>> 1514:           range(16, 1024)                                                   \
> 
> Since this range is derived from other related flag, I tend to think we shouldn't place a range here -- to me, constraints in `product*(` declaration indicates an intrinsic attribute of this particular flag, e.g. the "power of two" constraint.
> 
> YMMV.

I agree, I had that thought as well and was unsure when I added it. I will remove the range. It is just annoying that the range can not be derived to the user.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29637#discussion_r2786799172


More information about the hotspot-dev mailing list