On Wed, 2 Sep 2026 20:23:39 GMT, Frederic Parain <[email protected]> wrote:

>> Often, we are not concerned with the exact size, but simply wants the 
>> largest size available among a few layouts. Then, we can do something like 
>> what we do here: 
>> https://github.com/openjdk/jdk/pull/32276/changes#diff-bdfdbe1685717bf0c72c691043ced9bbe148364cbe7bf055857c72eb07f4ad62L1306
>> 
>> The reason that I went for having a `default_value` is that I think it's 
>> more dangerous to depend on the exact choice of sentinel value.
>> 
>> We might want to introduce a helper `largest_layout_of(LK::A, ..., LK::N)`, 
>> but I'd really like to hold off on that for a future RFE.
>
> Flat layout sizes have to be exact, polymorphism is not supported by 
> flattening.
> The notion of "largest size available among a few layouts" is a red flat. 
> Either the exact kind of the layout is known, and there's only one size 
> associated with it, or the layout kind is not known and no size should be 
> returned.
> Returning a size bigger than the exact size for a flat value is taking the 
> risk to overwrite another field or another array element next to the flat 
> value.

Did Github's buggy UI not show you the diff I pointed to? Look at 
`fieldLayoutBuilder.cpp:1340`, we're performing a pattern of picking the 
largest of three layouts which are available. Same at line 1306 of the same 
file. Now, either we keep the old code, which I think would be a mistake, or we 
use `MAX` to show that we're picking the largest value. For picking the largest 
value, my earlier point about depending on the sentinel value being `-1` 
applies.

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

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

Reply via email to