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

Quesitons about wasi_thread_spawn semantics #13

Open
yamt opened this issue Dec 6, 2022 · 5 comments
Open

Quesitons about wasi_thread_spawn semantics #13

yamt opened this issue Dec 6, 2022 · 5 comments

Comments

@yamt
Copy link
Contributor

yamt commented Dec 6, 2022

the description of wasi_thread_spawn says:

instantiate the module again — this child instance will be used for the new thread

it isn't obvious to me which module "the module" here is when multiple modules are involved.
for example, if module A calls a function imported from module B and the function calls wasi_thread_spawn, which module is it?

also, does instantiate the module again imply that an engine needs to keep an equivalent of wasm-c-api wasm_extern_vec_t or "import object" (i mean importObject argument of WebAssembly.instantiate) for possible wasi_thread_spawn operations?

@yamt
Copy link
Contributor Author

yamt commented Dec 11, 2022

the description of wasi_thread_spawn says:

instantiate the module again — this child instance will be used for the new thread

it isn't obvious to me which module "the module" here is when multiple modules are involved. for example, if module A calls a function imported from module B and the function calls wasi_thread_spawn, which module is it?

also, does instantiate the module again imply that an engine needs to keep an equivalent of wasm-c-api wasm_extern_vec_t or "import object" (i mean importObject argument of WebAssembly.instantiate) for possible wasi_thread_spawn operations?

as i couldn't find a way to determine them reliably, i made them explicitly specified by an embedder for my runtime.
https://github.com/yamt/toywasm/blob/ad3c57eaad7f04541c4b4b6f501dcdfe5221919c/lib/wasi_threads.h#L7-L9

@abrown
Copy link
Collaborator

abrown commented Dec 16, 2022

if module A calls a function imported from module B and the function calls wasi_thread_spawn, which module is it?

I don't think the "multiple linked modules" story is completely figured out. I think this question is similar to the dilemma that wasi-threads faces when attempting to use it in the component model paradigm.

also, does instantiate the module again imply that an engine needs to keep an equivalent of wasm-c-api wasm_extern_vec_t or "import object"

I believe that is correct; e.g., in Wasmtime the linking happens again for each new thread instantiation.

@abrown
Copy link
Collaborator

abrown commented Feb 8, 2023

@yamt, can we close this now?

@yamt
Copy link
Contributor Author

yamt commented Feb 8, 2023

questions are answered. it seems there is no plan to decide behavior with multiple modules in near future. closing.

@yamt
Copy link
Contributor Author

yamt commented Jul 21, 2023

reopening because it's a real problem, not just a question.

@yamt yamt reopened this Jul 21, 2023
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