MethodHandles for Kawa and other functional languages?
Per Bothner
per at bothner.com
Sun Oct 10 17:21:32 PDT 2010
On 10/10/2010 02:20 PM, Rémi Forax wrote:
> guardWithTest is the missing piece.
> It should be something like that:
> ...
Thanks! This is somewhat tricky - it will take a bit to grok it
property.
> Perhaps you need to add some conversions with convertArguments.
> But as I said, why do you want to use invokedynamic here ?
That is the question - how much would a language like Kawa
benefit from using invokedynamic - or MethodHandles in some
other way.\? Some potential benefits:
* Reduce boxing - e.g passing an int to an unknown function
which in turns expects an int.
* A better implementation of "multi-methods" - which are not
standard Scheme and probably not very common, except for a few
built-ins.
What I suspect might be the biggest benefit:
* Less indirection, allowing potential other VM optimizations,
like inlining. Currently, a user-defined Procedure is an
object that references a ModuleBody and an index. Appying
the procedure is implemented by calling a handler method in
the ModuleBody. The handler method does a switch on the
index, then does some argument type checking/conversion, then
calls the static method that does the actual work. I'm
guessing this indirection makes it difficult for the VM to
optimize such calls, but using invokedynamic would help.
Bu it is also possible I might get more bang-for-the-effort
by focusing on, say, arithmetic. Rather than try to optimize
calling unknown procedures it might be more worthwhile to
concentrate on calling known procedures with unknown argument
types, like + when the operands don't have type specifiers.
--
--Per Bothner
per at bothner.com http://per.bothner.com/
More information about the mlvm-dev
mailing list