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
setTempRet0 and getTempRet0 are inconsistent in their implementation. #7273
Comments
I guess we can have two different names..? |
I agree that splittin them into separate variables would solve the problem and increase comprehension. But since they are trying to do that same thing I think I'd rather unify them at this point. My initial plan is to change the implementations to always use the set functions rather than settings these values directly. Alon, do you forsee a performance hit if change "set_global"/"store" to "call setTempRet0"? Presumably they will be inline-able by binaryen anyway? |
I don't understand this point. They are used to mean different things, and they don't even set the same thing (one sets a global variable in linear memory, and the other sets an wasm global). |
Another option to avoid the problem (of inconsistency, using the get from one method with the set of another) may be to keep the get and set together. Specifically, we can make the Another option is to standardize a wasm global for this, like I believe we standardize the stack pointer. |
Yeah, Binaryen should inline a small getter/setter like that. |
These are now always generated by emscripten-wasm-finalize See: WebAssembly/binaryen#1703 Parial fix for #7273
These are now always generated by emscripten-wasm-finalize See: WebAssembly/binaryen#1703 Parial fix for #7273
These function always either exist in the wasm module or are expected to be imported (in the case of RELOCATABLE). In neither case do they need to be synthesized here. Fixes: emscripten-core/emscripten#7273 Fixes: emscripten-core/emscripten#7304 See: https://reviews.llvm.org/D53240
Export them as library functions so compiled code can access them. Remove them from system/lib/compiler-rt/extras.c. Fixes: #7273
Its simpler if we alwasy import these functions from the embedder rather then synthesizing them various placed. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: emscripten-core/emscripten#7358 binaryen: emscripten-core/emscripten#7358 Fixes: emscripten-core/emscripten#7273 Fixes: emscripten-core/emscripten#7304
Its simpler if we alwasy import these functions from the embedder rather then synthesizing them various placed. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: emscripten-core/emscripten#7358 binaryen: emscripten-core/emscripten#7358 Fixes: emscripten-core/emscripten#7273 Fixes: emscripten-core/emscripten#7304
Its simpler if we alwasy import these functions from the embedder rather then synthesizing them various placed. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: emscripten-core/emscripten#7358 binaryen: emscripten-core/emscripten#7358 Fixes: emscripten-core/emscripten#7273 Fixes: emscripten-core/emscripten#7304
Its simpler if we always import these functions from the embedder rather then synthesizing them various placed. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: emscripten-core/emscripten#7358 binaryen: emscripten-core/emscripten#7358 Fixes: emscripten-core/emscripten#7273 Fixes: emscripten-core/emscripten#7304
Export them as library functions so compiled code can access them. Remove them from system/lib/compiler-rt/extras.c. Fixes: #7273
Export them as library functions so compiled code can access them. Remove them from system/lib/compiler-rt/extras.c. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: #7358 binaryen: WebAssembly/binaryen#1709 Bump binaryen and fastcomp versions to include the relevant changes from those projects. Fixes: #7273
Export them as library functions so compiled code can access them. Remove them from system/lib/compiler-rt/extras.c. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: emscripten-core/emscripten-fastcomp#237 emscripten: #7358 binaryen: WebAssembly/binaryen#1709 Bump binaryen and fastcomp versions to include the relevant changes from those projects. Fixes: #7273
I think we should revisit this.. since the solution we ended up with was to always have getTempRet0/setTempRet0 available as imports from the environment. A better solution would avoid environmental imports completely and define these functions in native code. |
Why were they moved to JS in #7358? I think they used to be in native code long ago, and I'm not familiar with the history after that. |
Indeed, i make bunch of changes to move them to JS so there were always imported and never defined in the wasm or exported. I now think that was the wrong approach and I'm proposing to move them back inside the wasm file :) We also now have the ability to define wasm globals in assembly which we didn't have before so we can use a wasm global to hold this. |
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
This allows emscripten to move these helper functions from JS library imports to native wasm exports. See emscripten-core/emscripten#7273
There are several places there the need to some kind of temporary is need is needed / used in emscripten.
Under wasm this is handled in either asm2wasm or emscripten-wasm-finalize which both run the legalize-js-interface pass: https://github.com/WebAssembly/binaryen/blob/master/src/passes/LegalizeJSInterface.cpp#L256
In this case the temporary uses is a wasm global and is only ever set via inline calls to set_global in the wrapper functions.
getTempRet0
in synthesized here then exported so that JS can call it. For an example of this run theother.test_sixtyfour_bit_return_value
test.See lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp in both fastcmp and upstream.
Here we have a global variable in linear memory and a helper function called
setTempRet0
that JS can use to set it.So we have two different globals being used, which happens to work because JS code only need to set one of them an get the other.
This is somewhat confusing and should probably be fixed. There is more complexity that I'm also missing. Continuing to investigate. My current feeling is that the codegen in both llvm and binaryen should always use the getters and setters, and then the implementations can be up the linker/LTO.
The text was updated successfully, but these errors were encountered: