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 5.1 Brings More ECMAScript Compliance, WASM Support

V8 JavaScript Engine 5.1 Brings More ECMAScript Compliance, WASM Support

Google has announced version 5.1 of its V8 JavaScript engine, which improves compliance with the ECMAScript 2017 draft specification and adds preliminary support for WASM, a low-level portable bytecode aimed to enable near-native execution speed.

As usual, the V8 release process is tied to Chrome’s, so V8 5.1 will be finally out when Chrome 51 Stable is released.

The final goal for this release is bringing ECMAScript 2015 support to 97%. To this aim, V8 5.1 includes:

  • Symbol.species, which allows subclasses to override the default constructor for objects that is used by methods such as Array.prototype.map. E.g., you could define a MyArray class that when used with map returns the case class constructor:
    class MyArray extends Array {
      // Overwrite species to the parent Array constructor
      static get [Symbol.species]() { return Array; }
    }
    var a = new MyArray(1,2,3);
    var mapped = a.map(x => x * x);
    
    console.log(mapped instanceof MyArray); // false
    console.log(mapped instanceof Array);   // true
    
  • Symbol.hasInstance, which can be overridden to determine if a constructor recognizes an object as its instance.
  • Iterators now support a close method which is called if the loop terminates early.
  • RegExp subclasses can define their own exec method to change the regular expression algorithm used.
  • Inferred function names are available through the name property.

V8 5.1 also brings preliminary support for WebAssembly (WASM). As briefly mentioned, WebAssembly is a low-level, portable bytecode that aims to enable execution at near-native speed by relying on common hardware capabilities that are available on many platforms. Additionally, WASM AST is designed to enable a compact and efficient binary format and meant to be executed in a sandboxed environment.

Finally, V8 5.1 improves performance of a number of JavaScript features, including executing loops like for-in, promise and RegExp instantiation, Math operations, and more.

Rate this Article

Adoption
Style

BT