V8 release v7.7

发布时间: · 标签: release

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 a Chrome Beta milestone. Today we’re pleased to announce our newest branch, V8 version 7.7, which is in beta until its release in coordination with Chrome 77 Stable in several weeks. V8 v7.7 is filled with all sorts of developer-facing goodies. This post provides a preview of some of the highlights in anticipation of the release.

Performance (size & speed)

Lazy feedback allocation

In order to optimize JavaScript, V8 collects feedback about the types of operands which are passed to various operations (e.g. + or o.foo). This feedback is used to optimize these operations by tailoring them to those specific types. This information is stored in “feedback vectors”, and while this information is very important to achieve faster execution times, we also pay a cost for the memory usage required to allocate these feedback vectors.

To reduce V8’s memory usage, we now allocate the feedback vectors lazily only after the function has executed a certain amount of bytecode. This avoids allocating feedback vectors for short-lived functions that don’t benefit from the feedback collected. Our lab experiments show that lazily allocating feedback vectors saves about 2–8% of V8 heap size.

Our experiments from the wild show that this reduces V8’s heap size by 1–2% on desktop and 5–6% on mobile platforms for the users of Chrome. There are no performance regressions on desktop, and on mobile platforms we actually saw a performance improvement on low-end phones with limited memory. Please look out for a more detailed blog post on our recent work to save memory.

Scalable WebAssembly background compilation

Over the last milestones, we worked on scalability of background compilation of WebAssembly. The more cores your computer has, the more you benefit from this effort. The graphs below have been created on a 24-core Xeon machine, compiling the Epic ZenGarden demo. Depending on the number of threads used, compilation takes less than half of the time compared to V8 v7.4.

Stack trace improvements

Almost all errors thrown by V8 capture a stack trace when they are created. This stack trace can be accessed from JavaScript through the non-standard error.stack property. The first time a stack trace is retrieved via error.stack, V8 serializes the underlying structured stack trace into a string. This serialized stack trace is kept around to speed up future error.stack accesses.

Over the last few versions we worked on some internal refactorings to the stack trace logic (tracking bug), simplifying the code and improving stack trace serialization performance by up to 30%.

JavaScript language features

The Intl.NumberFormat API for locale-aware number formatting gains new functionality in this release! It now supports compact notation, scientific notation, engineering notation, sign display, and units of measurement.

const formatter = new Intl.NumberFormat('en', {
style: 'unit',
unit: 'meter-per-second',
});
formatter.format(299792458);
// → '299,792,458 m/s'

Refer to our feature explainer for more details.

V8 API

Please use git log branch-heads/7.6..branch-heads/7.7 include/v8.h to get a list of the API changes.

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