V8 release v4.6

Published · Tagged with release

Roughly every six weeks, we create a new branch of V8 as part of our release process. Each version is branched from V8’s Git master immediately before Chrome branches for a Chrome Beta milestone. Today we’re pleased to announce our newest branch, V8 version 4.6, which will be in beta until it is released in coordination with Chrome 46 Stable. V8 4.6 is filled with all sorts of developer-facing goodies, so we’d like to give you a preview of some of the highlights in anticipation of the release in several weeks.

Improved ECMAScript 2015 (ES6) support #

V8 v4.6 adds support for several ECMAScript 2015 (ES6) features.

Spread operator #

The spread operator makes it much more convenient to work with arrays. For example it makes imperative code obsolete when you simply want to merge arrays.

// Merging arrays
// Code without spread operator
const inner = [3, 4];
const merged = [0, 1, 2].concat(inner, [5]);

// Code with spread operator
const inner = [3, 4];
const merged = [0, 1, 2, ...inner, 5];

Another good use of the spread operator to replace apply:

// Function parameters stored in an array
// Code without spread operator
function myFunction(a, b, c) {
console.log(a);
console.log(b);
console.log(c);
}
const argsInArray = ['Hi ', 'Spread ', 'operator!'];
myFunction.apply(null, argsInArray);

// Code with spread operator
function myFunction (a,b,c) {
console.log(a);
console.log(b);
console.log(c);
}

const argsInArray = ['Hi ', 'Spread ', 'operator!'];
myFunction(...argsInArray);

new.target #

new.target is one of ES6's features designed to improve working with classes. Under the hood it’s actually an implicit parameter to every function. If a function is called with the keyword new, then the parameter holds a reference to the called function. If new is not used the parameter is undefined.

In practice, this means that you can use new.target to figure out whether a function was called normally or constructor-called via the new keyword.

function myFunction() {
if (new.target === undefined) {
throw 'Try out calling it with new.';
}
console.log('Works!');
}

// Breaks:
myFunction();

// Works:
const a = new myFunction();

When ES6 classes and inheritance are used, new.target inside the constructor of a super-class is bound to the derived constructor that was invoked with new. In particular, this gives super-classes access to the prototype of the derived class during construction.

Reduce the jank #

Jank can be a pain, especially when playing a game. Often, it's even worse when the game features multiple players. oortonline.gl is a WebGL benchmark that tests the limits of current browsers by rendering a complex 3D scene with particle effects and modern shader rendering. The V8 team set off in a quest to push the limits of Chrome’s performance in these environments. We’re not done yet, but the fruits of our efforts are already paying off. Chrome 46 shows incredible advances in oortonline.gl performance which you can see yourself below.

Some of the optimizations include:

The good thing is that all changes related to oortonline.gl are general improvements that potentially affect all users of applications that make heavy use of WebGL.

V8 API #

Please check out our summary of API changes. This document gets regularly updated a few weeks after each major release.

Developers with an active V8 checkout can use git checkout -b 4.6 -t branch-heads/4.6 to experiment with the new features in V8 v4.6. Alternatively you can subscribe to Chrome's Beta channel and try the new features out yourself soon.