MethodHandles for Kawa and other functional languages?
Helmut Eller
eller.helmut at gmail.com
Mon Oct 11 00:34:41 PDT 2010
* Per Bothner [2010-10-10 23:38] writes:
> An example I was considering was:
>
> (define (twice f x)
> (f (f x)))
>
> My initial thought was to compile this as:
>
> public static Object (Procedure f, Object x) {
> MethodHandle f$mh = f.asMethodHandle();
> return f$mh.invoke(f$mh.invoke(x));
> }
>
> But this is (presumbly) just using regular method calls,
> without any invokedynamoc or special VM magic or callsite specification,
> so it wouldn't get the real performance benefit.
asMethodHandle should probably receive the type of the callsite. In
this case that would at least specify that f needs one argument (and
returns one instead of multiple values).
> To do that
> I should generate actual invokedynamic instructions, along
> with a suitable CallSite handler, correct?
Optimizing asMethodHandle or invokeExact calls should be just as easy
for the VM, no? E.g. the VM could cache results of asMethodHandle calls
(if the spec of asMethodHandle allows that).
Helmut
More information about the mlvm-dev
mailing list