-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[JSPI] Automatically add promising JSPI wrappers to thread entry points. #22891
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
[JSPI] Automatically add promising JSPI wrappers to thread entry points. #22891
Conversation
| self.onunhandledrejection = (e) => { throw e.reason || e; }; | ||
|
|
||
| function handleMessage(e) { | ||
| {{{ asyncIf(ASYNCIFY == 2) }}} function handleMessage(e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like these fixes would apply to JSPI using in the main function of any pthread, not just the PROXY_TO_PTHREAD mode. Is there something specific to PROXY_TO_PTHREAD here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's not totally specific to PROXY_TO_PTHREAD, more it showed up as an issue there since the entry point for the main proxy is not the users actual main.
With a user defined entry point there were ways of handling this (see core.test_pthread_join_and_asyncify). I think I can actually change that test now to not require the user to specify that the entry function is JSPI. Hower, this makes me wonder if we should automatically JSPI wrap thread entry functions or require the user to specify that they need JSPI. FWIW, we currently auto JSPI wrap main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So an alternative solution to this one would be to auto-wrap _main_thread which is used in _emscripten_proxy_main ?
If the clang annotation was working we could use that there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So an alternative solution to this one would be to auto-wrap
_main_threadwhich is used in_emscripten_proxy_main?
Yeah, we'd need EMSCRIPTEN_KEEPALIVE or add it to EXPORTED_FUNCTIONS and also add it to DEFAULT_ASYNCIFY_EXPORTS.
If the clang annotation was working we could use that there?
Yeah, I still need to fix binaryen to handle the annotation.
Use a WebAssembly.Promising wrapper on the thread entry points to allow JSPI to be used from worker threads. The code that invokes the wrapper also adds async/await to handle this async call to entry point. Fixes emscripten-core#22354
aaf0481 to
7bca7aa
Compare
|
Per discussion in meeting, we'll auto wrap all thread entry points. I've removed my new test, but updated the original test to cover the case of suspending on them main thread too. (sorry for the force push, but I wanted to amend to make sure I removed all new code) |
|
Wasm64 was broken since it was trying to do |
…ts. (emscripten-core#22891) Use a WebAssembly.Promising wrapper on the thread entry points to allow JSPI to be used from worker threads. The code that invokes the wrapper also adds async/await to handle this async call to entry point. Fixes emscripten-core#22354 --------- Co-authored-by: Alon Zakai <[email protected]>
Use a WebAssembly.Promising wrapper on the thread entry points to allow
JSPI to be used from worker threads. The code that invokes the wrapper
also adds async/await to handle this async call to entry point.
Fixes #22354