Latest Revision to ARM Instruction Set Includes Optimizations Just for JavaScript

Greg Parker:

More precisely: ARMv8.3 adds a new float-to-int instruction with errors and out-of-range values handled the way that JavaScript wants. The previous [instructions] to get JavaScript’s semantics were much slower. JavaScript’s numbers are double by default so it needs this conversion a lot.

Back when the iPhone XS first shipped, people noticed that it performed seemingly impossibly well on JavaScript benchmarks. E.g., David Heinemeier Hansson:

The iPhone XS is faster than an iMac Pro on the Speedometer 2.0 JavaScript benchmark. It’s the fastest device I’ve ever tested. Insane 45% jump over the iPhone 8/X chip. How does Apple do it?!

Apple touts the new A12 as “only” 15 percent faster than the A11 at CPU tasks, and JavaScript is mostly (entirely?) CPU-bound. These new instructions make that big a difference. The iMac Pro is a professional desktop and it’s getting beaten by a phone. [Update: Turns out JavaScriptCore (Safari’s JavaScript engine) doesn’t use this new instruction yet — it should make things even faster once it does but the A12 chip is getting these benchmark scores without this new instruction’s help.]

Everyone can enjoy the fact that ARMv8.3 makes JavaScript faster. Comp sci nerds can further enjoy the fact that we now have CPUs being optimized for a specific weird programming language and not the other way around.

Thursday, 11 October 2018