3 ms·
I tested a sea of nodes representation on my toy compiler project and was unimpressed. The gist is that instead of having two graphs (one for operations, one fo
by pubby 6y ago
I tested a sea of nodes representation on my toy compiler project and was unimpressed. The gist is that instead of having two graphs (one for operations, one for control flow), you just have one... but no wait you actually have to convert back into a two-graph format eventually so you don't save any lines of code at all. It makes a few algorithms slightly prettier, but most code is made worse and slower, and when you start trying to rectify the disadvantages you realize you're just doing the two-graph thing in a roundabout way and that the sea-of-nodes is a oversold meme.
Also, I remember reading an anecdote by the V8 team where they had regrets in choosing the sea of nodes representation over a more traditional 2-graph IR, but I can't find a link.
- sebmellen 6y agoThe V8 blog mentions using a sea-of-nodes representation here: https://v8.dev/blog/turbofan-jit#more-sophisticated-optimizations https://v8.dev/blog/turbofan-jit#more-sophisticated-optimiza..., though they don't say anything bad about it: > The TurboFan JIT implements more aggressive optimizations than CrankShaft through a number of advanced techniques. JavaScript enters the compiler pipeline in a mostly unoptimized form and is translated and optimized to progressively lower forms until machine code is generated. The centerpiece of the design is a more relaxed sea-of-nodes internal representation (IR) of the code which allows more effective reordering and optimization.