Mozilla vows Google 'Crankshaft' riposte
'Nobody puts Monkey in a corner'
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.'" ®
Sponsored: The Nuts and Bolts of Ransomware in 2016