Charles Oliver Nutter, of JRuby fame, recently started assisting the Rhino project (Java implementation of JavaScript) to speed up the Rhino JavaScript runtime to compete with the likes of V8. Rhino, although a solid implementation, does not have the performance of other JavaScript runtimes. Nutter feels Rhino can make up some lost ground by using Invokedynamic and other optimizations. This could put Rhino on par with V8 or at least more competitive.

InfoQ caught up with Nutter to find out what he and the Rhino team are up to. Nutter plans on employing the JVM's Invokedynamic to wire up Rhino's dispatch mechanism directly into the JVM's optimizing compiler. This should reduce or eliminate overhead for method lookup at call time, argument-boxing overhead, and JavaScript to JavaScript calls as well as JavaScript to Java calls by inlining and optimizing as a whole. Nutter explained that a side benefit of using invokedynamic is that the invocation logic of Rhino will be much simpler for the Java 6 case.

InfoQ went on to ask Nutter how important he felt it was for the JVM to have a faster JavaScript implementation since JavaScript has seemed to become increasingly important overall. Nutter responded:

I personally think a lot of the hype about JavaScript is overblown. It's a good language for the browser primarily because all browsers support it not because the language is significantly better than other options. And on the server side, it has become popular because runtimes now perform well and there's a lot of libraries written for client-side that are applicable to the server as well. ... However, given the recent popularity of JavaScript for end-to-end applications, it seems only natural for the JVM version to have a refresh. It's also something of an embarrassment that arguably the fastest managed runtime around -- the JVM -- can't manage to run JavaScript as fast as current competitors. I think it's time for that to change.

Finally we asked Nutter how Rhino compared with the challenges thrown up by JRuby from an implementation point of view. Nutter responded:

Rhino may actually be an easier target in many ways, since it does not have some of Ruby's wilder features. However, it presents an interesting challenge in that its prototype-based object model leaves no clear location to store method table caches as is the case in Ruby. Techniques used by V8 and John Rose's "DavinciMonkey" (an early attempt at invokedynamic-based Rhino) -- such as generating synthetic classes as prototypes are modified -- should make it easier to deal with Rhino's more fluid type structure.

There is a large performance gap between the V8 JavaScript engine employed by Chrome and Rhino. Nutter commented that JVM features like invokedynamic may close the gap, but Rhino itself needs to be updated with performance in mind. Although Rhino is a great implementation there are techniques to employ to speed things up with or without new JVM feature like invokedynamic.

It is too soon to tell if Rhino can compete with VMs written specifically with JavaScript in mind, but Rhino is sure to get a speed boost.