Saturday, 21 December 2013

Mozilla’s Asm.js Gets Another Step Closer To Native Performance

Mozilla’s Asm.js Gets Another Step Closer To Native Performance
Dec 21st 2013, 18:30, by Frederic Lardinois
aurora_rocket
Mozilla’s asm.js is a strict subset of JavaScript that Firefox can run significantly faster than regular JavaScript code. Thanks to the so-called OdinMonkeymodule for Firefox’s built-in JavaScript engine, asm.js code was running at about 2x native speed in Marchand this week, the organizationannounced that it’s now running most benchmarks at just 1.5x slower than native or better.
While Google is betting on Native Client to allow web apps to execute native compiled code in the browser, Mozilla is betting on its ability to run JavaScript at near-native speeds, too. While they approach this problem from very different angles, both Google, through Native Client, and Mozilla, through its Emscripten LLVM-to-JavaScript compiler, allow developers to write their code in C or C++ and then run it in the browser.
Given that most game engines are written in C or C++, the focus for asm.js has mostly been on gaming too. Indeed, one of the first public asm.js demos Mozilla showed was Epic’s Unreal Engine 3running natively in the browser.

As Mozilla’s Alon Zakai and Robert Nyman note in the most recent announcement, the team manged to get to 1.5x performance through a number of small, incremental changes to both asm.js and the Emscripten compiler. The team, however, also profited from some general improvements to Firefox’s JavaScript engine. Specifically,  Zakai and Nyman note, the fact that Firefox has now been optimized for some floating-point operations resulted in “substantial speedups.”
Mozilla measures asm.js performance by compiling the code natively (using clang and gcc) and comparing the results to running the same code through Emscripten and asm.js.
Here are the most current results:
asm1.5b
For the time being, asm.js remains a Mozilla project. While Google’s Chrome team is clearly aware of it and recently added it to its Octane benchmark, it seems unlikely that Chrome will support it natively anytime soon. It’s worth noting, though, that asm.js code will run in any current JavaScript engine – it just won’t run as fast as on Firefox.

No comments:

Post a Comment