The Register® — Biting the hand that feeds IT

Feeds

Google 'Crankshaft' inspired by Sun Java HotSpot

Bak to 'adaptive compilation'

Agentless Backup is Not a Myth

Google's new "Crankshaft" JavaScript engine was inspired at least in part by Sun's Java Hotspot performance engine, the reengineered Java virtual machine that Sun released in 1999.

A number of developers who built Crankshaft, including Danish programmer Lars Bak, also worked on HotSpot. Bak led the HotSpot team at Sun, and he's one of the founders of Google's V8 JavaScript engine.

Crankshaft is similar to Mozilla's TraceMonkey-JagerMonkey JavaScript engine setup in that it seeks to optimize certain pieces of code. "At a simple level, they both do dynamic optimization. There's one version of the code that gets 'hot,' gets important, and they take a deeper pass on that code," Google engineer Eric Kay said this morning at the annual Add-on-Con browser conference in Mountain View, California, when we asked about the Crankshaft design and how it compares to Mozilla's engine.

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. ®

Regcast training : Hyper-V 3.0, VM high availability and disaster recovery

Re: *Sigh*

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.

1
0

*Sigh*

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.

1
0
Anonymous Coward

re: rhino

No, the real hotspot is a virtual machine, originally created for java, but which can be used for a number of languages like python and ruby. Rhino (see title) is a javascript implementation on top of the JVM hosted on mozilla.org. JSR 292 is meant to help with languages like javascript on the JVM.

0
0

More from The Register

Bjarne Again: Hallelujah for C++
Plus: Now officially OK to admit you never used STL algorithms
Interwebs taunt Sir Jony over Apple eye candy makeover
Hey Ive, Ive... add more unicorns, willya?
SCO vs. IBM battle resumes over ownership of Unix
Zombie lawsuit back and wants to suck the brains out of Linux
Apple: iOS7 dayglo Barbie makeover is UNFINISHED - report
Plus: You don't like the icons? Blame marketing
Red Hat to ditch MySQL for MariaDB in RHEL 7
So long, Oracle! Don't let the door hit you on the way out
Shy? Socially inadequate? Fiddling with your phone could help
App 'tells the brutal truth' about social inadequates' chatup lines
Java EE 7 melds HTML5 with enterprise apps
New release arrives with GlassFish, NetBeans support
 breaking news
'Office Facebook' firm Tibbr wants you to PAY for mobe-meetings app
Great idea. Punters won't cough for it though
 breaking news
The only Waze is Google: Ad giant tipped to gobble map app 'for $1.3bn'
Pac-Man-satnav-ish upstart in bidding war with Apple, Facebook
 breaking news
PM Cameron calls for modern, programmable computers! (We think)
IT education musings to G8 chiefs to mystify IT industry