RFR: 8372845: C2: Fold identity hash code if object is constant [v4]
Chen Liang
liach at openjdk.org
Mon Jan 26 17:16:13 UTC 2026
On Tue, 13 Jan 2026 03:27:06 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:
>>
>> - Move test, fix merge garbage
>> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/identity-hash-const
>> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/identity-hash-const
>> - Typo
>> - assert
>> - refactorings
>> - Typo
>> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/identity-hash-const
>> - Cleanup
>> - identity hash support in C2
>> - ... and 2 more: https://git.openjdk.org/jdk/compare/96fd00b6...67a3954f
>
> src/hotspot/share/ci/ciArray.cpp line 93:
>
>> 91: // Returns T_ILLEGAL if there is no element at the given index.
>> 92: ciConstant ciArray::element_value(int index) {
>> 93: assert(index >= 0, "out-of-bounds index: %d", index);
>
> IIUC, this is because you use `-1` as the offset for hashcode, so you need to make sure we are accessing a real element here, or the cache access will return something dubious. I think it is then more uniform to save the value at the cache using the offset instead of the element index.
I think I will not touch ciArray but rather comment on the ConstantValue _off variable about it is just a key.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2728496636
More information about the hotspot-runtime-dev
mailing list