On Mon, 17 Apr 2023 13:00:36 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Enum.java line 191: >> >>> 189: int hc = hash; >>> 190: if (hc == 0) { >>> 191: hc = hash = System.identityHashCode(this); >> >> Why not `hc = hash = super.hashCode()`? > > Saves the virtual call, makes for a simpler intrinsic path (no need to handle > NPE and fold away, for example), since we know the super-class is already > `java.lang.Object`. Unless I miss something else here... Shouldn’t `invokespecial` produce a non‑virtual call as well? And `this`/`super` can never be `null`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13491#discussion_r1169484780