Turboshaft: Replacing the Sea of Nodes in V8's Compiler

Introduction

For over a decade, V8's top-tier optimizing compiler, Turbofan, relied on a unique intermediate representation known as the Sea of Nodes (SoN). This graph-based approach, where instructions and data flow are intermingled, set V8 apart from most other production compilers. However, since 2021, the V8 team has been systematically replacing SoN with a more conventional Control-Flow Graph (CFG) based IR called Turboshaft. As of 2024, the entire JavaScript backend of Turbofan has transitioned to Turboshaft, and WebAssembly uses it throughout its pipeline. Only a few remnants of SoN remain: the builtin pipeline (being slowly replaced) and the frontend of the JavaScript pipeline (being replaced by Maglev, another CFG IR). This article explores the reasons behind this architectural shift.

Turboshaft: Replacing the Sea of Nodes in V8's Compiler
Source: v8.dev

The Path from Crankshaft to Turbofan and Sea of Nodes

Crankshaft's Limitations

Twelve years ago, in 2013, V8's only optimizing compiler was Crankshaft, which used a standard CFG IR. While it delivered significant performance improvements, it had several critical flaws:

Turbofan and the Adoption of Sea of Nodes

To overcome Crankshaft's limitations, V8 developed Turbofan, which adopted the Sea of Nodes representation. SoN elegantly combined data flow and control flow into a single graph, enabling more aggressive optimizations and flexible lowerings. It allowed operators to be reordered and control flow to be introduced later. This design solved many of Crankshaft's problems, including supporting try-catch and eliminating performance cliffs. SoN became the bedrock of V8's optimization pipeline for years.

Why Did V8 Abandon the Sea of Nodes?

Complexity and Maintenance Burden

Despite its theoretical elegance, SoN introduced significant complexity. The graph's structure made debugging, profiling, and reasoning about compiler passes much harder. Maintaining the compiler required deep expertise in SoN's intricacies, slowing down development. As V8 evolved, the team found that a CFG-based IR offered a better trade-off between expressiveness and maintainability.

Improved Compiler Architecture with Turboshaft

Turboshaft, the new CFG IR, was designed from the ground up to be simpler and more modular. It separates control flow and data flow, making passes easier to write and verify. This design reduces the risk of subtle bugs and enables faster iteration. The team reports that Turboshaft's structure leads to more predictable compilation and easier performance tuning.

Practical Benefits in Modern JavaScript

Modern JavaScript engines face evolving workloads, from web applications to WebAssembly. Turboshaft's CFG approach handles these workloads efficiently, especially for large functions and complex control flow. Benchmarks show that Turboshaft generates comparable or better code quality than SoN, while being simpler to maintain and extend.

Current Status of the Transition

Today, Turboshaft has fully replaced SoN in Turbofan's JavaScript backend. The WebAssembly pipeline also uses Turboshaft end-to-end. Two areas still rely on some SoN code: the builtin pipeline (gradually being migrated) and the JavaScript frontend (being replaced by Maglev, another CFG-based compiler). Maglev handles intermediate-tier optimization, reducing the load on Turbofan. Once these replacements are complete, Sea of Nodes will be completely phased out.

Conclusion

The shift from Sea of Nodes to Turboshaft marks a pragmatic evolution in V8's compiler design. While SoN was a groundbreaking innovation that solved many problems, its complexity eventually outweighed its benefits. Turboshaft provides a more maintainable, efficient, and developer-friendly foundation for future optimizations. This transition underscores the importance of balancing theoretical elegance with practical engineering realities in compiler development.

Recommended

Discover More

Dart and Flutter's AI Roadmap for 2026: Navigating Trust, Productivity, and the Agentic ShiftA Non-Programmer's Guide to Compiling C Programs from SourceA Beginner's Guide to Compiling C Programs from SourceEverything You Need to Know About watchOS 26.5: Stability Updates and MoreMaster Complex Systems with HASH: A Step-by-Step Simulation Guide