Google 'Crankshaft' inspired by Sun Java HotSpot
Bak to 'adaptive compilation'
But whereas TraceMonkey uses a technique called "tracing" – detecting code loops and converting them into assembly language – Google's Crankshaft uses an approach known as "adaptive compilation" whereby it identifies all sorts of hot code and optimizes whole methods of code as needed. Sun's HotSpot was based on adaptive compilation, and according to Kay the idea of adding adaptive compilation to the V8 engine has long been on Google's roadmap.
Crankshaft includes four complementary components. In addition to a base compiler, there's a runtime profile that identifies hot code. Then an optimizing compiler recompiles the hot code to offer such optimizations as loop-invariant code motion, linear-scan register allocation, and inlining. Lastly, Google includes "deoptimization support" that identifies cases where the optimizing compiler has promised too much optimization. When this happens, the engine falls back on the base compiler. ®
It doesnt work that way. You cant just feed it all in to a compiler with optimization at max and expect to get good results. In dynamic environments the compiler just doesnt have enough information to make good optimizations straight away. Remember theres no type information. Profiling is not just about identifying parts of code that run often, but recording common code paths so the compiler can generate special-case code for them. For example it can notice that a particular call site always seems to go to one particular function, so it can inline the call. You cant determine that without running the code for a while first. What this crankshaft will do is compile a basic version initially, use that to profile, then "deopt" and recompile with the information it gained. Java's hotspot pioneered this.
Lars is a leading expert in the field. He knows what hes doing.
Why not just feed the whole damn thing into the optimizing compiler. It's not like webpages have the entire Windows codebase to build every time you reload the thing. It would take milliseconds at most to deep compile your average java source file, less time than it would take to download all the images used on the page.