RFR: 8372845: C2: Fold identity hash code if object is constant [v4]
Vladimir Ivanov
vlivanov at openjdk.org
Tue Dec 16 02:53:53 UTC 2025
On Tue, 16 Dec 2025 02:39:47 GMT, Chen Liang <liach at openjdk.org> wrote:
>> src/hotspot/share/opto/library_call.cpp line 4806:
>>
>>> 4804: assert(!is_virtual, "no devirtualization for constant receiver?");
>>> 4805: ciConstant identity_hash = t->const_oop()->identity_hash();
>>> 4806: if (identity_hash.is_valid()) {
>>
>> Is there any reason we don't calculate the identity hash right away if there is not any?
>
> @iwanowww recommended not to so that we can save resources - ideally we should convert this to sort of macro node, so we can calculate the hash if the node is not eliminated in the end.
My main concern is possible interference with application, not performance.
One example is CDS where archive dumping is performed in a single thread with a fixed random generator seed. If identity hash computation can be triggered from JIT-compiler thread (with a different seed), it will break deterministic behavior.
Another case to illustrate another type of issues is biased locking: the optimization was disabled for objects with identity hash code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28589#discussion_r2621562185
More information about the hotspot-dev
mailing list