JS engine V8 release version 7.6, do not ask, ask to improve performance

V8 JavaScript engine has released version 7.6, currently in beta, the official version will be released a few weeks later along with Chrome 76 Stable.

This version by the following features to enhance the performance improvements:

Improved JSON.parse

In modern applications, JavaScript, JSON format commonly used as a data transfer structure. By accelerating JSON parsing, communication delay can be reduced. With this release, JSON parser has been overhauled for faster scanning and parsing JSON, which makes data analysis speed popular page provides increased 2.7 times.

Before V8 v7.5, JSON parser is a recursive resolver that uses affect the incoming native nesting depth of stack space JSON data, which means you can run out of stack space in very deeply nested JSON data. V8 v7.6 turning it into an iterative parser , now manages its own stack, the stack is limited only by available memory.

On the other hand, the new JSON parsers are also more memory efficient, by buffering properties before creating the final object can now decide how to allocate the results in an optimal way.

Improved frozen / sealed array

Calls on the performance of frozen and sealed array (array-like objects as well) would be enhanced. This release enhances the JavaScript coding mode in which frozen is frozen or sealed array or array-like objects:

  • frozen.indexOf(v)
  • frozen.includes(v)
  • Transfer calls, such as fn(...frozen)
  • Nested arrays to spread using spread call, such as fn(...[...frozen])
  • Using arrays spread application calls, such as fn.apply(this, [...frozen])

As a result, huge improve performance, as shown below:

Unicode string processing

Optimization process to convert Unicode string to significantly increase the speed of String # localeCompare, String # normalize and a number Intl API calls and so on. For example, for single-byte character string, String # localeCompare raw throughput of about 2 times the original.

JavaScript language features, there is also the following update:

Promise.allSettled

Promise.allSettled(promises) 在所有输入 promise 处于 settled 状态时提供一个信号,这意味着它们要么被 fulfilled 要么被 rejected。

改进 BigInt 支持

BigInt 现在有更好的 API 支持,可以使用 toLocaleString 方法以区域设置感知方式格式化 BigInt。

12345678901234567890n.toLocaleString('en'); 
// → '12,345,678,901,234,567,890'
12345678901234567890n.toLocaleString('de'); 
// → '12.345.678.901.234.567.890'

改进 Intl.DateTimeFormat

应用通常显示日期间隔或日期范围以显示事件的范围,例如酒店预订、服务的计费周期或音乐节。Intl.DateTimeFormat API 现在支持 formatRange 和 formatRangeToParts 方法,以便以特定于语言环境的方式方便地格式化日期范围。

const start = new Date('2019-05-07T09:20:00');
// → 'May 7, 2019'
const end = new Date('2019-05-09T16:00:00');
// → 'May 9, 2019'
const fmt = new Intl.DateTimeFormat('en', {
  year: 'numeric',
  month: 'long',
  day: 'numeric',
});
const output = fmt.formatRange(start, end);
// → 'May 7 – 9, 2019'
const parts = fmt.formatRangeToParts(start, end);
// → [
// →   { 'type': 'month',   'value': 'May',  'source': 'shared' },
// →   { 'type': 'literal', 'value': ' ',    'source': 'shared' },
// →   { 'type': 'day',     'value': '7',    'source': 'startRange' },
// →   { 'type': 'literal', 'value': ' – ',  'source': 'shared' },
// →   { 'type': 'day',     'value': '9',    'source': 'endRange' },
// →   { 'type': 'literal', 'value': ', ',   'source': 'shared' },
// →   { 'type': 'year',    'value': '2019', 'source': 'shared' },
// → ]

此外,format、formatToParts 和 formatRangeToParts 方法现在支持新的 timeStyle 和 dateStyle 选项:

const dtf = new Intl.DateTimeFormat('de', {
  timeStyle: 'medium',
  dateStyle: 'short'
});
dtf.format(Date.now());
// → '19.06.19, 13:33:37'

原生堆栈遍历

虽然 V8 在 DevTools 中进行调试或分析等情况下可以使用自己的调用堆栈,但 Windows 操作系统无法在 x64 架构上遍历包含 TurboFan 生成的代码的调用堆栈。当使用原生调试器或 ETW 采样来分析使用 V8 的进程时,这可能会导致堆栈损坏。新版本 V8 能够为 Windows 注册必要的元数据,使得可以在 x64 上运行这些堆栈,v7.6 默认启用此功能。

详情查看:https://v8.dev/blog/v8-release-76

Guess you like

Origin www.oschina.net/news/107806/v8-release-76