RFR: 8372845: C2: Fold identity hash code if object is constant

Chen Liang liach at openjdk.org
Tue Dec 2 23:18:28 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 tried to come up with an example where the buggy code from Vladimir would inline to identityHashCode when the right call would be virtual - couldn't construct such a case unfortunately :(

I think we can deal with IGVN later, as this involves creating new macro node and other infrastructure support.

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

PR Comment: https://git.openjdk.org/jdk/pull/28589#issuecomment-3604321567


More information about the hotspot-compiler-dev mailing list