I have an unfinished local branch that adds exception handling lowering to wasm-opt, for the benefit of runtimes like wasmtime where exception handling isn't supported and probably won't be supported for a while. At the moment I have to patch a lot of the software I package to replace __cxa_throw
with an abort, which isn't great. I haven't got EH lowering to fully work yet but I think it should definitely be possible.
I've considered using Asyncify to implement EH but it seems like, while they are conceptually similar, EH can't really be implemented in terms of unmodified Asyncify since Asyncify works on the unit of a function and EH works on the unit of a try/catch block.
One additional reason I want EH lowering is because wasi_thread_exit
doesn't currently exist but it enables certain applications (virtualizing proc_exit
in CLI subcommands by denying spawning threads and then using threads as faux-processes). Without runtime support it can only be implemented (in terms of core Wasm functionality) via EH, though I could also write a wasm-opt
pass lowering that function specifically. (Ideally it would be EH as otherwise the overhead of the asyncify-style branches will compound.)
Is there anybody else interested in this functionality? (Possibly enough to sponsor the work?) Do you think it will be accepted in upstream wasm-opt?
found it! I'll pick up the thread on monday
Last updated: Nov 22 2024 at 17:03 UTC