On Fri, 19 Apr 2024 23:56:00 GMT, ExE Boss <d...@openjdk.org> wrote: >> We can reduce overhead of first use of a switch bootstrap by moving >> `typePairToName` into `TypePairs` and by explicitly overriding `hashCode` >> and `equals`. The first change avoids loading and initializing the >> `TypePairs` class in actual cases, the second remove some excess code >> generation from happening on first use. > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 699: > >> 697: >> 698: public boolean equals(Object other) { >> 699: if (other instanceof TypePairs otherPair) { > > To match the behaviour of the `equals` method body generated by > `java.lang.runtime.ObjectMethods::bootstrap`, this should include a fast > path check for `this == other`: > Suggestion: > > if (this == other) { > return true; > } > if (other instanceof TypePairs otherPair) {
No, see https://www.youtube.com/watch?v=kuzjX_efuDs; this fast path is faster for == matching case but significantly slows down all other branches. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/18865#discussion_r1573146432