* Refactor use of Refs and RefMuts in wasi-common This commit refactors the use of `Ref`s and `RefMut`s in `wasi-common`. Now, `Entry` is stored behind an `Rc` inside the `EntryTable`. The `Entry` itself on the other hand now stores rights behind a `RefCell` and the descriptor as `Rc<RefCell<..>>` combo to enable easy reference tracking and interior mutability which is required down the line in a couple of syscalls. In essence, this implies that we no longer have need for mutable accessor to `Entry` from `WasiCtx`, and so all related methods go away (`get_entry_mut`, etc.). While here, I've also simplified handling and aggregating of rights on the `Entry` object. Instead of storing base and inheriting rights as separate fields, they are now aggregated into one struct `EntryRights` which features convenient constructors for each possible combination; i.e., when only base rights are set, or both base and inheriting are set, or both are left as empty. Since we do need to be able to mutate those rights down the line in `fdstat_set_rights` syscall, this object is kept behind a `RefCell` (note no `Rc` since we don't need to pass it around anywhere). The descriptor field in `Entry` is now kept behind `Rc<RefCell<..>>` combo since we not only need to mutate it down the line, but we also need to be able to pass it around (as part of the machinery making `poll_oneoff` work). I've also removed `as_file` and `try_clone` methods on `Descriptor` struct since they were adding more noise than necessary, and making them work with `Rc` was unnecessarily complicated. Finally, I've converted the `get_dir_from_os_handle` function into a method attached to the `OsHandle` itself, called `dir_stream`. IMHO, it makes more sense to have it there directly as a method than as a separate function. * Use Cell for types that are Copy
wasmtime
A standalone runtime for WebAssembly
A Bytecode Alliance project
Guide | Contributing | Website | Chat
Installation
The Wasmtime CLI can be installed on Linux and macOS with a small install script:
$ curl https://wasmtime.dev/install.sh -sSf | bash
Windows or otherwise interested users can download installers and binaries directly from the GitHub Releases page.
Example
If you've got the Rust compiler installed then you can take some Rust source code:
fn main() {
println!("Hello, world!");
}
and compile/run it with:
$ rustup target add wasm32-wasi
$ rustc hello.rs --target wasm32-wasi
$ wasmtime hello.wasm
Hello, world!
Features
-
Lightweight. Wasmtime is a standalone runtime for WebAssembly that scales with your needs. It fits on tiny chips as well as makes use of huge servers. Wasmtime can be embedded into almost any application too.
-
Fast. Wasmtime is built on the optimizing Cranelift code generator to quickly generate high-quality machine code at runtime.
-
Configurable. Whether you need to precompile your wasm ahead of time, generate code blazingly fast with Lightbeam, or interpret it at runtime, Wasmtime has you covered for all your wasm-executing needs.
-
WASI. Wasmtime supports a rich set of APIs for interacting with the host environment through the WASI standard.
-
Standards Compliant. Wasmtime passes the official WebAssembly test suite, implements the official C API of wasm, and implements future proposals to WebAssembly as well. Wasmtime developers are intimately engaged with the WebAssembly standards process all along the way too.
Documentation
📚 Read the Wasmtime guide here! 📚
The wasmtime guide is the best starting point to learn about what Wasmtime can do for you or help answer your questions about Wasmtime. If you're curious in contributing to Wasmtime, it can also help you do that!.
It's Wasmtime.