RFR: 8263087: Add a MethodHandle combinator that switches over a set of MethodHandles
forax at univ-mlv.fr
forax at univ-mlv.fr
Fri Apr 9 18:15:24 UTC 2021
----- Mail original -----
> De: "John Rose" <john.r.rose at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Jorn Vernee" <jvernee at openjdk.java.net>, "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Envoyé: Vendredi 9 Avril 2021 20:01:18
> Objet: Re: RFR: 8263087: Add a MethodHandle combinator that switches over a set of MethodHandles
Hi John,
> On Apr 9, 2021, at 9:55 AM, Remi Forax <forax at univ-mlv.fr> wrote:
>>
>> I think the combinator should be lookupswitch which is more general than
>> tableswitch with a special case when generating the bytecode to generate a
>> tableswitch instead of a lookupswitch if the indexes are subsequent.
>
> We can get there in the simpler steps Jorn has outlined.
I fail to see how it can work.
>
> The combinator is much simpler if the case numbers are implicit in [0,N). Then
> it’s natural to filter on the [0,N) input as a separately factored choice.
An array of MethodHandles + a default method handle is simpler than an array of sorted ints + an array of MethodHandles + a default method, but not much simpler.
> That also scales to pattern-switch.
yes, for all the switches, pattern-switch, enum-switch but not for the string switch which requires a lookup switch.
Can you outline how to use the tableswitch combinator in the case of a switch on strings ?
>
> I agree with the choice to have N call sites. It’s possible to build the one
> call site version on top using constant combinators but not vice versa.
yes,
Rémi
More information about the core-libs-dev
mailing list