RFR: 8350617: Improve MethodHandles.tableSwitch and remove intrinsicData

Chen Liang liach at openjdk.org
Tue Feb 25 21:53:11 UTC 2025


On Tue, 25 Feb 2025 06:37:08 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> Remove the intrinsicData field. We can obtain this from the customized MH when we spin ultra-customized lambda forms. In the long run, we aim to remove this intrinsic if there is no regression for call site sharing.
>> 
>> The existing tableSwitch combinator's LF is unnecessarily complex. This patch also simplifies the tableSwitch combinator.
>> 
>> Note that I was forced to add `@ForceInline` on immutable lists due to regressions in `MethodHandlesTableSwitchRandom` with `sorted == true`, which eliminates the regression. Otherwise, all benchmark results are the same. Tested java/lang/invoke.
>
> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 7659:
> 
>> 7657:         if (!(expectedType.parameterCount() >= 1) || expectedType.parameterType(0) != int.class)
>> 7658:             throw new IllegalArgumentException(
>> 7659:                 "Case actions must have int as leading parameter: " + caseActions);
> 
> As you're already touching this: `expectedType` is the default case, but it's not printed here. This can lead to very confusing output if all caseActions have a leading int parameter but the defaultCase hasn't.

True, why did this insufficent message slip through the original reviews 🤔

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23763#discussion_r1969067288


More information about the core-libs-dev mailing list