RFR: 8372845: Fold identity hash code if object is constant
Chen Liang
liach at openjdk.org
Tue Dec 2 02:52:50 UTC 2025
On Mon, 1 Dec 2025 23:01:08 GMT, Chen Liang <liach at openjdk.org> wrote:
> Folding identity hash as constant if the incoming argument is constant would be useful for quick map lookups, such as for the [Classifier proposal](https://openjdk.org/jeps/8357674). Currently, identity hash is not constant because it loads the object header/mark word. We can add an explicit bypass to load an existing hash eagerly instead.
I have one question: would it be safer for us to move the constant detection after generate_virtual_guard in the `is_virtual` if block? I think it may be possible for users to create a `Object::hashCode` site with a constant receiver that is of a specialized class that overrides `hashCode`.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28589#issuecomment-3599934103
More information about the hotspot-compiler-dev
mailing list