Microsoft's secret weapon in browser wars: Mozilla's supercharged Asm.js

Native-speed JavaScript available now in Windows 10's Edge browser

Web browsers 2015

Microsoft has included a surprise feature in its new Edge web browser for Windows 10, in the form of support for the ultra-optimizable Asm.js JavaScript dialect.

First developed by Mozilla and championed by the nonprofit's former CTO Brendan Eich, Asm.js is a strict subset of JavaScript that aims to be the "assembly language of the web."

By eliminating many of the vagaries of the JavaScript language syntax, Asm.js forces client-side web code into a form that is easy for Just-In-Time compilers to parse and optimize.

In many cases, Asm.js code can be compiled into native binaries that execute as fast as code written in C or C++ – as evidenced by impressive 3D gaming demos like the one that was developed jointly by Mozilla and Unity earlier this year.

To gain the benefits, though, explicit support for Asm.js must be built into the browser. And while support is already present in Firefox and Chrome (albeit reluctantly), Microsoft hasn't said much about it until now.

In a Thursday blog post, Microsoft's Edge team said Asm.js support was one of the ten most requested features submitted to the Microsoft Edge Developer Suggestion Box. What's more, not only has Redmond listened, but experimental Asm.js support is already available in the version of Edge that shipped with the current version of the Windows 10 Technical Preview, Build 10074.

To enable it, all you need to do is enter "about:flags" into the URL bar and tick the box next to the relevant option under the browser's list of experimental features.

Screenshot showing the Asm.js option in Microsoft Edge browser

It's the box at the bottom

Microsoft said it has made a number of modifications to its Chakra JavaScript engine to support Asm.js, as illustrated by the green components of the pipeline in the diagram below:

Diagram showing the pipeline for Microsoft's Chakra JavaScript engine

Microsoft's Chakra JavaScript engine has been juiced up to support Asm.js

Among the new components is an Asm.js validator that ensures that code marked as being Asm.js actually complies with the spec. It also has a new generator that outputs Type Specialized bytecode, which takes advantage of the fact that Asm.js only supports architecture-native data types like integers, floats, and doubles to speed up execution. Chakra's JIT compiler has also been optimized to add extra acceleration Asm.js code that's output by the LLVM compiler backend.

The Edge team's blog post goes into more detail about how Chakra's new features help push the pedal to the metal when executing Asm.js code. Suffice it to say that Edge means to be fast. Microsoft says it already performs 300 per cent faster on the Unity Benchmark and 200 per cent faster on other benchmarks than it did before Asm.js support was enabled. To check it out, you can put the new browser through its paces on some 3D games and other demos.

The work isn't done, though, and Microsoft says it plans to gather more data from the preview builds of Edge to determine whether its current approach to Asm.js is working before enabling support by default.

Once it's satisfied, however, the plan is to enable Asm.js not only within Edge but also for HTML/JavaScript apps sold through the Windows Store, which target Windows 10's EdgeHTML rendering engine.

Microsoft is accepting feedback on Asm.js support and all things Edge on Twitter and its own Connect web forums. ®

Sponsored: From CDO to CEO

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER




Biting the hand that feeds IT © 1998–2019