BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google Proposes StrongMode and SoundScript, Boosting V8 Performance

Google Proposes StrongMode and SoundScript, Boosting V8 Performance

Bookmarks

In the ever-present JavaScript engine performance war, the team behind V8, the engine for Chrome, has announced plans to introduce two new virtual machine concepts: StrongMode and StrongScript.

StrongMode is an extension of ES5 strict mode that only allows features of JavaScript that have predictable performance. It is a subset of the JavaScript language that turns off parts that, while allowed, inhibit VMs from fully optimizing code.

For example, one proposed StrongMode restriction is that arrays cannot have holes. In a blog post describing SoundScript, Dr. Axel Rauschmayer says:

If arrays don’t have holes, their elements are stored as contiguous memory and [are] accessed via indices. If arrays do have holes, a map from indices to elements has to be used.

Thus, eliminating the possibility of array holes should improve performance. To use this mode, developers would declare at the top of their code:

use strong

JavaScript written to the StrongMode spec would still work in other browsers. Enabling StrongMode would allow V8 to perform additional optimizations and throw errors when the "bad parts" are used. This concerns Alon Zakai, a researcher at Mozilla and head of Emscripten:

This worries me. If it's running "correctly", then sure, it will run elsewhere. But if it hits something that Strong Mode considers "incorrect", then things diverge, and other browsers will execute something different. This can be avoided if Strong Mode just issues warnings, not errors. Which seems sufficient, if the goal is to inform people about stuff they should optimize.

In a related move that has potential to be a major change for JavaScript, SoundScript aims to add user-facing types to run-time JavaScript. One of the JavaScript's featuresis its dynamic type system. However, as apps have increased in size, external typing systems, like TypeScript, have sprung up to fill a need.

In fact, SoundScript will base its implementation on TypeScript and intends to "stay as close to TypeScript as possible." The V8 team says that having types available in the VM will allow it to "use type information for early and aggressive optimisations."

In a discussion on Hacker News, Brendan Eich, the creator of JavaScript, hopes that Chrome will do the right thing with these proposals:

V8 folks promise to work with TC39 on semantics and open source the code, which helps. ... Worst case, this turns into another Chrome-only power play. But all signs suggest otherwise, so far.

Google describes StrongMode and SoundScript as experiments, but there is a long way to go before these or advances like them make their way into a standard. TC39, the standards body in charge of ECMAScript, requires proposals such as SoundScript to have implementations in use before they can become standards.

Developers are encouraged to read the StrongMode proposal and can play with StrongMode by running Chrome canary using the command line and adding the flag

--js-flags="--strong-mode"

.

 

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT