4 ms·
Sure, you can still have safe code with irreducible loops. Safety is orthogonal. There is a proposal to add "multi-loop" (https://gist.github.com/conrad-watt/6a
by titzer 3y ago
Sure, you can still have safe code with irreducible loops. Safety is orthogonal. There is a proposal to add "multi-loop" (https://gist.github.com/conrad-watt/6a620cb8b7d8f0191296e3eb24dffdef https://gist.github.com/conrad-watt/6a620cb8b7d8f0191296e3eb...) to Wasm, but it hasn't been a high priority.
Of all the Wasm JITs I know of, none of the Web engine's optimizing compilers can handle irreducible control flow in their backends. Their register allocators and codegen algorithms would need to be modified. I worked on TurboFan, and several parts of it would choke on irreducible control flow. It's likely these engines would fall back to baseline compilation for such functions, which is a bigger perf impact than using state variables.