-
Notifications
You must be signed in to change notification settings - Fork 89
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 thread.spawn_indirect
#447
Conversation
This encoding change is necessary due to recent additions to the component model; see [bytecodealliance#447]. [bytecodealliance#447]: WebAssembly/component-model#447
[bytecodealliance#447] tries to make the built-in naming a bit more consistent; this change propagates that here. [bytecodealliance#447]: WebAssembly/component-model#447
This encoding change is necessary due to recent additions to the component model; see [bytecodealliance#447]. [bytecodealliance#447]: WebAssembly/component-model#447
[bytecodealliance#447] tries to make the built-in naming a bit more consistent; this change propagates that here. [bytecodealliance#447]: WebAssembly/component-model#447
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.
Looks generally good. One initial suggestion:
This change codifies the conclusions we arrived to in [WebAssembly#89]. It adds a new way to spawn threads, `thread.spawn_indirect`, which retrieves the thread start function from a table. This prompted me to rename `thread.spawn` to `thread.spawn_ref`. [WebAssembly#89]: WebAssembly/shared-everything-threads#89
a69f22e
to
903cdb1
Compare
@lukewagner, I had to rebase due to some conflicts but the follow-on commits should have the changes we discussed. |
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.
Great, thanks! This looks good to me with these suggestions:
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
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.
Last tiny nits:
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
* `$tbl` must refer to a table with type `(table (ref null (shared func)) | ||
shared)` |
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.
The table type doesn't seem to follow any syntax defined in the proposal. More importantly, we have subtyping. So I think this ought to say:
* `$tbl` must refer to a shared table whose element type matches `(ref null (shared func))`
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.
Ah, thanks, good point!
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.
Updated in #462.
This uses the language suggested [here] to document the table type needed for the `thread.spawn_indirect` canonical builtin. [here]: WebAssembly#447 (comment)
This uses the language suggested [here] to document the table type needed for the `thread.spawn_indirect` canonical builtin. [here]: #447 (comment)
[bytecodealliance#447] tries to make the built-in naming a bit more consistent; this change propagates that here. [bytecodealliance#447]: WebAssembly/component-model#447
This encoding change is necessary due to recent additions to the component model; see [bytecodealliance#447]. [bytecodealliance#447]: WebAssembly/component-model#447
[bytecodealliance#447] tries to make the built-in naming a bit more consistent; this change propagates that here. [bytecodealliance#447]: WebAssembly/component-model#447
This encoding change is necessary due to recent additions to the component model; see [bytecodealliance#447]. [bytecodealliance#447]: WebAssembly/component-model#447
* threads: add `thread.spawn_indirect` As discussed in [#89], this adds support for a new intrinsic, `thread.spawn_indirect`. This new operation would allow spawning a shared function stored in a table via a table index. This leaves some future work undone: - `thread.spawn` could/should be renamed to `thread.spawn_ref` - `thread.spawn_indirect` could/should take the encoding byte from `thread.hw_concurrency`--swap `0x07` for `0x06` - importantly, `thread.spawn_indirect` should gain a field indicating which type to expect in the indirect table; due to current limitations in `wasm-tools`, the locations to check once this is possible are marked with `TODO: spawn indirect types`. [#89]: WebAssembly/shared-everything-threads#89 * threads: rename `thread.spawn` to `thread.spawn_ref` [#447] tries to make the built-in naming a bit more consistent; this change propagates that here. [#447]: WebAssembly/component-model#447 * threads: move `thread.*` canonical opcodes to `0x40+` This encoding change is necessary due to recent additions to the component model; see [#447]. [#447]: WebAssembly/component-model#447 * threads: add function types to `thread.spawn_indirect` Initially I implemented `thread.spawn_indirect` without the ability to check the type of the function to spawn out of an abundance of caution (see the implementation issues described in [#89]). In the process of writing out the specification, we convinced ourselves that these problems should not apply to `thread.spawn_indirect`. This change adds the function type index necessary for doing some extra validation of `thread.spawn_indirect` and adds some tests related to this. One unimplemented TODO is what to do about shared tables: technically, the table used by a `thread.spawn_indirect` should be shared but we have so far prevented this in the component model; this can be resolved later, though. [#89]: WebAssembly/shared-everything-threads#89 * review: simplify WAST parsing
This change codifies the conclusions we arrived to in #89. It adds a new way to spawn threads,
thread.spawn_indirect
, which retrieves the thread start function from a table. This prompted me to renamethread.spawn
tothread.spawn_ref
.