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

Chen Liang liach at openjdk.org
Wed Dec 10 15:39:53 UTC 2025


On Wed, 10 Dec 2025 13:07:20 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Typo
>
> 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?

The C2 requirement is effective if a build configuration disables the compiler2 feature. I don't know if we run tests in such a build. I copied this from `compiler/c2/irTests/TestEnumFinalFold.java` in particular.

> 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?

I can't find a way to access the identity hash code without compilation. Would something like a method that calls System.identityHashCode but is not inlied work?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2607156541
PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2607151871


More information about the hotspot-dev mailing list