On Tue, 21 May 2024 00:16:51 GMT, Chen Liang <[email protected]> wrote:
>> 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.
>
> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 630:
>
>> 628: .withMethodBody("typeSwitch",
>> 629:
>> MethodTypeDescImpl.ofValidated(ConstantDescs.CD_int,
>> 630:
>> ClassDesc.ofDescriptor(selectorType.descriptorString()),
>
> `selectorType` can be primitive, therefore verification errors arise at
> `aload` in the generated code. This is why tests fail on GitHub actions.
Dang. I had focused on making the `java/lang/runtime` tests pass locally,
thinking that'd be sufficient. Luckily bf68b1d had only a minor benefit.
Backing it out and tidying up a bit gives me these numbers:
Wall clock: 65.0 ms/op
.taskclock: 75.0 ms/op
.cycles: 255323158 average cycles elapsed
.instructions: 626086160 average instructions retired
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19307#discussion_r1607874407