Spread problem with > 10 arguments

Rémi Forax forax at univ-mlv.fr
Sun Jul 5 11:17:56 PDT 2009


Charles Oliver Nutter a écrit :
> I'll give it a try in a bit.
>
> I suspect that method handles will need to know about large numbers of
> arguments, since you often need to pass in the same large signature to
> a given adapter for all its component handles to receive them. For
> example, guardWithTest; the test and fast path may not need all
> arguments, and test may need different/additional ones, but the
> arguments passed to them must be the same long list. Add to that a
> language like Clojure, which has unboxed paths for up to 20
> arguments...
>
> Thanks for the find and fix :)
>   

We can perhaps modify the  fact that  the test, the slow path and the 
fast path
need the same arguments. foldArgument already do this kind of stuff.
In practical terms,  test arguments  can be a sublist of target/fallback 
arguments.

Or in pseudo code:

boolean test(A...);
 T target(A..., B...);
 T fallback(A..., B...);
 T adapter(A... a, B... b) {
   if (test(a...))
     return target(a..., b...);
   else
     return fallback(a..., b...);
 }



Else, for slow paths, you can use a JavaMethodHandle and store
all you need using fields instead of insert them as arguments.
It's very difficult to write a JavaMethodHandle that doesnt not box/spread
to handle polymorphic signatures that why I think it should
only be used to handle slow paths.

Rémi


> On Sat, Jul 4, 2009 at 4:36 PM, John Rose<John.Rose at sun.com> wrote:
>   
>> Good guess, Remi; thanks.  I just pushed a fix.  -- John
>>
>> On Jul 4, 2009, at 8:49 AM, Rémi Forax wrote:
>>
>>     
>>> The code is different if there is less than 10 argument of more :
>>> If this the first line of the else is wrong,
>>> it should be :
>>> MethodType gtype = MethodType.makeGeneric(0, true);
>>>
>>> It's just a guess, sorry,
>>> I've currently no time to compile because I am not at home and just in
>>> front of a browser.
>>>       
>> _______________________________________________
>> mlvm-dev mailing list
>> mlvm-dev at openjdk.java.net
>> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>>
>>     
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>   




More information about the mlvm-dev mailing list