Mozilla JIT Choices

by Miguel de Icaza

I was reading a comparison between Adobe's Tamarin JIT and Sun's HotSpot and there was some discussion started by Chris:

Maybe, I'm missing something, but I really don't see why Mozilla doesn't build on the Java platform rather than Tamarin. Investing effort in writing a full ECMAScript 3 or 4 translator to JVM byte-code seems like an easier and faster way to get much better results than Tamarin.

To which one of Brendan Eich's replies was:

We don't depend on closed source in-process code, period. I've also mentioned the license requirements, not that it mattered due to the lateness of Java's open source transition (GPL alone is not ok).

I ran the same program that was posted there on Mono, and extrapolating the values (my machine is faster than Chris, but am using Java HotSpot 1.6):

  • Tamarin: 58 second
  • Rhino JS engine: 31.944 seconds;
  • Mono: 10 seconds;
  • HotSpot: 2.23 seconds

Someone on the thread pointed out that using type annotations might bring Tamarin to 11 seconds. Update: , but Chris was not able to replicate that behavior..

It is clear that Mono's floating point performance is far from ideal. Currently Mono on x86-32 platforms is still using the x87 "stack" style of floating point operations as opposed to the more efficient XMM style of code generation that we used on x86-64. We should look into this.

Update: Mike ran the tests on x86-64 where Mono has a different floating point implementation and the results are promising, instead of being 4 times slower than Java in this test Mono is only 2 times slower.

That being said, for Mozilla purposes, it seems that using Mono as their JIT instead of Tamarin would be a better choice:

  • Mono can be shrunk down to 5 megs by picking files (uncompressed) and even more if you are willing to ifdef stuff.
  • Mono's VM is licensed under the LGPL.
  • Mono runs IronPython, IronRuby and the DLR out of the box, no need to modify either one of them.
  • Mono already supports more platforms than Tamarin (and I believe we support more than Sun's JVM).

Planning-wise its probably too late to use Mono on Mozilla, which is a shame.

It might still be interesting to prototype using Mono + Rhyno as a Javascript engine or completing the DLR-based Javascript and see how fast it can get.

This could probably be prototyped on WebKit/Gtk easily.

Posted on 06 Aug 2007