Skip to content
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

wait/notify can check for shared memory at instantiation time #200

Closed
anuraaga opened this issue May 22, 2023 · 2 comments
Closed

wait/notify can check for shared memory at instantiation time #200

anuraaga opened this issue May 22, 2023 · 2 comments

Comments

@anuraaga
Copy link

Currently, wait/notify check whether memory is shared or not at runtime

https://github.com/WebAssembly/threads/blob/main/test/core/atomic.wast#L492

It seems like whether memory is shared or not could always be determined at instantiation time. Is there a reason it needs to be checked at runtime?

@conrad-watt
Copy link
Collaborator

See here for context on this decision, in particular

For example, consider a user wishing to distribute a WebAssembly binary for a C++ library. Say that library uses C++11 atomics internally to achieve thread-safety, but is otherwise agnostic to whether it is used in a single threaded environment or a multithreaded environment. On native platforms a single build of the library can be used in both environments, but due to the validation rules for WebAssembly atomics, the library must be built twice for WebAssembly; once with atomics enabled and once without. Beyond causing extra work for developers, having to produce these separate builds is also a large hole in WebAssembly's portability story.

So I believe the point is to better facilitate static linking of WebAssembly (e.g. see here).

@anuraaga
Copy link
Author

Ah so the summary is that wait/notify may be in the binary but not actually used when in a non-shared environment, and that should be allowed. That makes sense, thanks for the clarification. I think this will be a common question so it could be worth copying something into the overview itself for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants