This change is the first in a series of changes to support shared memory in Wiggle. Since Wiggle was written under the assumption of single-threaded guest-side access, this change introduces a `shared` field to guest memories in order to flag when this assumption will not be the case. This change always sets `shared` to `false`; once a few more pieces are in place, `shared` will be set dynamically when a shared memory is detected, e.g., in a change like #5054. Using the `shared` field, we can now decide to load Wiggle values differently under the new assumptions. This change makes the guest `T::read` and `T::write` calls into `Relaxed` atomic loads and stores in order to maintain WebAssembly's expected memory consistency guarantees. We choose Rust's `Relaxed` here to match the `Unordered` memory consistency described in the [memory model] section of the ECMA spec. These relaxed accesses are done unconditionally, since we theorize that the performance benefit of an additional branch vs a relaxed load is not much. [memory model]: https://tc39.es/ecma262/multipage/memory-model.html#sec-memory-model Since 128-bit scalar types do not have `Atomic*` equivalents, we remove their `T::read` and `T::write` implementations here. They are unused by any WASI implementations in the project.
wiggle
Wiggle is a code generator for the host side of a witx interface. It is
invoked as a Rust procedural macro.
Wiggle is not specialized to any particular WebAssembly runtime. It is usable in at least Wasmtime and Lucet.
Learning more
Read the docs on docs.rs.
There are child crates for integrating with Wasmtime and Lucet.
The wasi-common crate is implemented using Wiggle and the wasmtime-wasi crate integrates wasi-common with the Wasmtime engine.
Andrew Brown wrote a great blog post on using Wiggle with Wasmtime.