-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Exception support #2049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Duplicate of #1677 |
I agree it's related, but unwind and catch are slightly distinct actions and your issue doesn't cover that? |
Catch is implemented by returning |
Given the above comments I think this can be closed as duplicate. |
I missed your reply last year but does that cover windows at all? Windows doesn't use personalities? At least not like that? |
SEH seems to use exception handlers and termination handlers. I think catching an exception instead of doing cleanup is done by using an exception handler instead of termination handler. This is based on a cursory reading of the docs though, so I may be wrong. In any case both catching exceptions and cleanup needs the same codegen handling to support an alternative location to which a call can "return". |
Add unwinding and recover support for wasm using WebAssembly exception handling. This still has a few gotchas: * Many WASI systems don't support exception handling yet. For example, see: bytecodealliance/wasmtime#2049 * Asyncify doesn't support wasm exception handling: WebAssembly/binaryen#4470 This means it's not possible to use goroutines together with panic/recover. * The current way that exceptions are implemented pretend to be C++ exceptions, but work slightly differently. If C++ code is called (for example through CGo) that raises an exception, that exception will be eaten by TinyGo and not be propagated. This is fixable, it just hasn't been implemented (because we don't actually support C++ right now). I hope that these issues will be resolved over time. At least for now, people who need `recover()` have a way to use it.
Add unwinding and recover support for wasm using WebAssembly exception handling. This still has a few gotchas: * Many WASI systems don't support exception handling yet. For example, see: bytecodealliance/wasmtime#2049 * Asyncify doesn't support wasm exception handling: WebAssembly/binaryen#4470 This means it's not possible to use goroutines together with panic/recover. * The current way that exceptions are implemented pretend to be C++ exceptions, but work slightly differently. If C++ code is called (for example through CGo) that raises an exception, that exception will be eaten by TinyGo and not be propagated. This is fixable, it just hasn't been implemented (because we don't actually support C++ right now). I hope that these issues will be resolved over time. At least for now, people who need `recover()` have a way to use it.
Add unwinding and recover support for wasm using WebAssembly exception handling. This still has a few gotchas: * Many WASI systems don't support exception handling yet. For example, see: bytecodealliance/wasmtime#2049 * Asyncify doesn't support wasm exception handling: WebAssembly/binaryen#4470 This means it's not possible to use goroutines together with panic/recover. * The current way that exceptions are implemented pretend to be C++ exceptions, but work slightly differently. If C++ code is called (for example through CGo) that raises an exception, that exception will be eaten by TinyGo and not be propagated. This is fixable, it just hasn't been implemented (because we don't actually support C++ right now). I hope that these issues will be resolved over time. At least for now, people who need `recover()` have a way to use it.
Feature
Cranelift currently doesn't support SEH (but has some support for finally I think). This is a feature request to support properly exception (landingpads on Posix, SEH on windows, maybe SLJL for others)
Benefit
WASM has plans to support exceptions, at which point it's going to be needed. Win64 has partial SEH support (iirc it just emits what's needed, nothing more), this would allow for c++ /java/.net exception support.
Implementation
Tricky one. I know LLVM has two alternative ways of doing this. I think with that in mind it should be possible to do a single implementation. What's basically needed is a way to say:
from here
[code]
till here is a protected block, on exceptions go to X, for finalization go to Y. For the handler itself it should be possible to define the personality to call.
Throw, Rethrow etc can all probably be done on a library level.
Alternatives
The only alternative is to not do it.
The text was updated successfully, but these errors were encountered: