Remove need for explicit `Config::async_support` knob (#12371)* Refactor component model host function definitionsPush the `async`-ness down one layer.* Remove need for explicit `Config::async
Remove need for explicit `Config::async_support` knob (#12371)* Refactor component model host function definitionsPush the `async`-ness down one layer.* Remove need for explicit `Config::async_support` knobThis commit is an attempt to step towards reconciling "old async" and"new async" in Wasmtime. The old async style is the original asyncsupport in Wasmtime with `call_async`, `func_wrap_async`, etc, where themain property is that the store is "locked" during an async operation.Put another way, a store can only execute at most one async operation ata time. This is in contrast to "new async" support in Wasmtime with thecomponent-model-async (WASIp3) support, where stores can have more thanone async operation in flight at once.This commit does not fully reconcile these differences, but it doesremove one hurdle along the way: `Config::async_support`. Since thebeginning of Wasmtime this configuration knob has existed to explicitlydemarcate a config/engine/store as "this thing requires `async` stuffinternally." This has started to make less and less sense over timewhere the line between sync and async has become more murky with WASIp3where the two worlds comingle. The goal of this commit is to deprecate`Config::async_support` and make the function not actually do anything.In isolation this can't simply be done, however, because there are manyload-bearing aspects of Wasmtime that rely on this `async_support` knob.For example once epochs + yielding are enabled it's required that allWasm is executed on a fiber lest it hit an epoch and not know how toyield. That means that this commit is not a simple removal of`async_support` but instead a refactoring/rearchitecting of how async isused internally within Wasmtime. The high-level ideas within Wasmtimenow are:* A `Store` has a "requires async" boolean stored within it.* All configuration options which end up requiring async, such as yielding with epochs, turn this boolean on.* Creation of host functions which use async (e.g. `func_wrap_{async,concurrent}`) will also turn this option on.* Synchronous API entrypoints into Wasmtime ensure that this boolean is disabled.* Asynchronous APIs are usable at any time.This means that the concept of an async store vs a sync store is nowgone. All stores are equally capable of executing sync/async, and thechange now is that dynamically some stores will require that async isused with certain configuration. Additionally all panicking conditionsaround `async_support` have been converted to errors instead. Allrelevant APIs already returned an error and things are murky enough nowthat it's not necessarily trivial to get this right at the embedderlevel. In the interest of avoiding panics all detected async mismatchesare now first-class `wasmtime::Error` values.The end result of this commit is that `Config::async_support` is adeprecated `#[doc(hidden)]` function that does nothing. While manyinternal changes happened as well as having new tests for all this sortof behavior this is not expected to have a great impact on externalconsumers. In general a deletion of `async_support(true)` is in theoryall that's required. This is intended to make it easier to think aboutasync/sync/etc in the future with WASIp3 and eventually reconcile`func_wrap_async` and `func_wrap_concurrent` for example. That's leftfor future refactorings however.prtest:full* Review comments* Fix CI failures
show more ...
Migrate the Wasmtime CLI to `wasmtime::error` (#12295)* Migrate wasmtime-cli to `wasmtime::error`* migrate benches to `wasmtime::error` as well* Remove new usage of anyhow that snuck in
Rename "preview{0,1}" in `wasmtime-wasi` to "p{0,1}" (#11380)* Rename "preview{0,1}" in `wasmtime-wasi` to "p{0,1}"This commit renames the `preview1` module and features to `p1` and doesthe same
Rename "preview{0,1}" in `wasmtime-wasi` to "p{0,1}" (#11380)* Rename "preview{0,1}" in `wasmtime-wasi` to "p{0,1}"This commit renames the `preview1` module and features to `p1` and doesthe same for `preview0`. This additionally cleans up the test suite abit to share more code amongst all the implementaitons and to also movethe p1 tests out of the p2 folder.This additionally adds a `p2` feature to the `wasmtime-wasi` crate butit does not currently gate the `p2` module because that'll require somemore refactoring an annotations to get that working.* Fix build of the CLI* Fix build of the C API* Fix bench-api build* Fix build of examples* More renamings
Unify WASIp{2,3} context structures (#11370)This removes `wasmtime_wasi::p{2,3}::{WasiCtx, WasiCtxBuilder,WasiView}` in favor of only having `wasmtime_wasi::{WasiCtx,WasiCtxBuilder, WasiView}` in
Unify WASIp{2,3} context structures (#11370)This removes `wasmtime_wasi::p{2,3}::{WasiCtx, WasiCtxBuilder,WasiView}` in favor of only having `wasmtime_wasi::{WasiCtx,WasiCtxBuilder, WasiView}` instead. Conceptually these revisions of WASIall provide the same functionality just with a different veneer that thecomponent model offers, so having only one way to configure host-sidebehavior will make it easier to both organize implementations internally(e.g. more sharing of code) as well as for embedders to configure (onlyone context to create/manage).
Update pinned nightly used in CI (#10893)* Update pinned nightly used in CIResolves some various warnings cropping up from rustc/clippy. This doestrigger what for us is a false positive (I belie
Update pinned nightly used in CI (#10893)* Update pinned nightly used in CIResolves some various warnings cropping up from rustc/clippy. This doestrigger what for us is a false positive (I believe) dead code warningwhich I've annotated as `#[allow]` for now (alas this can't be`#[expect]` because it's a nighly-only warning).* Remove dead methods when component-model is disabled
Update Wasmtime to the 2024 Rust Edition (#10806)* Update Wasmtime to the 2024 Rust EditionNow that our MSRV supports the 2024 edition it's possible to make thisswitch. This commit moves Wasmtim
Update Wasmtime to the 2024 Rust Edition (#10806)* Update Wasmtime to the 2024 Rust EditionNow that our MSRV supports the 2024 edition it's possible to make thisswitch. This commit moves Wasmtime to the 2024 Edition to keepup-to-date with Rust idioms and access many of the edition featuresexclusive to the 2024 edition.prtest:full* Reformat with the 2024 edition
Rename the `wasm32-wasi` target to `wasm32-wasip1` (#8867)This rename is happening in upstream Rust and should be in enough placesnow.prtest:full
Make wasi-common self-contained, deprecate exports from wasmtime-wasi (#7881)* WIP: try to make wasi-common self contained.* rebase: cargo.lock* remove all dependencies between wasi-common and
Make wasi-common self-contained, deprecate exports from wasmtime-wasi (#7881)* WIP: try to make wasi-common self contained.* rebase: cargo.lock* remove all dependencies between wasi-common and wasmtime-wasi* use wasi-common directly throughout tests, benches, examples, cli run* wasi-threads: use wasi-common's maybe_exit_on_error in spawned threadnot a very modular design, but at this point wasi-common andwasi-threads are forever wed* fix wasmtime's docs* re-introduce wasmtime-wasi's exports of wasi-common definitions behind deprecated* factor out determining i32 process exit codeand remove libc dep because rustix provides the same constant* commands/run: inline the logic about aborting on trapsince this is the sole place in the codebase its used* Add high-level summary to wasi-common's top-level doc comment.* c-api: fix use of wasi_cap_std_sync => wasi_common::sync, wasmtime_wasi => wasi_common* fix tokio example* think better of combining downcast and masking into one method* fix references to wasmtime_wasi in docsprtest:full* benches: use wasi-common* cfg-if around use of rustix::process because that doesnt exist on windows* wasi-common: include tests, caught by verify-publish* fix another bench* exit requires wasmtime dep. caught by verify-publish.
Switch to simpler fuel APIs (#7298)In an effort to simplify the many fuel related APIs, simplify theinterface here to a single counter with get and set methods.Additionally the async yield is red
Switch to simpler fuel APIs (#7298)In an effort to simplify the many fuel related APIs, simplify theinterface here to a single counter with get and set methods.Additionally the async yield is reduced to an interval of the total fuelinstead of injecting fuel, so it's easy to still reason about how muchfuel is left even with yielding turned on.Internally this works by keeping two counters - one the VM uses toincrement towards 0 for fuel, the other to track how much is in"reserve". Then when we're out of gas, we pull from the reserve torefuel and continue. We use the reserve in two cases: one for overflowof the fuel (which is an i64 and the API expresses fuel as u64) and theother for async yieling, which then the yield interval acts as a cap tohow much we can refuel with.This also means that `get_fuel` can return the full range of `u64`before this change it could only return up to `i64::MAX`. This isimportant because this PR is removing the functionality to track fuelconsumption, and this makes the API less error prone for embedders totrack consumption themselves.Careful to note that the VM counter that is stored as `i64` can bepositive if an instruction "costs" multiple units of fuel when the fuelran out.prtest:fullSigned-off-by: Tyler Rockwood <[email protected]>
Remove explicit `S` type parameters (#5275)* Remove explicit `S` type parameters This commit removes the explicit `S` type parameter on `Func::typed` and `Instance::get_typed_func`. Historical
Remove explicit `S` type parameters (#5275)* Remove explicit `S` type parameters This commit removes the explicit `S` type parameter on `Func::typed` and `Instance::get_typed_func`. Historical versions of Rust required that this be a type parameter but recent rustcs support a mixture of explicit type parameters and `impl Trait`. This removes, at callsites, a superfluous `, _` argument which otherwise never needs specification. * Fix mdbook examples
Add cmake compatibility to c-api (#4369)* Add cmake compatibility to c-api * Add CMake documentation to wasmtime.h * Add CMake instructions in examples * Modify CI for CMake support * U
Add cmake compatibility to c-api (#4369)* Add cmake compatibility to c-api * Add CMake documentation to wasmtime.h * Add CMake instructions in examples * Modify CI for CMake support * Use correct rust in CI * Trigger build * Refactor run-examples * Reintroduce example_to_run in run-examples * Replace run-examples crate with cmake * Fix markdown formatting in examples readme * Fix cmake test quotes * Build rust wasm before cmake tests * Pass CTEST_OUTPUT_ON_FAILURE * Another cmake test * Handle os differences in cmake test * Fix bugs in memory and multimemory examples
Upgrade all crates to the Rust 2021 edition (#3991)* Upgrade all crates to the Rust 2021 edition I've personally started using the new format strings for things like `panic!("some message {foo}
Upgrade all crates to the Rust 2021 edition (#3991)* Upgrade all crates to the Rust 2021 edition I've personally started using the new format strings for things like `panic!("some message {foo}")` or similar and have been upgrading crates on a case-by-case basis, but I think it probably makes more sense to go ahead and blanket upgrade everything so 2021 features are always available. * Fix compile of the C API * Fix a warning * Fix another warning
Change the injection count of fuel in a store from u32 to u64 (#3048)* Change the injection count of fuel in a store from u32 to u64 This commit updates the type of the amount of times to inject
Change the injection count of fuel in a store from u32 to u64 (#3048)* Change the injection count of fuel in a store from u32 to u64 This commit updates the type of the amount of times to inject fuel in the `out_of_fuel_async_yield` to `u64` instead of `u32`. This should allow effectively infinite fuel to get injected, even if a small amount of fuel is injected per iteration. Closes #2927 Closes #3046 * Fix tokio example
Implement RFC 11: Redesigning Wasmtime's APIs (#2897)Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more inform
Implement RFC 11: Redesigning Wasmtime's APIs (#2897)Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
only wasi_cap_std_sync and wasi_tokio need to define WasiCtxBuilders (#2917)* wasmtime-wasi: re-exporting this WasiCtxBuilder was shadowing the right one wasi-common's WasiCtxBuilder is really o
only wasi_cap_std_sync and wasi_tokio need to define WasiCtxBuilders (#2917)* wasmtime-wasi: re-exporting this WasiCtxBuilder was shadowing the right one wasi-common's WasiCtxBuilder is really only useful wasi_cap_std_sync and wasi_tokio to implement their own Builder on top of. This re-export of wasi-common's is 1. not useful and 2. shadow's the re-export of the right one in sync::*. * wasi-common: eliminate WasiCtxBuilder, make the builder methods on WasiCtx instead * delete wasi-common::WasiCtxBuilder altogether just put those methods directly on &mut WasiCtx. As a bonus, the sync and tokio WasiCtxBuilder::build functions are no longer fallible! * bench fixes * more test fixes
less general mechanism for examples cargo feature
fix example
fixes to example
tokio example requires enabling a cargo featureand also a dummy C example
wasi-cap-std-async is better named wasi-tokio
add tokio exampleCo-authored-by: Alex Crichton <[email protected]>