What's included in the release of the V8 engine version 9.0

On March 17, 2021, the release of the ninth version of the V8 engine was published. This post is a short description of what was included in the release changelog.





Original post V8 release v9.0





JavaScript

Match indices in RegExp

Since version 9.0, developers can get an array of start and end positions that match the capture groups that match a regular expression. This array is available through a property .indices



for matching objects if the regex has a flag / d



.





const re = /(a)(b)/d;      // Note the /d flag.
const m = re.exec('ab');
console.log(m.indices[0]); // Index 0 is the whole match.
// → [0, 2]
console.log(m.indices[1]); // Index 1 is the 1st capture group.
// → [0, 1]
console.log(m.indices[2]); // Index 2 is the 2nd capture group.
// → [1, 2]
      
      







super

super



(, super.x



) V8 TurboFan. , super



, , , .









"for ( async of "

V8 v9.0, . for ( async of



.





WebAssembly

JS-to-Wasm

V8 WebAssembly JavaScript. , JavaScript WebAssembly, JS-to-Wasm, JavaScript WebAssembly, , .





, , , JavaScript WebAssembly , JavaScript JavaScript. , JS-to-Wasm ., .





, WebAssembly, , :





double addNumbers(double x, double y) {
  return x + y;
}
      
      



and for example, we call this function in JavaScript to add multiple vectors (represented as typed arrays):





const addNumbers = instance.exports.addNumbers;

function vectorSum(len, v1, v2) {
  const result = new Float64Array(len);
  for (let i = 0; i < len; i++) {
    result[i] = addNumbers(v1[i], v2[i]);
  }
  return result;
}

const N = 100_000_000;
const v1 = new Float64Array(N);
const v2 = new Float64Array(N);
for (let i = 0; i < N; i++) {
  v1[i] = Math.random();
  v2[i] = Math.random();
}

// Warm up.
for (let i = 0; i < 5; i++) {
  vectorSum(N, v1, v2);
}

// Measure.
console.time();
const result = vectorSum(N, v1, v2);
console.timeEnd();
      
      



This feature is still experimental and can be enabled with a flag --turbo-inline-js-wasm-calls



.





See the design document for details .








All Articles