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

Emanuel Peter epeter at openjdk.org
Wed Dec 10 13:12:34 UTC 2025


On Tue, 2 Dec 2025 23:25:29 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.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Typo

Drive-by comments

test/hotspot/jtreg/compiler/c2/irTests/constantFold/IdentityHashCodeFold.java line 37:

> 35:  * @library /test/lib /
> 36:  * @requires vm.compiler2.enabled
> 37:  * @run driver compiler.c2.irTests.constantFold.IdentityHashCodeFold

Suggestion:

 * @run driver ${test.main.class}

Is the C2 requirement really necessary?

test/hotspot/jtreg/compiler/c2/irTests/constantFold/IdentityHashCodeFold.java line 51:

> 49:     public int testSum() {
> 50:         return a.hashCode() + System.identityHashCode(b);
> 51:     }

This does not test correctness of the result. How confident are we that this patch is sufficiently tested?
How can we test that the compiled and interpreter hashcode are equivalent?

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

PR Review: https://git.openjdk.org/jdk/pull/28589#pullrequestreview-3562463539
PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2606597900
PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2606602984


More information about the hotspot-dev mailing list