RFR: 8306075: Micro-optimize Enum.hashCode [v3]

Pavel Rappo prappo at openjdk.org
Mon Apr 17 13:48:42 UTC 2023


On Mon, 17 Apr 2023 13:08:41 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Yes, it is implementation-specific, that is why it says "Hotspot's identity hash code". The relevant code blocks are https://github.com/openjdk/jdk/blob/cc60f2ff3f16bdb04917e09cb87f09bd544f1f8b/src/hotspot/share/oops/markWord.hpp#L231-L233 (property) and https://github.com/openjdk/jdk/blob/cc60f2ff3f16bdb04917e09cb87f09bd544f1f8b/src/hotspot/share/runtime/synchronizer.cpp#L826-L827 (invariant).
>
> It would not break the code functionally if that invariant ever breaks: we would "just" call the (intrinsic) method on zero hash code. That `implNote` only shows that it would not happen with current implementation at all.

>From that impl note it seemed like it was a big deal for hash code to never return 0 for an object. Could you maybe de-emphasize the importance of that HotSpot behavior in the note?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13491#discussion_r1168725310


More information about the core-libs-dev mailing list