On Mon, 14 Apr 2025 15:46:54 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>  It then means that the other field will never move out of its initial value 
> and thus will never be considered "stable".

For all non-zero hashcodes, it matters that `hash` would be constant-foldable, 
which means `if (h == 0 && !hashIsZero)` would be optimized to `if (false && 
!hashIsZero)` -> `if (false)` -> poof. So it would not matter if `hashIsZero` 
is actually foldable. 

Same goes the other way around for the hashcode that _is_ zero: now 
`!hashIsZero` would be folded to `false` -- with a wrinkle that `int h = hash;` 
read would likely still be there... You can massage the code a bit to return 
`0` if `hashIsZero`, but I don't think it is worth it.

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

PR Comment: https://git.openjdk.org/jdk/pull/24625#issuecomment-2802411963

Reply via email to