BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Rhino is About to Get a Lot Faster

by Rick Hightower on Jul 01, 2011 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Sounds very exciting by William Louth

I do hope someone takes this up and gives the codebase an overhaul in terms of performance (ignoring invokedynamic). I came to the same conclusion recently in integrating our metering technology int the library to do Java-to-Javascript translation for profiling purposes.

JavaScript Metering with JXInsight/OpenCore and Mozilla Rhino
opencore.jinspired.com/?p=3623

Progress by Jonathan Locke

I see this was posted in July. Was wondering if there are any preliminary results yet? Would love to hear about it!

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT