This article is more than 1 year old

Mozilla vows Google 'Crankshaft' riposte

'Nobody puts Monkey in a corner'

Mozilla has vowed not to get "left behind" by Google's latest JavaScript engine, codenamed Crankshaft.

With a blog post on Wednesday, Mozilla's David Mandelin mused on Craftshaft's "adaptive compilation" design and said that the Mozilla JavaScript team and developer community "definitely have the skills and resources to enhance" Firefox's JavaScript engine in ways that match Google's work, and he indicated that this will begin after the release of Firefox 4, due early next year.

Today, at the annual Add-on-Con browser conference in Mountain View, California, Mozilla director of products Jay Sullivan told us that the open source outfit sees Crankshaft as yet another example of the major browser vendors pushing each other to improve JavaScript speed. "It's good. At the highest order, the competition continues," he said, after pointing us to Mandelin's blog post.

Mandelin compares Crankshaft to Firefox's existing TraceMonkey JavaScript engine extension. "I have to point out that run-time type specialization for JavaScript was pioneered by Mozilla’s TraceMonkey project," he said. But he also points out that Crankshaft takes the technique several steps further.

Crankshaft consists of four components. There's a base compiler as well as a run-time profiler that identifies hot code – code that's frequently used. Then an optimizing compiler recompiles the hot code to offer such optimizations as loop-invariant code motion, linear-scan register allocation, and inlining. Plus, Google's V8 team has included "deoptimization support", which identifies cases where the optimizing compiler has over-promised on speed improvements. In this case, the engine falls back on the base compiler.

"Crankshaft introduces an optimizing compiler that does complex optimizations, such as register allocation and loop-invariant code motion," as Mozilla's David Mandelin sees it. "These optimizations take time, so they would make startup slow if that was the only compiler. But Crankshaft also has a base compiler that starts fast but doesn’t optimize very much: probably less than the V8 compiler, in fact. Only if the code is predicted to run many times will it be compiled with full optimization."

With TraceMonkey, Mandelin says, Firefox's engine does something similar. But Crankshaft goes further. Unlike Crankshaft, he says, TraceMonkey just records a trace once – a trace being a code loop that gets reused. Crankshaft, it seems, profiles code repeatedly. It also seems that Crankshaft optimizes entire methods rather than just traces. And it uses inline caching.

"Plenty to do after Firefox 4 comes out," Mandelin said . "In the words of [fellow Mozilla developer] David Anderson, 'The game’s back on.'" ®

More about

TIP US OFF

Send us news


Other stories you might like