by tsegratis · 2y ago · 0 comments
Meaning some control flows are unrepresentable and certainly less compact; since they must be 'interpreted'
I think that's probably the best decision for quick webpage loading, but given that WASM is generally used for code heavy webpages -- not quick jquery replacements, I'm not convinced it was the best decision overall
-- I love a lot of wasm, I just wish it was a better target for open ended computation; which is something gotos and coroutines are better suited for
That said; WASM is a clever trade off; but the trade-off is hidden within compilers (ref Go's wasm for instance)
https://en.m.wikipedia.org/wiki/Structured_program_theorem
Rather, I think the trade off was more in the realm of “aggressively optimize for what the web does well”.
With that being said, I do wish it was better suited for general purpose computation.
What's the problem with multiple entry points anyway? If we're not using computed goto, or dynamically verifying it when we do, aren't all of our jump targets known, and so inherently safe?
What am i missing?
EDIT: is it just a question of speed of jit for register allocation / dominance frontiers?? But the verifier is providing safety right??
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.