The new JIT is already faster and should yield even more improvements in time

Apr 8, 2013 19:41 GMT  ·  By

Firefox has been getting plenty of JavaScript oriented improvements these days. First there was support for asm.js which makes it possible to create really, really fast and complex JavaScript apps. But asm.js is mostly aimed at porting existing C/C++ apps, games in particular, to JavaScript.

Now, Mozilla is introducing a new Baseline JavaScript compiler which, as its name suggests, is a more general tool.

The Baseline compiler is mostly designed to replace JagerMonkey, which is currently used as the go-to just-in-time (JIT) compiler for code that needs to be optimized but doesn't require the big guns, i.e. IonMonkey.

It sits between the interpreter, the base SpiderMonkey, which can take anything sent its way but is obviously significantly slower than any JIT compiler, and IonMonkey which can generate heavily optimized, and thus fast, code though with a significant resource cost.

JagerMonkey doesn't need as many resources as IonMonkey, but it is still significantly faster than SpiderMonkey, and so it is used as a the first step for code that is often utilized by an app.

There are several problems with this setup, mostly due to the fact that JagerMonkey wasn't designed for this. There are significant differences between IonMonkey and JagerMonkey, meaning resources and code can't be shared between the two, for one.

This is where the new Baseline compiler comes in. It was designed for the job it's going to do, which means that it shares some components with IonMonkey and generates code that IonMonkey can utilize without having to start from scratch, i.e. the pure JavaScript code.

Another crucial difference and improvement over JagerMonkey is that optimized code remains optimized no matter what happens, with JagerMonkey code having to be recompiled for type changes, for example.

The Baseline compiler is now part of Firefox Nightly. Tests are already showing a 5 to 10 percent improvement in benchmarks. But, just like with IonMonkey, the new Baseline compiler is just laying the groundwork, future improvements will now be easier to do.