Adobe open sources Flash JavaScript engine
The other day, it was announced that Adobe would be submitting the source code of Tamarin, the JavaScript engine used in Flash, to Mozilla for open sourcing. In turn, Mozilla will be using it in future editions of Firefox. Why does this matter?
The most important thing is that Tamarin is a just-in-time JavaScript compiler, not an interpreter. That means it’s producing machine byte code and then executing instead of interpreting a syntax tree at runtime. Compiling down to byte code means that JavaScript code execution will be significantly accelerated in future editions of Firefox. One may call this one of the most significant enhancements to JavaScript since it was created: transforming it from an interpreted language to a compiled one.
To make sure everyone understands, this doesn’t mean you’ll be compiling your JavaScript before deploying it. Everything will be the same except the client will run much faster (this should also help speed up the Firefox interface since a lot of it is written in JavaScript as well). It’ll be interesting to see how other browser makers respond to this.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.
Both comments and pings are currently closed.




10 Comments
I don’t think Opera will do much since their JS implementation smokes anything out right now, this would just give it a run for its money.
Do you know what kind of license it was released under? Is there any reason M$, Opera, or other browser makers could not take this code and implement it? Just think of the JavaScript nirvana that would ensue if they did!
Andrew Herron on November 9th, 2006 at 2:14 pm
I wonder if self modifying code still works in their system. I assume eval would still work.
david_kw on November 9th, 2006 at 3:50 pm
Andrew: I think this will definitely blow out any other Browsers JS engine that isn’t compiling. So to put it politely, Opera will have to catch back up.
Dustin Diaz on November 9th, 2006 at 8:49 pm
Dustin’s right, all JavaScript interpreters will pale in comparison to the performance of compiled JavaScript. It’s not even a competition.
David – self-modifying code will still work, it’ll just be much faster. Compiling the code doesn’t change it’s nature, it just changes how it’s executed.
Nicholas C. Zakas on November 9th, 2006 at 9:00 pm
I wouldn’t be so sure. The overhead of JIT-compiling the JavaScript code in many situations may be greater than the time taken to execute the code itself. Many JavaScript functions are executed only as a result of DOM events, which happens relatively infrequently and are relatively small, in which case the time spent compiling can dwarf the time spent executing the code. The other thing to consider is that a relatively small amount of time is spent inside the JavaScript runtime — most JavaScript code is doing something. The most common cause of "slow" JavaScript is time spent manipulating the DOM or doing XMLHttpRequests. Using a JIT compiler will have little effect on code that spends the majority of its time doing real work.
Mark Rowe on November 10th, 2006 at 2:16 am
With all of this development, and all of the power now under the hood in Firefox, and a JIT, what is the browser becoming?
An application development platform to rival (in some respects at least) Java and .NET?
Julian Turner on November 10th, 2006 at 5:54 am
Mark: That’s exactly what I was thinking. Why compile code at runtime that may not even be run?
What would be cool would to have the ability to compile the code before runtime into a file that can be imported by Mozilla. While you’d still have to have a file that could be read by everyone else, the compiled file would run like a dream on the new engine and there would not be the overhead of compiling at runtime every time the user did something.
To that, does the engine cache the compiled code, or every time I refresh the page is it going to recompile?
Andrew Herron on November 10th, 2006 at 9:11 am
Guys, I think you’re misunderstanding the concept of "just-in-time" compiling. What this means is that code is compiled only when it is needed. It’s the exact same way the .NET Common Language Runtime and the Java Runtime Environment work. As soon as it reaches a point where code is needed, it is compiled and executed. Nothing is compiled ahead of time. This is what provides the speed, it’s incremental background compilation that is completely transparent to the user.
Another key aspect of JIT compiling is that it does cache the code it’s already compiled so that it will be faster the next time. If you navigate away from a page and go back, the code isn’t recompiled.
Mark – You’re incorrect in saying that JIT compiling won’t have any effect on DOM manipulations. Anything that is scripted will benefit. The time it takes for a server response to be received will always be time-consuming, but that has nothing to do with the execution of JavaScript.
Nicholas C. Zakas on November 10th, 2006 at 1:36 pm
It seems to me that this should’ve been done a long time ago. This’ll be sweet!
Jeremy on November 10th, 2006 at 6:19 pm
There is a good FAQ at Mozilla: http://www.mozilla.org/projects/tamarin/faq.html
José Jeria on November 12th, 2006 at 7:14 am
Comments are automatically closed after 14 days.