bytecodealliance / bytecodealliance/wasmtime

Tracking issue: Stack switching proposal implementation status

Open
#10,248 4 comments 2 reactions 0 assignees View on GitHub
wasm-proposal:stack-switching
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

This is a tracking issue for the in-progress implementation of the [Wasm stack switching proposal](https://github.com/WebAssembly/stack-switching). The explainer document for the proposal is [here](https://github.com/WebAssembly/stack-switching/blob/main/proposals/stack-switching/Explainer.md).

### Progress of initial implementation

This just tracks what's happening in the sequence of PRs that's providing an initial implementation of the proposal. To get an idea of the extent of the initial implementation, see draft PR #10177.
- [x] ~Support for tags~ (implemented in #10251)
- [x] ~Type definitions for stack switching support~ (implemented in #10255)
- [x] Runtime support for stack switching (implemented in #10388)
- [ ] Compiling stack switching instructions to CLIF

### Limitations of initial implementation
These are things that won't be part of the initial implementation:

- [ ] Support for ISAs other than x64
- [ ] Support for `resume.throw` instructions (requires exception handling)
- [ ] Support for deallocating continuations
- [ ] Integration with GC (i.e., allowing continuation references to appear in GC objects, such as arrays an structs)
- [ ] Windows support
- [ ] Pulley support
- [ ] Winch support

### Miscellaneous TODO items

- [ ] `Config::wasm_stack_switching` enables both exceptions + stack-switching, but it should only enable `stack_switching` (from https://github.com/bytecodealliance/wasmtime/pull/10251)
- [ ] After pulley support, update the [provenance test](https://github.com/bytecodealliance/wasmtime/blob/c71d3aabfd7edbd21b76514849e0f31c208cf0be/tests/all/pulley.rs#L78-L184) to exercise various bits of stack switching to run as much as we can through MIRI
- [ ] Update the [host_segfault.rs](https://github.com/bytecodealliance/wasmtime/blob/c71d3aabfd7edbd21b76514849e0f31c208cf0be/crates/wasmtime/tests/host_segfault.rs) test to exercise stack overflow cases in various stack-y situations to ensure that faults due to misconfigured engines or recursion on the host fail in predictable fashions
- [ ] Remove use of `rustix::param::page_size` (cc https://github.com/bytecodealliance/wasmtime/pull/10803 for motivation)
- [ ] Remove `stack-switching` Cargo features for winch/Cranelift-related crates. Keep it for runtime bits, but for compiler bits we've generally found it's not worth the overhead.
- [ ] Add `stack-switching` Cargo features to the c-api and various crates/locations there
- [ ] [Stack-capturing fuzzer needs to be extended to support capturing backtraces across stack suspensions](https://github.com/bytecodealliance/wasmtime/pull/10388#discussion_r2114569602)
- [ ] Add support for stack switching in the embedder API (https://github.com/bytecodealliance/wasmtime/pull/10388#discussion_r1994307521).
- [ ] Allow [basic compat of GC/stack-switching](https://github.com/bytecodealliance/wasmtime/pull/10388#discussion_r1994023305) (continuations will still have lifetime of store).
- [x] Remove stray `DeleteMeDebugAssertion`s: https://github.com/bytecodealliance/wasmtime/pull/10388/files/60c9cdb707fc674857fa549a8459f8c602be0c82#r2127451083
- [ ] Ideally [`mod stack_switching`](https://github.com/bytecodealliance/wasmtime/blob/e4714332cade561c4bc5bbd9334ff76c53f4e0ab/crates/wasmtime/src/runtime/vm.rs#L62) would have a `#[cfg]` for stack switching on it
- [ ] `cont.bind` cannot contain gc roots (compile error), see https://github.com/bytecodealliance/wasmtime/pull/11003/files/e9fa92d1fd989a10b584124ca07acee836123b4d#r2138934542
- [ ] https://github.com/bytecodealliance/wasmtime/issues/13020
- [ ] https://github.com/bytecodealliance/wasmtime/issues/13021
- [ ] https://github.com/bytecodealliance/wasmtime/issues/13022
- [ ] all test cases at https://gist.github.com/alexcrichton/c03760ee0d0a1c37a15f2e1cd27060d4 currently fail
- [ ] https://github.com/bytecodealliance/wasmtime/issues/13028

### Larger outstanding work items which have arisen during review of the initial changes:

- [ ] Hostcalls can currently be made directly from continuation stacks; this behavior is different than the fibers impl and we likely should not allow this, [see related discussion](https://github.com/bytecodealliance/wasmtime/pull/10388#discussion_r2114375774)
- [ ] Currently stack switching and fibers use different stack layouts and cannot (without modification) share a lot of functionality (e.g. pooling allocator used for fiber stacks); long-term, we would like to unify these two mechanisms where possible. [See discussion](https://github.com/bytecodealliance/wasmtime/pull/10388#issuecomment-2817337818). (Note: This will likely mean that stack switching will require `cfg(feature = "async")` which is what we probably want anyways)
- [ ] Implement full GC of continuations

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.