Charles Oliver Nutter wrote: > I ask because I still have a perverse desire to follow up on an idea > John Rose gave me to implement JRuby's interpreter entirely with > MethodHandles...with the obvious result being that by simply composing > a set of handles they'll already be compiled to native code for me :) > It might be fun, but I do not think that it is a good idea to implement an interpreter in this way, or more precisely, to implement any interpreter of bytecodes, using Java.
For languages like Ruby where the executable format is the source, I assume that your interpreter works on the source text by parsing/interpreting each source code line after each other. Since each interpreter step requires so much computation you will not gain any measurable performance by putting the interpreter loop inside the MethodHandle. On the other hand, if you interpret bytecodes, then each interpreter step is very small. At first it might look like a good idea to try to shave a few instructions from each interpreter step. But the whole point of achieving good performance on the JVM is that you translate the bytecodes of the other language into JVM bytecodes and then allow the JVM technology to do its magic. When you implement an interpreter with JVM bytecodes (or MethodHandles) then you immediately shut the door hard in the face of the JVM. It is simply impossible for the JVM to optimize >through< your interpreter loop into your application. The JVM will try to optimize your interpreter loop, but it is still only the interpreter loop. No variables will be optimized away from your code, no objects allocations will disappear, no inlining will happen! //Fredrik _______________________________________________ mlvm-dev mailing list [email protected] http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
