Replies: 10 comments
-
@tlively Sorry for the delay in getting back to you, its been a busy couple weeks at work! Currently the exception handling primitives we use are target-specific. More precisely, non-Windows platforms we use |
Beta Was this translation helpful? Give feedback.
-
Great, thanks! I asked because right now WebAssembly's exceptions proposal is implemented in LLVM in terms of the Windows SEH intrinsics. If you're already using those for Windows, I would hope it wouldn't be a large burden to use them for WebAssembly as well. |
Beta Was this translation helpful? Give feedback.
-
Yeah I actually already have the code in place to use SEH-style exception instrinsics for WebAssembly, we just don't have the entire codegen pipeline implemented for WebAssembly yet. One other thing I forgot to mention is that as part of this, we also rely on the StackMaps feature, which is not implemented for WebAssembly AFAICT, but I'm curious if you think such a thing can even be implemented on top of WebAssembly's backend in LLVM. |
Beta Was this translation helpful? Give feedback.
-
I'm not familiar with the StackMaps feature, but perhaps @aheejin knows? |
Beta Was this translation helpful? Give feedback.
-
I mispoke, we're not actually using StackMaps in relation to exception handling, so its not really related to the original topic. I'm primarily using it right now to track live values on the stack across GC statepoints. It's of interest though, since its an LLVM feature that is quite useful for compilers for GC'd languages, I'd go so far as to say critical for those building precise GCs, but is not supported for the WebAssembly target. I think the main obstacle around supporting it though is the ability to link call sites to StackMap entries, which in general is done via return address for other targets, but in WebAssembly would need to be something else more opaque, but roughly equivalent. |
Beta Was this translation helpful? Give feedback.
-
Oh gotcha. After reading a bit about it, my best guess is that stackmaps could be supported today by spilling the preserved values to the in-memory stack and writing out the stack maps themselves as data. In the future, my guess is that a faster implementation could use the stack walking / stack inspection proposal. |
Beta Was this translation helpful? Give feedback.
-
Sorry I'm not very familiar with Lumen compiler. Does Lumen compiler have both separate frontend and backend that it generates source code to wasm directly? If so, does it use LLVM in both? Can it use the WebAssembly backend instead? |
Beta Was this translation helpful? Give feedback.
-
@aheejin Lumen has a frontend which generates a high-level IR, that in turn is lowered to MLIR and ultimately, LLVM IR. We don't generate WebAssembly directly, we rely on LLVM to take care of that for us. |
Beta Was this translation helpful? Give feedback.
-
Oh, I see. Then I guess there should be no problem to use the wasm EH implementation in our LLVM backend if you generate Windows IR from the frontend for all platforms.. |
Beta Was this translation helpful? Give feedback.
-
Per Dec 9 standup, this issue has been converted to a Discussion. |
Beta Was this translation helpful? Give feedback.
-
At the WebAssembly stack subgroup meeting this morning, @bitwalker mentioned that Lumen uses LLVM's
invoke
instruction. What other LLVM exception handling mechanisms does Lumen use? Specifically, does Lumen uselandingpad
or does it use the structured exception handling mechanismscatchpad
andcleanuppad
?Beta Was this translation helpful? Give feedback.
All reactions