On Mon, 24 Mar 2025 20:49:25 GMT, Frederic Parain <[email protected]> wrote:

> Strict final instance fields are not subject to concurrent writes during a 
> read access, so they can be flattened even if they are nullable and bigger 
> than 64 bits. The NULLABLE_NON_ATOMIC_FLAT layout is added for this 
> particular case.
> This new layout can also be used in the special case of nullable empty value 
> classes, because their payload contains a single entry, the null-marker, 
> which is naturally atomic.

This would forbid the class which contains the `NULLABLE_NON_ATOMIC_FLAT` from 
being flattened into a class which contains it. I think we should only do so if 
the holder of the flattened strict final field should not be flattened if it is 
not itself a strict final field:

- The holder is an identity class.
- The holder is a large value class without `@LooselyConsistentValue`.

This is equally valid to null-restricted field of 
non-`@LooselyConsistentValue`, too.

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

PR Comment: https://git.openjdk.org/valhalla/pull/1407#issuecomment-2876555236

Reply via email to