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

Aleksey Shipilev shade at openjdk.org
Tue Apr 18 08:39:46 UTC 2023


On Mon, 17 Apr 2023 23:38:31 GMT, John R Rose <jrose at openjdk.org> wrote:

> I do have one comment: Since identity hash codes are typically reasonably well-conditioned, it is perfectly reasonable to recondition an occasional 0 by replacing it with 1, in order to store it in a stable variable for later reuse.

As comment in the code change says, this is already handled on Hotspot side: https://github.com/openjdk/jdk/blob/cc60f2ff3f16bdb04917e09cb87f09bd544f1f8b/src/hotspot/share/runtime/synchronizer.cpp#L826-L827 -- if only to disambiguate the "unset" IHC in the object header. So the stars have already aligned well for us to use `0` as uninitialized marker!

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

PR Comment: https://git.openjdk.org/jdk/pull/13491#issuecomment-1512684621


More information about the core-libs-dev mailing list