The big new feature in Firefox 9 is most interesting to developers

Nov 11, 2011 10:42 GMT  ·  By

Several days after Firefox 8 landed in the stable channel, beta users are finally getting Firefox 9, which has graduated from the Aurora channel. There aren't any surprises with Firefox 9 Beta, everything that was expected is there.

The big new feature in Firefox 9 is type inference for JavaScript. That may not mean much to regular users, but developers will know the importance of this.

It's a big project at Mozilla, some of its developers have been working on it for over a year and it is now ready for the big time.

One problem with JavaScript, from a performance stand point, is that variables are not give a type, i.e. integer, string and so on, from the get go but the type is determined by whatever the code does with the variables.

This adds a lot of flexibility to writing and managing the code, but it means that JavaScript interpreters have to account for this and treat each variable as an abstract type that can hold any type of value.

The SpiderMonkey JavaScript engine in Firefox 9 analyzes the code and predicts the type of the variables. Then, it uses that predictions when generating JIT compiled code.

This results in smaller and faster code and lower memory requirements, although that is offset somewhat by the memory used to determine the types.

"Firefox 9 includes modifications to the JaegerMonkey JIT compiler to use inferred type information. This compilation mode, which is the default in Firefox 9, speeds up major benchmarks like Kraken and V8 by over 30%, and gives a large speed boost to many JS heavy websites," Brian Bondy, Firefox Engineer, explained.

But even now that the type inference technology in Firefox 9 is complete, Mozilla is working on making more use of it. It's next generation JIT, IonMonkey, which is still some time away, will be built with type inference in mind, so the performance improvements should be even greater.