deeply nested MethodHandles, performance?
Garcia Gutierrez Miguel Alfredo
miguelalfredo.garcia at epfl.ch
Fri May 18 08:47:44 PDT 2012
Hi,
I've been experimenting with MethodHandles for runtime code generation [1] by combining MHs as one would build an AST, e.g. using the "application" combinator :
public static MethodHandle application(MethodHandle target, MethodHandle[] args) {
MethodHandle[] invokers = new MethodHandle[args.length];
for(int idx = 0; idx < args.length; idx++) {
invokers[idx] = exactInvoker(args[idx].type());
}
MethodHandle applied = filterArguments(target, 0, invokers);
for(int idx = 0; idx < args.length; idx++) {
applied = applied.bindTo(args[idx]);
}
return applied;
}
Similarly for "assignment", "block expression", and the rest of control flow.
With those building blocks, one can generate, say, a loop to add all numbers in an array [2] (which might not be the most efficient way to compute a sum-total) but which begs the question: How much of simplification can HotSpot perform on those MH trees ?
Miguel
http://lampwww.epfl.ch/~magarcia/ScalaCompilerCornerReloaded<http://lampwww.epfl.ch/%7Emagarcia/ScalaCompilerCornerReloaded>
References
----------
[1] http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/2012Q2/RuntimeMP.pdf<http://lamp.epfl.ch/%7Emagarcia/ScalaCompilerCornerReloaded/2012Q2/RuntimeMP.pdf>
[2] https://github.com/magarciaEPFL/MethodHandleUtils/blob/master/src/bt4/SummingUp.java
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20120518/619259c6/attachment.html
More information about the hotspot-dev
mailing list