Sunday, April 1, 2018

What’s new in Google’s V8 JavaScript engine Version 6.6

The V8 Version 6.6 beta focuses on JavaScript language features and code-caching capabilities

A new beta of Google’s V8 JavaScript engine is now available.

V8 is a staple in both the Chrome browser and the Node.js JavaScript runtime. WebAsembly is also supported in Mozilla Firefox, Apple Safari, and Microsoft Edge, though those browsers do not use V8.

The beta Version 6.6 of Google’s V8 JavaScript engine focuses on JavaScript language features and code-caching capabilities.

For JavaScript, Function.prototype.toString() returns exact slices of source code text, including whitespace and comments. V8 Version 6.6 also implements String.prototype.trimStart() and String.prototype.trimEnd(). This capability had been available through nonstandard trimLeft() and trimRight() methods, which remain as aliases of the new methods to enable backward compatibility.

Additionally, line and paragraph separator symbols can be used in string literals, thus matching JSON. Previously, these had been treated as line terminators in string literals and their usage resulted in a SyntaxError exception.

The Array.prototype.values method gives arrays the same iteration interface as the ECMAScript 2015 Map and Set collections. These can be interacted over by keys, values, or entries by calling the same-named method. This change could be incompatible with existing JavaScript code; developers who find odd or broken behavior on a website can try to disable this feature via chrome://flags/#enable-array-prototype-values.

In another JavaScript programming improvement, the catch clause of try statements can be used without a parameter, which is useful if there is no need for an exception object in the code handling the exception.

Aside from JavaScript, a code cache after execution capability in Version 6.6 lets more functions be included in the cache, with functions no longer needing to be compiled on future page loads. Compile and parse times in hot load scenarios—in which Chrome visits a page for the third time and provides code previous cached—are reduced. As a result, loading is faster and smoother.

Other capabilities featured in V8 Version 6.6 include:

  • More mitigations to prevent information leaks to untrusted JavaScript and web assembly code.
  • Compile times have been improved by moving out or deprecation of remaining functionality related to AST numbering. A previous compilation process had required a post-parsing stage dubbed AST numbering, where nodes in a syntax tree were numbered so compilers using it would have a common point of reference. But this postprocessing pass had ballooned to include other functionality. A new pipeline introduced last year eliminated the need for the numbering, but the numbering pass had remained until Version 6.6.
  • Asynchronous and array performance has been improved.

Where to download the V8 Version 6.6 beta

Developers with an active V8 checkout capability can use git checkout -b 6.6 -t branch-heads/6.6 to experiment with the features in V8 Version 6.6. You can also subscribe to the Google Chrome beta channel to try out new features.

Current version: New features in V8 Version 6.5

Released in February 2018, in V8 Version 6.5’s streaming compilation, WebAssembly modules are compiled while module bytes are still being downloaded. When all bytes of a single function has been downloaded, the function is passed to a background thread for compilation. As a result, WebAssembly compilation in Chrome 65 can maintain a 50Mbps download speed on high-end machines, Google says—meaning that if web assembly is downloaded at that speed, compilation finishes as soon as the download is done.

Other improvements planned for the 6.5 branch include:

An untrusted code mode, developed in response to a speculative side-channel Spectre attack. This mode is suitable for applications processing user-generated, untrusted code and is enabled by default.

A mechanism to detect and prevent a deoptimization loop. This loop occurs when optimized code deoptimizes and there is no way to find out what went wrong. V8 developers also have inlined many JavaScript builtins that had been excluded because of a side effect between the load of a function to call and the call itself.

Where to download the V8 Version 6.5 branch
You can download the V8 Version 6.5 branch from Google’s Git repo.

No comments:

Post a Comment