I'm doing some research on the turbofan of the V8, and I've got a few questions about Turbofan IR:
+) Is there any document that describes the semantics of the Turbofan IR? I've found out that this IR originates from Sea-of-Node(by Cliff Click), and so gained some hints from his papers. However, the IR of the turbofan seems to be a little different from the original. For example, there is no effect edge at the original Sea-of-Node. So if there is any document explaining the Turbofan IR, it would be really helpful.
Thanks.
console.log(1);
console.log(2);
the compiler must not reorder the two calls, because that would change the program's behavior, and that's not something compilers are allowed to do (for obvious reasons).
Non-observable instructions can be reordered in any way the compiler wants. For example, 1 + x + 2
could be reordered to x + 1 + 2
and then simplified to x + 3
.
(Note that this has nothing to do with Turbofan (or even JavaScript), it's a general statement that applies to all compilers for all languages.)
Turbofan uses "effect" edges between Nodes to ensure that the observable order of operations is always preserved.
That would be a bug.
You can find some documentation here: https://v8.dev/docs/turbofan