RFR: 8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations

Claes Redestad redestad at openjdk.org
Mon May 20 20:55:30 UTC 2024


We can fold the call to `Objects.checkIndex` into the code generated in generateTypeSwitchSkeleton instead of doing so by filtering the MH argument. This loads 9 less classes (of which 8 generated LFs and Species classes) on a minimal test, while being neutral on a throughput sanity test:


Name                   Cnt  Base   Error   Test   Error  Unit  Change
SwitchSanity.switchSum  15 8,162 ± 0,117  8,152 ± 0,131 ns/op   1,00x (p = 0,800 )
  * = significant
  ```

A few additional optimizations includes generating the switch method using the precise type (to avoid the need for an explicitCast adaptation), and moving some seldom used `findStatic` calls to a holder. All in all this means a reduction by 33-34M cycles to bootstrap a trivial switch expression on my M1.

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

Commit messages:
 - Remove explicitCastArguments and refactor
 - Move rarely used findStatics to Holder class
 - Drive-by desugaring
 - Move Objects.checkIndex call to code generated by generateTypeSwitch

Changes: https://git.openjdk.org/jdk/pull/19307/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19307&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8332528
  Stats: 157 lines in 4 files changed: 113 ins; 18 del; 26 mod
  Patch: https://git.openjdk.org/jdk/pull/19307.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19307/head:pull/19307

PR: https://git.openjdk.org/jdk/pull/19307


More information about the core-libs-dev mailing list