DEV Community

Cover image for Top 8 Recent V8 Updates
Antonello Zanini for AppSignal

Posted on • Originally published at blog.appsignal.com

Top 8 Recent V8 Updates

V8 is the most popular JavaScript engine on the planet, supporting technologies such as Chrome and Node.js. The pace of V8's development is impressive, with multiple code commits a day and major releases roughly every month.

Keeping up with updates isn't easy, but you've come to the right place! Here, we'll dig into the latest improvements and additions Google has made to the JavaScript engine.

Find out what the future of web development looks like!

What Is V8?

V8 is a high-performance JavaScript engine developed by Google. Its purpose is to convert JavaScript code into machine code for execution by the underlying hardware. Primarily developed by the V8 team at Google, the engine focuses on speed and efficiency. In particular, it relies on just-in-time compilation and uses inline caching for high performance.

Thanks to V8, Chromium-based browsers and Node.js can run JavaScript code. Deno also relies on it for executing JavaScript, making V8 a major element in modern software development.

V8 JavaScript Engine: Latest Updates

As you can tell from the V8 repository, development is fast-paced, with several commits within the same day. This means that bug fixes, enhancements, and new features are introduced daily.

Top Recent V8 Updates

Time to find out the top 8 recent V8 updates of the past few months!

1. New JavaScript Features

JavaScript continues to evolve to meet the demands of modern development. New standardized features are frequently added to the language, and JavaScript engines must implement them.

In the latest iterations, V8 has added support for:

  • toWellFormed() string method: Returns a string where all lone surrogates are replaced with the Unicode replacement character U+FFFD.
  • isWellFormed() string method: Returns a boolean to indicate whether the string contains any lone surrogates.
  • Resizable ArrayBuffers: The ArrayBuffer() constructor now accepts the maxByteLength to define its maximum size in bytes. You can then assign a new size to a resizable ArrayBuffer object with the resize() method. This makes ArrayBuffers more efficient and closer to WebAssembly.
  • ArrayBuffer transfer: ArrayBuffer objects can now be transferred between different execution contexts via the structured clone algorithm.
  • RegExp v flag: A new mode that unlocks support for extended character classes, such as all valid emojis.
  • Object.groupBy() static method for Arrays: To group the elements of a given iterable according to the given callback function.
  • Array.fromAsync() static method: Creates a new, shallow-copied Array instance from an async iterable, iterable, or array-like object.
  • Promise.withResolvers() static method: Returns an object containing a new Promise object and two functions to resolve or reject it.

Plus, dynamic import() has been updated to accept a with option to specify import attributes:

const jsonModule = await import("./data.json", {
  // specify some extra attributes with through
  // the "with" object
  with: { type: "json" },
});
Enter fullscreen mode Exit fullscreen mode

2. Support for Compilation to WebAssembly of Garbage Collected Languages

WasmGC, short for WebAssembly Garbage Collection, represents a pivotal advancement in the realm of WebAssembly (Wasm). Its goal is the compilation of garbage-collected (GC) languages down to WasmGC constructs to make them run on the web.

After several years of work, WasmGC is finally ready.

Wasm now has a built-in way to allocate objects and arrays that are managed by the V8 garbage collector.

This enables compiling applications written in Java, Kotlin, Dart, Python, C#, and similar garbage-collected languages to Wasm.

That's a huge leap toward bringing GC languages efficiently to the web!

3. A Brand New Optimizing Compiler

The recent V8 update has introduced a brand-new optimizing compiler called Maglev. This solution sits between the Sparkplug non-optimizing JavaScript compiler and the TurboFan top-tier optimizing compiler.

Maglev falls somewhere between these two as a high-speed optimizing compiler. It can generate code nearly 20 times slower than Sparkplug, but 10 to 100 times faster than TurboFan.

Thanks to Maglev, the team behind V8 has noticed the following performance improvements on JavaScript and WebAssembly benchmark sites:

  • +8.2% on JetStream
  • +6% on Speedometer

For more information, read Maglev — V8’s Fastest Optimizing JIT.

4. A New Architecture for the Optimizing Compiler Turbofan

Maglev is not the only investment the development team has made in compiler technologies. The latest V8 updates have also introduced Turboshaft, a new internal architecture for the high-level optimizing compiler Turbofan.

This new, modern, better-engineered architecture makes Turbofan easier to extend with new optimizations and faster compilation.

In fact, compilation times are twice as fast in certain situations.

That also leads to power savings, paving the way for other performance gains in the future.

5. Improved Security with Control-flow Integrity

CFI, short for Control-flow Integrity, is a vital security feature designed to thwart exploits aimed at hijacking the control flow of a program.

By applying strict controls on how control flow instructions are executed, CFI prevents attackers from exploiting memory corruption vulnerabilities to execute arbitrary code. Thus, even if an attacker succeeds in corrupting the memory of a process, CFI prevents them from executing unauthorized instructions.

The adoption of CFI in V8 brings several benefits to the security landscape, significantly reducing the risk of successfully exploiting memory corruption vulnerabilities. These are usually the primary targets of attackers trying to gain control of a system.

By applying integrity checks to both forward and reverse control flow transfers, CFI decreases the possibility of attackers manipulating program execution to execute malicious code.

6. A Faster HTML Parser and DOM Allocation

In the pursuit of optimizing web performance, recent V8 updates have introduced significant improvements to both HTML parsing and DOM allocation.

A significant portion of time in a performance benchmark is spent parsing HTML.

Even though it's not a direct enhancement to V8, the team decided to apply their expertise in performance optimization to add a faster HTML parser to Blink.

If you aren't familiar with it, Blink is the rendering engine used by Chromium and is based on the WebCore component of WebKit.

These changes resulted in a notable 3.4% increase in the Speedometer scores.

Other optimizations have been applied to DOM memory allocation strategies within Oilpan — the V8 allocator for DOM objects.

By introducing a page pool mechanism and supporting compressed and uncompressed pointers, kernel round-trip costs have been greatly reduced.

Moreover, by avoiding compression for high-traffic fields, allocation workloads have become 3x faster.

These updates have led to significant improvements in DOM-heavy benchmarks, providing a smoother and more responsive browsing experience.

7. New WebAssembly Features

Just as with JavaScript, new features are continually added to Wasm. The main recent updates have been:

8. Memory Handling Optimizations Through Compile-Time Constant Addresses

Finally, V8 recently introduced a revolutionary improvement in memory management. This new feature is called static roots and aims to optimize the way basic JavaScript objects — such as undefined and true — are managed in memory. By assigning fixed memory addresses to these objects at compile time, V8 eliminates the need to look up addresses at runtime for a significant performance boost.

Thanks to static roots, access to commonly used objects becomes lightning fast. That's because V8 can now accurately predict their memory addresses at compile time. Not only does this optimization speed up code execution, but it also improves the performance of built-in C++ functions.

What Do These V8 Engine Updates Bring to the Table?

Most of the recent V8 updates aim for the same results: to improve performance and security.

As mentioned on the official V8 site, its performance improvements over a single year have been impressive, with an overall growth of 14% on JetStream and an astounding 34% on Speedometer.

This means that V8 is faster and more secure than ever. The possibility of running Python and Java on the web thanks to WasmGC is clearly huge. We will see how the web developer community reacts to this great news!

Wrapping Up

In this blog post, we took a look at what V8 is and dug into the recent updates made to the popular JavaScript engine.

You now know:

  • The top 8 recent V8 updates, including the new compilers available
  • Why V8 is faster and more secure than ever

Thanks for reading!

P.S. If you liked this post, subscribe to our JavaScript Sorcery list for a monthly deep dive into more magical JavaScript tips and tricks.

P.P.S. If you need an APM for your Node.js app, go and check out the AppSignal APM for Node.js.

Top comments (0)