Mozilla's high-performance TraceMonkey JavaScript engine, which was first introduced in 2008, has lost a lot of its luster as competing browser vendors have stepped up their game to deliver superior performance. Firefox now lags behind Safari, Chrome, and Opera in common JavaScript benchmarks. In an effort to bring Firefox back to the front of the pack, Mozilla is building a new JavaScript engine called JägerMonkey.

The secret sauce that will drive Mozilla's new JavaScript engine engine into the fast lane is some code borrowed from Apple's WebKit project. Mozilla intends to bring together the powerful optimization techniques of TraceMonkey and the extremely efficient native code generator of Apple's JSCore engine. The mashup will likely deliver a significant boost in Firefox's JavaScript execution speed, making Mozilla's browser a formidable contender in the ongoing JavaScript speed race.

Mozilla's current JavaScript engine uses nanojit as its native code generator. Adobe originally developed nanojit to power Flash's ActionScript execution and released it under an open source software license in 2006. Mozilla and Adobe were going to use nanojit to build an ECMAScript 4 implementation called Tamarin, but the project was largely abandoned when ECMAScript 4 was shelved. Mozilla integrated nanojit into its existing SpiderMonkey engine and added tracing optimization to build TraceMonkey.

Mozilla's new JägerMonkey engine will continue to use nanojit for some things, but will rely on Apple's Nitro Assembler to generate efficient native code. This will allow JägerMonkey to benefit from the performance advantages of method-based just-in-time (JIT) compilation. JägerMonkey will also use tracing optimization to flatten out loops and speed up other kinds of execution paths that can benefit from further optimization. Mozilla says that this blend of technologies potentially offers the best of all worlds.

"The reason we're [building JägerMonkey] is that TraceMonkey is very fast for code that traces well, but for code that doesn't trace, we're stuck with the interpreter, which is not fast. The JägerMonkey method JIT will provide a much better performance baseline, and tracing will continue to speed us up on code where it applies," wrote developer David Mandelin a blog entry about the new engine.

The project is said to be at a relatively early stage of development and is not yet ready to be broadly demonstrated. Developers who want to have a look at the code can download it from Mozilla's version control repository. The current development status is described in a page at the Mozilla wiki.