Cmm_of_wasm: From WebAssembly to Native Code via the OCaml Back End
simonjf.com
simonjf.com
But there are actually use cases to what you're talking about. Essentially instead of nginx -> LLVM -> machine code you're replacing it with nginx -> WASM -> cmm_of_wasm -> machine code. There are tons of LLVM opts already, but if there weren't, it might be reasonable to use WASM as IR and using cmm_of_wasm's opts to make it faster than a naive C compiler (but of course none of the popular compilers are naive anyways). Also, of course this won't work today because cmm_of_wasm doesn't rebuild the syscalls from emscripten-compiled-WASM (yet). But if you're writing your own language today, ignoring system interaction for a sec, targeting WASM even for native might not be a bad idea as backends are coming w/ optimizations.
also...
> and eventually we hope to hook into OCaml’s excellent garbage collector
isnt WASM gc-free? why would the output need explicit GC interaction?
"Its types and pattern matching make it well-suited and commonly used to operate on other formal languages, such as in compiler writing, automated theorem proving and formal verification."
[1]: https://github.com/WebAssembly/gc/blob/master/proposals/gc/O...