RFR: 8372845: Fold identity hash code if object is constant
Vladimir Kozlov
kvn at openjdk.org
Tue Dec 2 21:01:00 UTC 2025
On Tue, 2 Dec 2025 20:53:56 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>>> would it be safer for us to move the constant detection after generate_virtual_guard in the is_virtual if block?
>>
>> Good catch. I missed that the intrinsic is shared between `System::identityHashCode()` and `Object::hashCode`.
>>
>> I'm not sure it makes sense to support `Object::hashCode` unless C2 can eliminate `generate_virtual_guard` for a constant receiver. I'd just limit constant folding to `!is_virtual` case for now.
>
>> I'm not sure it makes sense to support Object::hashCode unless C2 can eliminate generate_virtual_guard for a constant receiver. I'd just limit constant folding to !is_virtual case for now.
>
> Or, alternatively, inspect constant object's v-table during compilation and ensure that corresponding slot points at `Object::hashCode`.
@iwanowww please fix title to match JBS.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28589#issuecomment-3603933760
More information about the hotspot-compiler-dev
mailing list