The upcoming JavaScript engine is showing very promising early results

Mar 1, 2010 17:50 GMT  ·  By
JaegerMonkey, the upcoming JavaScript engine from Mozilla, is showing very promising early results
   JaegerMonkey, the upcoming JavaScript engine from Mozilla, is showing very promising early results

Most browser makers tout JavaScript performance these days, at least, if they have what to brag about. Unlike most numbers and stats shoved in front of people, JavaScript performance actually matters and modern browsers have made spectacular leaps in speed to keep up with the latest powerful web apps. But since no one is sitting still, the arms race seems to be escalating. Mozilla's Firefox has seen some pretty big improvements in JavaScript speed with both 3.0, 3.5 and even in the latest 3.6. Yet, it's still behind competitors like Chrome, Safari and even Opera. What was needed was a brand-new (relatively speaking) JavaScript engine. Enter JaegerMonkey, a new JavaScript engine project at Mozilla, which is showing very promising signs even at this early stage.

JaegerMonkey is not exactly new, though it's not exactly an update or evolution either. It takes the Dr. Frankenstein tried-and-tested method of stitching together the best parts from several JavaScript engines out there to get the best possible combination but, hopefully, with slightly better results than he aforementioned doctor.

TraceMonkey

Firefox currently uses the TraceMonkey JavaScript rendering engine, a relatively new development. It was introduced with Firefox 3.5 and built on the old SpiderMonkey engine but added native-code compilation using a method dubbed "trace trees," hence the name. It examines the JavaScript code from a web page, finds the bits that repeat most often and then compiles them into native code, which executes several times faster than JavaScript.

This approach provided a significant boost in speed, when it worked. When it didn't, the underlying engine, SpiderMonkey, was still significantly slower than its competitors. With JaegerMonkey, Mozilla aims to take its tracing method and apply it to a faster base and also borrows from one of its competitors, Apple, to get the best possible results.

JaegerMonkey

"Why couldn’t we trace and keep going SUPER AWESOME FAST, and when tracing fails, fall back to STILL REALLY FAST?" Mozilla's David Anderson asks. "Our new project, JaegerMonkey (or JägerMonkey), has exactly this in mind. We’re taking the tried-and-true approach of other vendors, and bolting trace compilation on top. Once the two are interacting seamlessly, you’ll have a much more consistent – and fast – JavaScript performance experience."

So far, only early progress has been made and several main components have been built separately. But even at the early stage, the results are promising. Anderson reports a performance boost of 30 percent on x86 and 45 percent on x64 for his new JIT compiler he's building from the ground up compared to the regular interpreter. At the same time, Mozilla's adaptation of Apple's Nitro JavaScript JIT native-code assembler is also wielding performance gains of 18 percent and this is before the two components have been put together and with very little optimization. Granted, JaegerMonkey is still a long way off from landing in a Firefox stable build, it's not even in the Firefox nightly developer builds. But if progress moves at a fast enough pace, it should give Mozilla's browser a fighting chance perhaps by the time Firefox 4.0 lands.