Inside Mozilla's New JavaScript JIT Compiler
An anonymous reader writes "IonMonkey is the name of Mozilla's new JavaScript JIT compiler, which aims to enable many new optimizations in the SpiderMonkey JavaScript engine. InfoQ had a small Q&A with Lead Developer David Anderson, about this new development that could bring significant improvements in products that use the SpiderMonkey engine like Firefox, Thunderbird, Adobe Acrobat, MongoDB and more.
This new JIT infrastructure, will feature SSA compiler intermediate representations which will facilitate advanced optimizations such as type specialization, function inlining, linear-scan register allocation, dead-code elimination, and loop-invariant code motion."
What's different between IonMonkey and JaegerMonkey (the last engine I thought)?
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
I'd be interested to hear why the Mozilla developers don't use an existing compiler framework like LLVM, which already implements many advanced optimization techniques. I am aware that JavaScript-specific problems need to be dealt with anyway, but it seems like they could save themselves a lot of hassle in things like register allocation etc. Those are not so interesting problems that are handled by existing tools like LLVM quite well, so why not use that?
Damn, Mozilla changes JIT engines like every year. Why should be believe this one will last any longer than all the others they have tried?
Javascript is a poorly designed language that is hard to JIT and I imagine that's why we keep seeing people trying to redo things better than the previous JIT engine. It's damn near impossible though, just micro-fractional improvements and a whole lot of wasted effort.
Meanwhile things like LuaJIT offer a Javascript-like scripting environment with damn near the performance of native C applications. Pretty much all done by one guy.
Lua is what Javascript should have been. It's dynamic, simple, and fast (partly because it's so simple). The language itself is so much cleaner than Javascript which makes it easy to parse and optimize while still giving you all the power.
Maybe is this obvious. In the interview he mentions that optimization is hard because the types of variables aren't known. For me (and probably most programmers) the variable names are a dead give away on the type. A variable called "i" is going to be an int and "str" is a string. Likewise with iName and strName. I wonder if they have run some analysis on a large body of code to see if they can do a good guess on the variable type from its name.
Now javaScript is so fast perhaps other interpreted languages would be "compiled" to JS. I am thinking of Perl6 for one.
This looks a lot like what PyPy is currently doing
Didn't Mozilla cry bloody murder when IE9 was discovered to perform dead-code elimination claiming it was "cheating" because it made some outdated JS benchmarks finish in 0 time?
I think its time that Javascript and HTML get transmitted in a pre-compiled format, like Java.I'm sure the compiled file will be smaller than its mark-up counterpart, and would run faster in the browser since the browser won't have to analyze the mark-up before "compiling it" and rendering it. Plus, it might help people code their web-pages to standards if the compilers won't compile their half-assed HTML.
I wonder how do javascript engines optimize hash table lookups. Especially since it is faster to access a member of an object than to access a variable of an outer function. It seems to me that the former requires a hash table lookup with a string key while the later suffices with a pointer into the closure of an outer function and the offset of the variable.
and I still cannot run a mozilla javascript environment inside IE, Opera, or Chrome.
You think I'm joking but I'm plain serious. Why are we so dependent on each particular javascript implementation?
If Pandora's box is destined to be opened, *I* want to be the one to open it.
I don't understand the whole DCE reasoning. I mean - the cases show here and on mozilla's site are valid, but I'd like to know where in the world, aside from tests that aim to show browser maker's faults, does anyone actually write dead code?
As a developer I care for performance of my applications and optimize away what can be optimized - by using a profiler and analyzing compiler warnings. There are numerous books and articles on how to write good code.
This task should not be left to the JS engine - it only encourages writing sluggish and sloppy code hat does behave well only when certain conditions (read: browser version, JS engine, particular compile flag) are met. Instead there should be an interface set up that issues a warning: "Hey, this code does nothing. Consider removing it." in JS console or whatever JS devs use.
This whole JS seems to me that it could be improved - how about introducing some concepts from real programming languages, like typing, profiling, etc?