Tue. Nov 12th, 2019

V8 JavaScript Engine v7.7 releases: Google’s open source high-performance JavaScript engine

2 min read

V8 compiles and executes JavaScript source code, handles memory allocation for objects, and garbage collects objects it no longer needs. V8’s stop-the-world, generational, accurate garbage collector is one of the keys to V8’s performance. You can learn about this and other performance aspects in V8 Design Elements.

JavaScript is most commonly used for client-side scripting in a browser, being used to manipulate Document Object Model (DOM) objects for example. The DOM is not, however, typically provided by the JavaScript engine but instead by a browser. The same is true of V8—Google Chrome provides the DOM. V8 does however provide all the data types, operators, objects and functions specified in the ECMA standard.

V8 enables any C++ application to expose its own objects and functions to JavaScript code. It’s up to you to decide on the objects and functions you would like to expose to JavaScript. There are many examples of applications that do this, for example: Adobe Flash and the Dashboard Widgets in Apple’s Mac OS X and Yahoo! Widgets.

Image: slideshare

V8 v7.7 is now officially available.


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.

For full updates, please read the release notes here.