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
Export getTempRet0 like other EH library functions #7268
Export getTempRet0 like other EH library functions #7268
Conversation
In the current emscripten EH with the LLVM wasm backend, `__tempRet0` variable is in the wasm side and set by JS code and read by wasm code. So we need `setTempRet0` but not `getTempRet0`. This does not seem to be currently exported so it's not used anyway.
I think we use it in another way, when wasm returns an i64 we call We do have tests for that, though, so maybe I'm missing something - |
Ah, yes, it looks like these symbols are being injected by binaryen in LegalizeJSInterface. We should probably remove them from there. |
@sbc100 Then do we even need other functions? |
My understanding is that all three functions are needed yes. We just need to decide who generates them. One option is to simply rely on binaryen (wasm-emscripten-finalize) to generated them and simply delete this C file. |
I prefer the library option because it feels more normal. But what you mean is, we are currently relying on this file for only two functions ( |
Binaryen's legalization will add them if they aren't present (it needs to, so legalization can work), but it won't if they are already present, so this should not cause an error. |
Hmm, then what should we do? I guess there should be a unified way to handle all three of them. Then would it be better to export |
I think we can export this method too, so all 3 are exported. That does mean the the legalizeJSInterface pass doesn't need to generate them in the common case, but that's fine - there may still be a case like the optimizer removing these functions, then legalize being run late, and it re-creates them. (In general, we run legalizeJSInterface to make sure the JS interface can be called from JS, so no i64s going in or going out - so we do still need this pass, even if it doesn't need to create the 3 helper functions.) |
The problem is that the implementation of these functions in extras.c and that in LegalizeJSInterface is different. LegalizeJSInterface uses actual wasm globals whereas extras.c uses memory locations. So this change broke It looks like code in both llvm and fastcomp for WebAssemblyLowerEmscriptenEHSjLj.cpp uses the memoy locations, so it seem like we've had two diffferent approaches for while now. Could it be that 64-bit return and exceptions never worked at the same time? |
Mixing a get from one mechanism with a set from the other would definitely fail, yeah - is that what happened here? (Otherwise, while extras.c and legalizeJSInterface use a different mechanism, the code calling these APIs should not care about which it is.) Assuming the issue is mixing a get from one mechanism with a set for the other, I think some options are
It's possible 64-bit return an exceptions never worked together - we just have a few tests for the former, and not many for the latter. |
Can we revert this change for now while we investigate? |
In the current emscripten EH with the LLVM wasm backend,
__tempRet0
variable is in the wasm side and set by JS code and read by wasm code.
So we need
setTempRet0
but notgetTempRet0
. This does not seem to becurrently exported so it's not used anyway.