Navigating Away from the Sea of Nodes: V8's Shift to Turboshaft

By ✦ min read

Introduction

For over a decade, V8's optimizing compiler Turbofan relied on a distinctive intermediate representation known as the Sea of Nodes (SoN). This graph-based approach set V8 apart from most production compilers, which typically use a control-flow graph (CFG). However, starting around 2021, the V8 team began a gradual migration away from SoN toward a more traditional CFG-based IR called Turboshaft. Today, the entire JavaScript backend of Turbofan has adopted Turboshaft, and WebAssembly uses it throughout its entire pipeline. Only two parts of Turbofan still retain some Sea of Nodes: the builtin pipeline (being slowly replaced) and the JavaScript frontend (being replaced by Maglev, another CFG-based IR). This article explores the motivations behind this strategic shift.

Navigating Away from the Sea of Nodes: V8's Shift to Turboshaft
Source: v8.dev

The Origins of Turbofan and Sea of Nodes

Twelve years ago, in 2013, V8 had a single optimizing compiler: Crankshaft. Crankshaft used a CFG-based IR and delivered significant performance improvements despite its limitations. Over time, the team enhanced Crankshaft to generate faster code in more scenarios, but technical debt accumulated and several critical issues emerged.

Challenges with Crankshaft

Why Sea of Nodes Was Chosen for Turbofan

To overcome these limitations, the V8 team designed Turbofan with a Sea of Nodes IR. SoN allowed flexible operation reordering, easy introduction of new control flow during lowering, and better support for speculative optimizations. It was a bold choice that addressed many of Crankshaft’s weaknesses—at the cost of significant complexity.

The Decision to Move Away

Despite its strengths, the Sea of Nodes introduced its own set of challenges over the years. The team realized that a more conventional CFG-based IR could offer better maintainability, performance, and developer productivity.

Complexity and Maintenance

Sea of Nodes is inherently more complex than a CFG. The graph structure makes debugging, optimization passes, and code generation harder to reason about. New team members faced a steep learning curve, and the specialized knowledge required slowed down development. Turboshaft, with its explicit control flow, is easier to understand, modify, and extend.

Performance and Deoptimization Issues

While SoN enabled aggressive optimizations, it also made deoptimization handling more intricate. The free-form graph could lead to subtle bugs and performance regressions when speculative assumptions failed. Turboshaft simplifies deoptimization by tying state to specific control flow points, reducing the risk of deoptimization loops and making bailout mechanics more predictable.

Limitations in Lowering and Control Flow

Although SoN allowed introducing control flow during lowering, managing this flexibility at scale proved challenging. The graph could become cluttered with nodes that represented both data and control dependencies, making it harder to optimize. Turboshaft separates data flow from control flow, mimicking modern compiler architectures that have proven effective in other projects like LLVM and SpiderMonkey.

The Turboshaft Solution

Turboshaft is a clean-slate IR designed for clarity and performance. It uses a control-flow graph with basic blocks, explicit phi nodes, and a more traditional instruction selection pipeline.

Benefits of a Control-Flow Graph

Current Status and Future

As of now, Turboshaft powers all JavaScript optimization in Turbofan's backend, and WebAssembly uses it end-to-end. The builtin pipeline is partially converted, and the JavaScript frontend is being phased out in favor of Maglev. The V8 team expects to fully retire Sea of Nodes once these remaining parts are replaced. This migration demonstrates that even well-established compiler designs can evolve to meet new demands for maintainability and performance.

Conclusion

V8’s transition from the Sea of Nodes to Turboshaft represents a pragmatic return to a more conventional compiler architecture. While SoN served V8 well for years, the advantages of a CFG—simplicity, debuggability, and ease of maintenance—ultimately won out. This move has already improved developer experience and code quality, and it sets the stage for future optimizations in V8. The story underscores that in compiler engineering, the best design is often the one that balances innovation with practical long-term sustainability.

Tags:

Recommended

Discover More

Cloudflare IPsec Now Supports Post-Quantum Encryption: What You Need to KnowThe Importance of Accuracy in Cybersecurity Journalism: A Case Study of the Instructure Retraction10 Key Takeaways from Evan Blass's Departure: The End of an Era in Smartphone LeaksIndustrial Automation Under Siege: Worms Surge in Q4 2025 Email AttacksSafari Technology Preview 237: Accessibility and CSS Enhancements Lead the Way