----- Mail original -----
> De: "John Rose" <john.r.r...@oracle.com>
> À: "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "Jorn Vernee" <jver...@openjdk.java.net>, "core-libs-dev" 
> <core-libs-dev@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 <fo...@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

Reply via email to