-
Notifications
You must be signed in to change notification settings - Fork 765
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
Add Asyncify mode that uses "native" stack #2934
Comments
I forget, do we have a way of telling Binaryen where the |
I wanted to reply that it's exported, but, apparently, unlike other useful Now that I remember previous discussions around this, exporting it was blocked on mutable globals proposal (since |
The normal way to access and manipulate Is there some reason we can't use those in this case? |
Yes, in this case I want to use the stack pointer from an external JS wrapper - https://github.com/GoogleChromeLabs/asyncify. The only way to allow it such access is to re-export the |
Sorry I still don't understand :( What can you do with the Having said all that we should support its direct export too at least when mutable-globals are enabled. |
Those functions are Emscripten-specific and available only from Emscripten; Asyncify transform and the above JS wrapper are not and can be used on arbitrary Wasm (hence the issue on Binaryen repo, not Emscripten one).
Sounds like we agree :) |
Sorry for the misunderstanding.. I finally got it! |
In particular allow explict exporting of `__stack_pointer` but exclud this from `--export-all` to avoid requiring the mutable globals feature whenenve `--export-all` is used. This uncovered a bug in populateTargetFeatures regarding checking if the mutable-globals feature is allowed. See: WebAssembly/binaryen#2934 Differential Revision: https://reviews.llvm.org/D88506
OK as of https://reviews.llvm.org/D88506 you should now be able to |
@sbc100 Ah, interesting, thanks. I actually didn't realise that it requires change to LLVM / wasm-ld. And then wasm-opt will preserve the export as well when mutable globals are enabled? |
I don't think wasm-opt will add or remove exports.. but it might reject the binary if mutable globals are not enabled I think |
In particular allow explict exporting of `__stack_pointer` but exclud this from `--export-all` to avoid requiring the mutable globals feature whenenve `--export-all` is used. This uncovered a bug in populateTargetFeatures regarding checking if the mutable-globals feature is allowed. See: WebAssembly/binaryen#2934 Differential Revision: https://reviews.llvm.org/D88506
In particular allow explict exporting of `__stack_pointer` but exclud this from `--export-all` to avoid requiring the mutable globals feature whenenve `--export-all` is used. This uncovered a bug in populateTargetFeatures regarding checking if the mutable-globals feature is allowed. See: WebAssembly/binaryen#2934 Differential Revision: https://reviews.llvm.org/D88506
Something I mentioned in personal discussions with @kripken, posting here for tracking.
Low-level Asyncify API is flexible enough to support arbitrary suspend/resume use-cases, including coroutines. However, many applications don't really care about those and want to only suspend/resume the whole app on an external I/O.
For such cases, it could be nice to avoid having to allocate a separate "scratch space" for Asyncify, and instead push values directly onto the shadow stack behind
__stack_pointer
as defined by Tool Conventions. Semantically, those stored values are the spilled stack, so it only makes sense to store them there.This would, in particular, simplify integrations like https://github.com/GoogleChromeLabs/asyncify, which currently have to make guesses about a free space area in a Wasm file where they could store Asyncify data, and would centralise stack size management for both Asyncify and regular stack in a single place.
The text was updated successfully, but these errors were encountered: