Projects, which use JSR292

Rémi Forax forax at univ-mlv.fr
Tue Feb 15 09:53:18 PST 2011


On 02/15/2011 06:13 PM, John Rose wrote:
> On Feb 15, 2011, at 6:50 AM, Kirill Shirokov wrote:
>
>> - JRuby by Charles Oliver Nutter
>> - PHP.reboot by Remi Forax
>> - Smalltalk implementation by Mark Roos (in progress)

And Java lambda in JDK8.
The current prototype already use JSR 292.

>
> I think this recent thread is about an OCaml implementation by Xavier Clerc:
>    http://mail.openjdk.java.net/pipermail/mlvm-dev/2011-February/002464.html

I have also a metaclass core prototype named Gru (as a possible core for 
Groovy 2)
but it's far from being usable by anybody.
And a not yet finished implementation of JSR 292 on Android.

As an implementer, the first benefit of JSR 292 is to greatly simplify 
the implementation
of several common patterns:
- invokedynamic+CallSite.setTarget() allows to easily implement any kind 
of inlining caches
    (one element cache or bymorphic cache, tree of decision, etc.)
    which are the mothers of all optimizations of any dynamic languages.
- MutableCallSite.syncAll() allows to do thread safe deoptimization which is
   the root of all optimistic optimizations. No guard anymore ! (in 
reality, less guards).
- MethodHandle give you lambda for free.
- Predefined method handles avoid code generation for doing the plumbing
   required by features like varargs, spreads, named parameters.
   i.e adaptation between the calling and the target method.
- MethodHandles.asInstance() avoid code generation when bridging Java 
core interfaces like
   Comparator, Runnable, Callable and MethodHandle.
- invokedynamic bootstrap method ease the implementation of lazy 
intialization.
- ClassValue ease the storage of Class metadata.
- invokedynamic bootstrap method constants ease the storage of callsite 
metadata.

And I'm sure I forget some features.

The second benefit is performance.
Some performance improvement are already visible by example using metod 
handle for
doing reflection is more efficient than using java.lang.reflect 
especially when you deal with primitive types.
Some improvement are yet to appear like inlining of the whole callsite 
target tree.
Some will come later just because they require more works :)

About performance of the dynamic language runtimes, because JSR 292 
simplifies
the implementation of the runtime, I expect that existing runtime will 
introduce
more optimizations just because the code is now simpler. PHP.reboot is 
all about that.

> -- John

Rémi



More information about the mlvm-dev mailing list