RFR: 8372845: Fold identity hash code if object is constant

Vladimir Ivanov vlivanov at openjdk.org
Tue Dec 2 20:39:55 UTC 2025


On Tue, 2 Dec 2025 02:49:52 GMT, Chen Liang <liach 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.

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

PR Comment: https://git.openjdk.org/jdk/pull/28589#issuecomment-3603869560


More information about the hotspot-runtime-dev mailing list