BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News V8 JavaScript Engine 9.0 Improves JavaScript to WebAssembly Performance

V8 JavaScript Engine 9.0 Improves JavaScript to WebAssembly Performance

This item in japanese

The 9.0 release of the V8 JavaScript engine, powering Chrome and Chromium-based browsers, improves the performance of making WebAssembly calls from JavaScript, adds regular expression match indices, and speeds up super property access.

When making calls to WebAssembly from JavaScript, there are performance penalties compared to invoking JavaScript code from JavaScript. As explained in the V8 release announcement:

V8 uses different representations for the parameters of WebAssembly and JavaScript functions. For this reason, when JavaScript calls an exported WebAssembly function, the call goes through a so-called JS-to-Wasm wrapper, responsible for adapting parameters from JavaScript land to WebAssembly land as well as adapting results in the opposite direction.

The wrapper call can now get inlined at the call site to minimize the performance overhead of the JavaScript to WebAssembly wrapper. Using this experimental --turbo-inline-js-wasm-calls flag, performance benchmarks show typical calls completing within approximately one-third of the time without the inline wrapper. Additional details are available in the Faster js-to-wasm calls design document.

The stage 3 TC39 RegExp match indices proposal introduces more information on regular expression match objects, recording where each captured group starts and ends. For example,

const matchObject = /(i+)(q+)/.exec('iiinfoqqqq');
assert.equal(
  matchObject[1], 'iii');
assert.equal(
  matchObject[2], 'qqqq');

 

Match indices provides the start and end indices of the match, via matchObject.indices:

assert.deepEqual(
  matchObject.indices[1], [0, 3]);
assert.deepEqual(
  matchObject.indices[2], [6, 10]);

 

With V8's support for match indices, this feature will be available starting with Chrome 90. The feature is also expected soon for Firefox and Safari, currently supported in nightly releases.

Accessing super properties is now optimized by V8’s inline cache system and optimized code generation with TurboFan. Super property access was previously about 20X slower than regular property access and is now comparable in performance. Super fast super property access provides more information on how this performance benefit was achieved within V8.

V8 gets updated every six weeks, and powers JavaScript for Chrome browsers, Node.js, Electron, Deno, and more. V8 is open source software with several applicable licenses to subsets of the codebase due to external dependencies. Contributions are welcome via the V8 Git project and should follow V8's contribution guidelines and Google's open source conduct guidelines.

Rate this Article

Adoption
Style

BT