Turn on JavaScript JIT in Firefox 3.1
Mozilla has just introduced a new JavaScript optimization feature to Firefox 3.1 development code base (Shiretoko) that well enhances JavaScript-based web apps performance by a 2x - 20x fold compared to the Firefox 3.0, according to JavaScript performance tests ran and published by Mozilla’s Brendan Eich.
I’m extremely pleased to announce the launch of TraceMonkey, an evolution of Firefox’s SpiderMonkey JavaScript engine for Firefox 3.1 that uses a new kind of Just-In-Time (JIT) compiler to boost JS performance by an order of magnitude or more.
Here are some of the charts from Brendan’s blog:

Assorted benchmarks

SunSpider micro-benchmarks
However the best way to evaluate it is to see it in action via simple JavaScript image editor that lets you adjust a picture’s contrast and brightness with a couple of sliders created by Mike Schroepfer. By default, TraceMonkey is disabled (as it is still buggy), there is a very noticeable delay while sliding. Turn it on (javascript.options.jit.content = true in about:config) and the thing works like charm, very smoothly.

JavaScript Image Editor
Going into significant detail on how all of this came about, Brendan notes some key points:
- We have, right now, x86, x86-64, and ARM support in TraceMonkey. This means we are ready for mobile and desktop target platforms out of the box.
- As the performance keeps going up, people will write and transport code that was “too slow” to run in the browser as JS. This means the web can accomodate workloads that right now require a proprietary plugin.
- As we trace more of the DOM and our other native code, we increase the memory-safe codebase that must be trusted not to have an exploitable bug.
- Tracing follows only the hot paths, and builds a trace-tree cache. Cold code never gets traced or JITted, avoiding the memory bloat that whole-method JITs incur. Tracing is mobile-friendly.
John Resig says similar opinion in his blog post on the subject:
[This] means that JavaScript is no longer confined by previously-challenging resource of processing power… I fully expect to see more massive projects being written in JavaScript…
The primary thing holding back most extensive Canvas development hasn’t been rendering - but the processor limitations of the language (performing the challenging mathematical operations related to vectors, matrices, or collision detection). I expect this area to absolutely explode after the release of Firefox 3.1 as we start to see this work take hold.
Yes, after the release of Firefox 3.1 we can expect a new wave of web apps and games leveraging JIT JavaScript engine for much better performance without third-party plugins like Flash, Java Applet…

