|
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7 |
|
| #
ab78bd82 |
| 22-Mar-2026 |
Ho Kim <[email protected]> |
fix: correct various typos (#12807)
Signed-off-by: Ho Kim <[email protected]>
|
|
Revision tags: v43.0.0, v42.0.1 |
|
| #
7051ab30 |
| 24-Feb-2026 |
Chris Fallin <[email protected]> |
Debugging: add unique-within-store IDs for every entity. (#12645)
When building an introspection API for use by a debugger, we need a way to expose *identity*: that is, to give some way of knowing t
Debugging: add unique-within-store IDs for every entity. (#12645)
When building an introspection API for use by a debugger, we need a way to expose *identity*: that is, to give some way of knowing that a given `Memory`, `Instance`, etc. is *this* one and not *that* one. Our handle types variously have either `Eq` implementations or e.g. `Module::same` for the ones that wrap an `Arc` under-the-covers; but that's not enough to allow a debugger to e.g. build a hashmap for whatever metadata that it might expose via whatever debugging protocol.
For maximal generality and flexibility, we should expose the unique IDs that already more-or-less exist: for instances, that is their instance ID directly; for entities owned by instances, we can build a `u64` with the instance ID in the upper 32 bits and the defined-index in the lower 32 bits. IDs for all entities except modules are unique-within-a-Store (and this is all that is needed); IDs for modules happen to reuse the `CompiledModuleId` and so are unique-within-an-Engine.
I've opted to name these `debug_index_within_store` to scope the feature and intended use-case clearly, but if there's a desire, I could easily rename them to simply `index`. I shied away from that here because I didn't want to give a notion that these indices are somehow canonical or correspond to some order or other.
show more ...
|
|
Revision tags: v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3 |
|
| #
cc8d04f4 |
| 23-Jan-2026 |
Alex Crichton <[email protected]> |
Remove need for explicit `Config::async_support` knob (#12371)
* Refactor component model host function definitions
Push 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 definitions
Push the `async`-ness down one layer.
* Remove need for explicit `Config::async_support` knob
This commit is an attempt to step towards reconciling "old async" and "new async" in Wasmtime. The old async style is the original async support in Wasmtime with `call_async`, `func_wrap_async`, etc, where the main property is that the store is "locked" during an async operation. Put another way, a store can only execute at most one async operation at a time. This is in contrast to "new async" support in Wasmtime with the component-model-async (WASIp3) support, where stores can have more than one async operation in flight at once.
This commit does not fully reconcile these differences, but it does remove one hurdle along the way: `Config::async_support`. Since the beginning of Wasmtime this configuration knob has existed to explicitly demarcate a config/engine/store as "this thing requires `async` stuff internally." This has started to make less and less sense over time where the line between sync and async has become more murky with WASIp3 where 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 many load-bearing aspects of Wasmtime that rely on this `async_support` knob. For example once epochs + yielding are enabled it's required that all Wasm is executed on a fiber lest it hit an epoch and not know how to yield. That means that this commit is not a simple removal of `async_support` but instead a refactoring/rearchitecting of how async is used internally within Wasmtime. The high-level ideas within Wasmtime now 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 now gone. All stores are equally capable of executing sync/async, and the change now is that dynamically some stores will require that async is used with certain configuration. Additionally all panicking conditions around `async_support` have been converted to errors instead. All relevant APIs already returned an error and things are murky enough now that it's not necessarily trivial to get this right at the embedder level. In the interest of avoiding panics all detected async mismatches are now first-class `wasmtime::Error` values.
The end result of this commit is that `Config::async_support` is a deprecated `#[doc(hidden)]` function that does nothing. While many internal changes happened as well as having new tests for all this sort of behavior this is not expected to have a great impact on external consumers. In general a deletion of `async_support(true)` is in theory all that's required. This is intended to make it easier to think about async/sync/etc in the future with WASIp3 and eventually reconcile `func_wrap_async` and `func_wrap_concurrent` for example. That's left for future refactorings however.
prtest:full
* Review comments
* Fix CI failures
show more ...
|
|
Revision tags: v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1 |
|
| #
96e19700 |
| 07-Jan-2026 |
Nick Fitzgerald <[email protected]> |
Migrate the `wasmtime` crate to `wasmtime_environ::error::*` (#12231)
* Migrate the `wasmtime` crate to `wasmtime_environ::error::*`
Instead of `anyhow::Error`.
This commit re-exports the `wasmtim
Migrate the `wasmtime` crate to `wasmtime_environ::error::*` (#12231)
* Migrate the `wasmtime` crate to `wasmtime_environ::error::*`
Instead of `anyhow::Error`.
This commit re-exports the `wasmtime_environ::error` as the `wasmtime::error` module, updates the prelude to include these new error-handling types, redirects our top-level `wasmtime::{Error, Result}` re-exports to re-export `wasmtime::error::{Error, Result}`, and updates various use sites that were directly using `anyhow` to use the new `wasmtime` versions.
This process also required updating the component macro and wit-bindgen macro to use the new error types instead of `anyhow`.
Part of https://github.com/bytecodealliance/wasmtime/issues/12069
* Replace wasmtime::error::Thing with wasmtime::Thing where it makes sense
* cargo fmt
* Move `crate::error::Thing` to `crate::Thing` where it makes sense
show more ...
|
|
Revision tags: v40.0.0 |
|
| #
99ecf728 |
| 03-Dec-2025 |
Chris Fallin <[email protected]> |
Debug: create private code memories per store when debugging is enabled. (#12051)
* Debug: create private code memories per store when debugging is enabled.
This will allow patching code to implem
Debug: create private code memories per store when debugging is enabled. (#12051)
* Debug: create private code memories per store when debugging is enabled.
This will allow patching code to implement e.g. breakpoints. (That is, for now the copies are redundant, but soon they will not be.)
This change follows the discussion [here] and offline to define a few types that better encapsulate the distinction we want to enforce. Basically, there is almost never a bare `CodeMemory`; they are always wrapped in an `EngineCode` or `StoreCode`, the latter being a per-store instance of the former. Accessors are moved to the relevant place so that, for example, one cannot get a pointer to a Wasm function's body without being in the context of a `Store` where the containing module has been registered. The registry then returns a `ModuleWithCode` that boxes up a `Module` reference and `StoreCode` together for cases where we need both the metadata from the module and the raw code to derive something.
The only case where we return raw code pointers to the `EngineCode` directly have to do with Wasm-to-array trampolines: in some cases, e.g. `InstancePre` pre-creating data structures with references to host functions, it breaks our expected performance characteristics to make the function pointers store-specific. This is fine as long as the Wasm-to-array trampolines never bake in direct calls to Wasm functions; the strong invariant is that Wasm functions never execute from `EngineCode` directly. Some parts of the component runtime would also have to be substantially refactored if we wanted to do away with this exception.
The per-`Store` module registry is substantially refactored in this PR. I got rid of the modules-without-code distinction (the case where a module only has trampolines and no defined functions still works fine), and organized the BTreeMaps to key on start address rather than end address, which I find a little more intuitive (one then queries with the dual to the range -- 0-up-to-PC and last entry found).
[here]: https://github.com/bytecodealliance/wasmtime/pull/12051#pullrequestreview-3493711812
* Review feedback: do not assume a reasonable code alignment; error when it cannot be known
* Review feedback: fail properly in profiler when we are cloning code
* Fix guest-profiler C API.
* Review feedback: make private-code representation impossible in non-debugging-support builds.
* Add TODO comment referencing issue for cloning only .text.
* clang-format
* Review feedback: add back Component::image_range.
* Review feedback: error on registering profiling metadata when debug is enabled.
* rustfmt
* Remove early bail on profiling-data registration when debugging is enabled: this always happens so we cannot error out.
show more ...
|
|
Revision tags: v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1 |
|
| #
557cc2d6 |
| 10-Oct-2025 |
Alex Crichton <[email protected]> |
Another batch of dependency updates (#11832)
* Another batch of dependency updates
Bringing some deps in `Cargo.toml` up-to-date with their latest versions along the same lines as #11820 to avoid d
Another batch of dependency updates (#11832)
* Another batch of dependency updates
Bringing some deps in `Cargo.toml` up-to-date with their latest versions along the same lines as #11820 to avoid deps getting too stale/old.
Code-wise this updates `anyhow` which enables preexisting Clippy warnings to check more code, so those warnings are fixed here as well.
prtest:full
* Run rustfmt
show more ...
|
|
Revision tags: v37.0.2, v37.0.1, v37.0.0, v36.0.2, v36.0.1 |
|
| #
155ea7fc |
| 21-Aug-2025 |
Alex Crichton <[email protected]> |
Remove unsoundness of widening store borrows (#11481)
* Remove unsoundness of widening store borrows
This commit removes preexisting unsoundness in Wasmtime where a `&mut StoreOpaque` borrow was "
Remove unsoundness of widening store borrows (#11481)
* Remove unsoundness of widening store borrows
This commit removes preexisting unsoundness in Wasmtime where a `&mut StoreOpaque` borrow was "widened" into encompassing the limiter on the `T` in `StoreInner<T>`, for example, by using the self-pointer located in an instance or the store. This fix is done by threading `&mut StoreOpaque` as a parameter separately from a `StoreResourceLimiter`. This means that various callers now take a new `Option<&mut StoreResourceLimiter<'_>>` parameter in various locations.
Closes #11409
* Fix gc-less build
show more ...
|
| #
e1f50aad |
| 21-Aug-2025 |
Alex Crichton <[email protected]> |
Make table/memory creation async functions (#11470)
* Make core instance allocation an `async` function
This commit is a step in preparation for #11430, notably core instance allocation, or `Store
Make table/memory creation async functions (#11470)
* Make core instance allocation an `async` function
This commit is a step in preparation for #11430, notably core instance allocation, or `StoreOpaque::allocate_instance` is now an `async fn`. This function does not actually use the `async`-ness just yet so it's a noop from that point of view, but this propagates outwards to enough locations that I wanted to split this off to make future changes more digestable.
Notably some creation functions here such as making an `Instance`, `Table`, or `Memory` are refactored internally to use this new `async` function. Annotations of `assert_ready` or `one_poll` are used as appropriate as well.
For reference this commit was benchmarked with our `instantiation.rs` benchmark in the pooling allocator and shows no changes relative to the original baseline from before-`async`-PRs.
* Make table/memory creation `async` functions
This commit is a large-ish refactor which is made possible by the many previous refactorings to internals w.r.t. async-in-Wasmtime. The end goal of this change is that table and memory allocation are both `async` functions. Achieving this, however, required some refactoring to enable it to work:
* To work with `Send` neither function can close over `dyn VMStore`. This required changing their `Option<&mut dyn VMStore>` arugment to `Option<&mut StoreResourceLimiter<'_>>` * Somehow a `StoreResourceLimiter` needed to be acquired from an `InstanceAllocationRequest`. Previously the store was stored here as an unsafe raw pointer, but I've refactored this now so `InstanceAllocationRequest` directly stores `&StoreOpaque` and `Option<&mut StoreResourceLimiter>` meaning it's trivial to acquire them. This additionally means no more `unsafe` access of the store during instance allocation (yay!). * Now-redundant fields of `InstanceAllocationRequest` were removed since they can be safely inferred from `&StoreOpaque`. For example passing around `&Tunables` is now all gone. * Methods upwards from table/memory allocation to the `InstanceAllocator` trait needed to be made `async`. This includes new `#[async_trait]` methods for example. * `StoreOpaque::ensure_gc_store` is now an `async` function. This internally carries a new `unsafe` block carried over from before with the raw point passed around in `InstanceAllocationRequest`. A future PR will delete this `unsafe` block, it's just temporary.
I attempted a few times to split this PR up into separate commits but everything is relatively intertwined here so this is the smallest "atomic" unit I could manage to land these changes and refactorings.
* Shuffle `async-trait` dep
* Fix configured build
show more ...
|
|
Revision tags: v36.0.0 |
|
| #
aa91737e |
| 19-Aug-2025 |
Alex Crichton <[email protected]> |
Relax the `Send` bound on fiber creation (#11454)
* Relax the `Send` bound on fiber creation
This commit removes the need for `Send` for all usages of fiber-related bits. The goal is that the futu
Relax the `Send` bound on fiber creation (#11454)
* Relax the `Send` bound on fiber creation
This commit removes the need for `Send` for all usages of fiber-related bits. The goal is that the future returned from `async` functions is `Send` if all the inputs are `Send`, but there's no actual need to require that in the function signatures themselves. This property was identified in upcoming work to make more internals of Wasmtime `async` where `async` functions are going to be used to implement the synchronous path through Wasmtime where `Send` isn't a bound today, nor ideally do we want to have it there.
The way this commit works is:
* First `make_fiber` now has a `Send` bound which makes it sound. Before #11444 it took `&mut dyn VMStore` which is never `Send` and the refactoring there missed adding this bound. This change required a few `Send` bounds in `concurrent.rs` where it's expected to have no impact as everything there is basically already `Send`.
* Next `make_fiber_unchecked` is added which is the same as `make_fiber` except without a `Send` bound. The `on_fiber` function is then updated to use this `*_unchecked` variant. This means that fibers can now be used with non-`Send` stores. Crucially though the structure of internals in play means that future produced is still only `Send` if `T: Send` meaning that there is no loss in safety.
* Next some `Send` bounds were dropped throughout async functions in Wasmtime as a proof-of-concept to require these changes to `on_fiber`. This means that these entrypoints into Wasmtime no longer require `Send`, but still naturally require `Send` if the result future is sent to various threads.
* Finally a new doctest is added to `Instance::new_async` with a `compile_fail` example to ensure that this fails. This is unfortunately a very brittle test because all we can assert is that compilation failed, not why compilation failed. That means that this is likely to regress over time, but it's the best we can do at this time.
Note that the goal here is NOT to remove `Send` bounds throughout Wasmtime. Many of them are still required, for example all the ones related to `Linker`. The realization is that we can remove some of the "edge" bounds on entrypoints where the resulting future can be conditionally `Send` depending on `T` meaning we don't actually have to write down any bounds ourselves.
This refactoring will enable future refactorings to have sync-and-async functions use the same internals and neither entrypoint needs to have a `Send` bound.
* Review comments
show more ...
|
| #
5f7cf53e |
| 18-Aug-2025 |
Alex Crichton <[email protected]> |
Make table growth a true `async fn` (#11442)
* Make table growth a true `async fn`
Upon further refactoring and thinking about #11430 I've realized that we might be able to sidestep `T: Send` on th
Make table growth a true `async fn` (#11442)
* Make table growth a true `async fn`
Upon further refactoring and thinking about #11430 I've realized that we might be able to sidestep `T: Send` on the store entirely which would be quite the boon if it can be pulled off. The realization I had is that the main reason for this was `&mut dyn VMStore` on the stack, but that itself is actually a bug in Wasmtime (#11178) and shouldn't be done. The functions which have this on the stack should actually ONLY have the resource limiter, if configured. This means that while the `ResourceLimiter{,Async}` traits need a `Send` supertrait that's relatively easy to add without much impact. My hunch is that plumbing this through to the end will enable all the benefits of #11430 without requiring adding `T: Send` to the store.
This commit starts out on this journey by making table growth a true `async fn`. A new internal type is added to represent a store's limiter which is plumbed to growth functions. This represents a hierarchy of borrows that look like:
* `StoreInner<T>` * `StoreResourceLimiter<'_>` * `StoreOpaque` * `Pin<&mut Instance>` * `&mut vm::Table`
This notably, safely, allows operating on `vm::Table` with a `StoreResourceLimiter` at the same time. This is exactly what's needed and prevents needing to have `&mut dyn VMStore`, the previous argument, on the stack.
This refactoring cleans up `unsafe` blocks in table growth right now which manually uses raw pointers to work around the borrow checker. No more now!
I'll note as well that this is just an incremental step. What I plan on doing next is handling other locations like memory growth, memory allocation, and table allocation. Each of those will require further refactorings to ensure that things like GC are correctly accounted for so they're going to be split into separate PRs. Functionally though this PR should have no impact other than a fiber is no longer required for `Table::grow_async`.
* Remove #[cfg] gate
show more ...
|
| #
aef5eeb5 |
| 12-Aug-2025 |
Alex Crichton <[email protected]> |
Refactor internals of table initialization and management (#11416)
* Refactor const-eval to use `Val`, not `ValRaw`
This commit refactors the evaluation of constant expressions during instantiation
Refactor internals of table initialization and management (#11416)
* Refactor const-eval to use `Val`, not `ValRaw`
This commit refactors the evaluation of constant expressions during instantiation for example to use `Val` instead of `ValRaw`. Previously the usage of `ValRaw` meant that wasm was disallowed from performing a GC during const evaluation, but currently constant expressions can indeed perform a GC. The goal of this commit is to lift this limitation. This is expected to be a minor slowdown for modules that hit this path, but most modules shouldn't hit this in a hot loop since LLVM doesn't generate modules that use this branch of const eval.
The usage of `Val` brings a number of benefits and refactorings associated with it:
* Const-evaluation is generally safer than before since everything is higher-level. * GC types in const-eval were almost already using `Val` meaning that there's actually fewer conversions now. * Instantiation code was refactored to use `wasmtime::*`-API types instead of low-level VM types. This deduplicates a good deal and lifts complexity out of the raw VM bits.
Another issue that this commit fixes is to change how table initialization is modeled internally in `vm::Instance::table_init_segment`. Previously this was done by removing the tables from an instance to get a split borrow into the store and the table. This is not valid though because if, during initialization, a GC is performed then the table is not present to find roots through the table. This function is refactored to scope borrows to within a loop instead of over a loop via various refactorings and such and usage of higher level APIs. This is again, like above, expected to pessimize performance but this is also not known to be a hot path for modules at this time.
* Remove the `TableElement` type
This commit is a refactoring of how tables work within Wasmtime to avoid funneling table elements through a `TableElement` enum internally. Instead methods are "exploded" to `grow_{gc_ref,func,cont}` which means, for example, funcrefs don't need a GcStore. The main motivation for this change was to avoid the idiom where `TableElement` represents a cloned, but unrooted, GC reference.
Prior to this commit there were a number of subtle bugs in the table code for Wasmtime where write barriers were forgotten on `table.init`, `table.set` (via the embedder API), and `table.grow`. While `table.fill` correctly handled the GC references it was awkward to get everything else working consistently so I opted to remove `TableElement` entirely to make it more clear that `&VMGcRef` is ubiquitously used meaning that the write barriers, for example, are the same as other parts of the Wasmtime codebase.
This has a few extra tests for "make sure this doesn't leak" to ensure that GC works correctly with new barriers in place.
* Fix some lints and warnings
* Fix wmemcheck build
* Review comments
* Optimize const eval and global initialization
* Fix compile
* Fix lints
show more ...
|
| #
3e1400e7 |
| 24-Jul-2025 |
Nick Fitzgerald <[email protected]> |
Tidy up `Table::copy_raw` cases (#11316)
The `match` makes the cases a lot more clear IMO, and additionally the conditions asserted in each branch become trivially obvious (they are exactly what was
Tidy up `Table::copy_raw` cases (#11316)
The `match` makes the cases a lot more clear IMO, and additionally the conditions asserted in each branch become trivially obvious (they are exactly what was matched upon for their associated branch) so I removed them.
I also made some minor copy-edit tweaks to some comments while I was here.
This would have just been a nitpick review comment on https://github.com/bytecodealliance/wasmtime/pull/11255 but I was traveling and didn't get a chance to leave review comments in a reasonable amount of time, so instead I am just fixing them up myself in this follow up.
show more ...
|
|
Revision tags: v35.0.0, v24.0.4, v33.0.2, v34.0.2 |
|
| #
f021346e |
| 17-Jul-2025 |
Alex Crichton <[email protected]> |
More table safety improvements (#11255)
* More table safety improvements
This is some more progress on #11179 aimed at improving the safety of management of tables internally within Wasmtime:
* `I
More table safety improvements (#11255)
* More table safety improvements
This is some more progress on #11179 aimed at improving the safety of management of tables internally within Wasmtime:
* `Instance::table_index` is removed as it can be replaced with data stored directly in the `VMTableImport` now. * `Instance::get_table` now returns `&mut Table` * `Instance::get_defined_table_with_lazy_init` now returns `&mut Table` * `Instance::with_defined_table_index_and_instance` now directly returns `DefinedTableIndex` plus `Pin<&mut Instance>`, codifying the ability to "laterally move" between instances. * `Instance::table_init_segment` was refactored to "take" the tables during initialization and replace them afterwards, resolving the split borrow issue and removing an `unsafe` block in the function.
cc #11179
* Improve safety of `Table::copy`
This commit fixes an issue in the previous commit with respect to Miri and Stacked Borrows. This does so by improving the safety of the `Table::copy`-related functions to all work mostly on safe code rather than unsafe references. Some minor amount of unsafety is still present but it is now clearly documented and easier to verify.
* Fix tests
show more ...
|
| #
ddfebe77 |
| 16-Jul-2025 |
Alex Crichton <[email protected]> |
Make `vm::Instance::get_defined_table_with_lazy_init` return a reference (#11215)
This commit updates the `get_defined_table_with_lazy_init` method to return a safe reference instead of a raw refere
Make `vm::Instance::get_defined_table_with_lazy_init` return a reference (#11215)
This commit updates the `get_defined_table_with_lazy_init` method to return a safe reference instead of a raw reference. This then cascaded outwards to updating more locations to handle this new safe reference as well. While this makes some further progress on #11179 there are a number of locations that will require using raw pointers until more refactoring is done.
show more ...
|
| #
2b832281 |
| 14-Jul-2025 |
Alex Crichton <[email protected]> |
Gut `vm::Export` to mostly be `crate::Extern` (#11229)
* Remove `Table::from_wasmtime_table`
This commit removes the unsafe function `Table::from_wasmtime_table`. This goes a bit further and remove
Gut `vm::Export` to mostly be `crate::Extern` (#11229)
* Remove `Table::from_wasmtime_table`
This commit removes the unsafe function `Table::from_wasmtime_table`. This goes a bit further and removes `ExportTable` entirely as well which means that table lookup on a `vm::Instance` directly returns a `wasmtime::Table` without any need to translate back-and-forth.
* Remove `Tag::from_wasmtime_tag`
Like the previous commit, but for tags.
* Remove `Global::from_wasmtime_global`
Like the previous commit, but for globals.
* Remove `Memory::from_wasmtime_memory`
Like the previous commit, but for memories.
* Remove `Func::from_wasmtime_function`
Like previous commits, but for functions.
* Fix lints
* Fill out missing safety comment
* Review comments
show more ...
|
| #
838ed2d0 |
| 07-Jul-2025 |
Alex Crichton <[email protected]> |
Enable `allow_attributes_without_reason` (#11195)
* Enable `allow_attributes_without_reason`
This commit enables the `clippy::allow_attributes_without_reason` for the `wasmtime` crate which previou
Enable `allow_attributes_without_reason` (#11195)
* Enable `allow_attributes_without_reason`
This commit enables the `clippy::allow_attributes_without_reason` for the `wasmtime` crate which previously forcibly allowed it. The reason this was allowed was that when the workspace was first migrated the Wasmtime crate had too many instances that I was willing to fix. I've now come back around and tried to fix everything.
In short: ideally delete `#[allow]`, otherwise use `#[expect]`, otherwise use `#[allow]`.
prtest:full
* Adjust some directives
* Fix some warnings
* Fix stack switching size tests on unix
* Don't have a conditional `Drop` impl
* Force `testing_freelist` method to be used
Too lazy to write `#[cfg]`, but not too lazy to write a test.
show more ...
|
|
Revision tags: v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0 |
|
| #
63d482c8 |
| 04-Jun-2025 |
Frank Emrich <[email protected]> |
Stack switching: Infrastructure and runtime support (#10388)
* [pr1] base
* prtest:full
* make sure to use ControlFlow result in trace_suspended_continuation
* stack-switching: cleanup: remove st
Stack switching: Infrastructure and runtime support (#10388)
* [pr1] base
* prtest:full
* make sure to use ControlFlow result in trace_suspended_continuation
* stack-switching: cleanup: remove stray c-api changes
These are remnants of unrelated wasmfx wasmtime experiments, possibly suitable for later submission against upstream.
* stack-switching: reuse async_stack_size
* stack-switching: delete delete_me debugging
* stack-switching: address feedback in environ::types
* stack-switching: remove unused code from vmoffsets
* stack-switching: drop dependency on std
* stack-switching: add compilation checks to ci matrix
* stack-switching: remove debug_println cruft
* stack-switching: export environ consts consistently
* stack-switching: export vm pub items consistently
* table_pool: reduced capacity for large elements
VMContRef elements which takes up two words and we don't want to double the size of all tables in order to support storing these. This change changes the table to target storing the requested max number of elements if they are "nominally" sized with (potentially) reduced capacity for non-nominally sized types when encountered.
Continuations are the only type of element which may result in fewer table slots being available than requested.
* stack-switching: extend conditional compilation
A fair bit of the definitions for stack switching are still enabled, but this patch takes things a bit further to avoid compilation problems; notably, cont_new is now not compiled in unless the feature is enabled.
* stack-switching: formatting fixes
* stack-switching: address new clippy checks
In addition, to get clippy to fully pass, plumbed in additional config to make winch paths happy; there's no impl for winch yet but plumbing through the feature is required to make paths incorporating macros at various layers satisfied (and it is expected we'll use the features in the future).
* stack-switching: more conditional compilation fixes
* stack-switching: additional conditional compile on table builtins for continuations
* stack-switching: additional conditional compile fixes
* stack-switching: additional conditional compile in store
* stack-switching: remove overly strict assertion
* stack-switching: remove errantly dropped no_mangle in config c-api
* stack-switching: VMContObj::from_raw_parts
* stack-switching: remove duplicate async_stack_size feature check
* stack-switching: VMArray -> VMHostArray
* stack-switching: remove unnecessary clippy exception
* stack-switching: fix docs referenced VMRuntimeLimits
* stack-switching: fix doc typo
* stack-switching: follow recommendations for type casts
* stack-switching: use usize::next_multiple_of
* stack-switching: update outdated comment
* stack-switching: use feature gate instead of allow(dead_code)
* stack-switching: rework backtrace using chunks/zip
* stack-switching: move tests to footer module
This is a bit more consistent with the prevailing style in tree and (subjectively) makes finding the tests as a reader more straightforward.
Tests left unchanged sans some import cleanup.
* stack-swictchding: verify stack_chain offsets at runtime
* fixup! stack-switching: use feature gate instead of allow(dead_code)
* stack-switching: document continuation roots tracing using match arms
---------
Co-authored-by: Paul Osborne <[email protected]>
show more ...
|
| #
5603ee7b |
| 03-Jun-2025 |
Alex Crichton <[email protected]> |
Change component/instance maps to `PrimaryMap` (#10916)
* Change component/instance maps to `PrimaryMap`
This switches to using typed keys for these maps to be more idiomatic with the rest of Wasmt
Change component/instance maps to `PrimaryMap` (#10916)
* Change component/instance maps to `PrimaryMap`
This switches to using typed keys for these maps to be more idiomatic with the rest of Wasmtime and this has the additional benefit of compressing indices to 32-bits instead of the previous pointer-sized-bits.
* Fix an unused import
show more ...
|
| #
e012eeda |
| 03-Jun-2025 |
Alex Crichton <[email protected]> |
Remove Stored from wasmtime::Instance (#10909)
* Remove the "export cache" on instances
This is now a relic of the past now that conversion from the internal to external representation of Wasmtime
Remove Stored from wasmtime::Instance (#10909)
* Remove the "export cache" on instances
This is now a relic of the past now that conversion from the internal to external representation of Wasmtime items is free. This is effectively dead code that is no longer needed.
* Remove `Stored` from `wasmtime::Instance`
Powered by all previous commits this is a near-trivial change where an `Instance` is now more-or-less "just" an `InstanceId`. Additionally the `host_state: Box<dyn Any>` is no longer needed within `vm::Instance` so that was removed as well.
show more ...
|
| #
132a1a53 |
| 03-Jun-2025 |
Alex Crichton <[email protected]> |
Replace `as usize` with `.addr()` (#10908)
Rust has since added provenance-related APIs so this is a more intent-ful way to cast a pointer to an integer.
|
| #
a30e7299 |
| 03-Jun-2025 |
Alex Crichton <[email protected]> |
Update the definition of `wasmtime::Table` (#10903)
This commit is similar to a prior commit modifying memories which refactors the internals of `wasmtime::Table` to not longer use a `Stored` index.
Update the definition of `wasmtime::Table` (#10903)
This commit is similar to a prior commit modifying memories which refactors the internals of `wasmtime::Table` to not longer use a `Stored` index. Instead a `StoreInstanceId` and a `DefinedTableIndex` is used instead. This enables construction of external-facing types to be trivial and zero-cost.
This additionally notably fixes an issue where triggering a GC in a store would unconditionally create a `Table`, pushing onto an internal vector in the store. This then would never be deallocated because the internal table lived as long as the `Store`. In effect this meant that triggering a GC would end up leaking memory by pushing more items onto internal `Store` table. This is fixed through this commit because creating a `wasmtime::Table` is now "free" and no longer requires any allocations.
show more ...
|
| #
46306693 |
| 02-Jun-2025 |
Alex Crichton <[email protected]> |
Add a `DefinedTableIndex` to table imports/exports (#10879)
This commit extends `ExportTable` and `VMTableImport` (renamed from `VMTable`) to include a `DefinedTableIndex` in the same manner that me
Add a `DefinedTableIndex` to table imports/exports (#10879)
This commit extends `ExportTable` and `VMTableImport` (renamed from `VMTable`) to include a `DefinedTableIndex` in the same manner that memories carry their index they're defined at as well. The main goal of this change is to power the next change which will update how tables are stored in a store.
show more ...
|
|
Revision tags: v33.0.0 |
|
| #
90ac295e |
| 19-May-2025 |
Alex Crichton <[email protected]> |
Update Wasmtime to the 2024 Rust Edition (#10806)
* Update Wasmtime to the 2024 Rust Edition
Now that our MSRV supports the 2024 edition it's possible to make this switch. This commit moves Wasmtim
Update Wasmtime to the 2024 Rust Edition (#10806)
* Update Wasmtime to the 2024 Rust Edition
Now that our MSRV supports the 2024 edition it's possible to make this switch. This commit moves Wasmtime to the 2024 Edition to keep up-to-date with Rust idioms and access many of the edition features exclusive to the 2024 edition.
prtest:full
* Reformat with the 2024 edition
show more ...
|
| #
f81c0dc0 |
| 13-May-2025 |
Alex Crichton <[email protected]> |
Add `T: 'static` to `Store<T>` (#10760)
* Add `T: 'static` to `Store<T>
Since the beginning the `T` type parameter on `Store<T>` has had no bounds on it. This was intended for maximal flexibility i
Add `T: 'static` to `Store<T>` (#10760)
* Add `T: 'static` to `Store<T>
Since the beginning the `T` type parameter on `Store<T>` has had no bounds on it. This was intended for maximal flexibility in terms of what embedders place within a `Store<T>` and I've personally advocated that we need to keep it this way. In the development of the WASIp3 work, however, I've at least personally reached the conclusion that this is no longer tenable and proceeding will require adding a `'static` bound to data within a store.
Wasmtime today [already] carries unsafe `transmute`s to work around this lack of `'static` bound, and while the number of `unsafe` parts is relatively small right now we're still fundamentally lying to the compiler about lifetime bounds internally. With the WASIp3 async work this degree of "lying" has become even worse. Joel has written up some examples [on Zulip] about how the Rust compiler is requiring `'static` bounds in surprising ways. These patterns are cropping up quite frequently in the WASIp3 work and it's becoming particularly onerous maintaining all of the `unsafe` and ensuring that everything is in sync.
In the WASIp3 repository I've additionally [prototyped a change] which would additionally practically require `T: 'static` in more locations. This change is one I plan on landing in Wasmtime in the near future and while its main motivations are for enabling WASIp3 work it is also a much nicer system than what we have today, in my opinion.
Overall the cost of not having `T: 'static` on `Store<T>` is effectively becoming quite costly, in particular with respect to WASIp3 work. This is coupled with all known embedders already using `T: 'static` data within a `Store<T>` so the expectation of the impact of this change is not large. The main downside of this change as a result is that when and where to place `'static` bounds is sort of a game of whack-a-mole with the compiler. For example I changed `Store<T>` to require `'static` here, but the rest of the change is basically "hit compile until rustc says it's ok". There's not necessarily a huge amount of rhyme-or-reason to where `'static` bounds crop up, which can be surprising or difficult to work with for users.
In the end I feel that this change is necessary and one we can't shy away from. If problems crop up we'll need to figure out how to thread that needle at that time, but I'm coming around to thinking that `T: 'static` is just a fundamental constraint we'll have to take on at this time. Maybe a future version of Rust that fixes some of Joel's examples (if they can be fixed, we're not sure of that) we could consider relaxing this but that's left for future work.
[already]: https://github.com/bytecodealliance/wasmtime/blob/35053d6d8d1a5d4692cf636cba0c920b4a79a44b/crates/wasmtime/src/runtime/store.rs#L602-L611 [on Zulip]: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.22type.20may.20not.20live.20long.20enough.22.20for.20generic.20closure/near/473862072 [prototyped a change]: https://github.com/bytecodealliance/wasip3-prototyping/pull/158
* Remove a no-longer-necessary `unsafe` block
* Update test expectations
* Fix gc-disabled builds
show more ...
|
|
Revision tags: v32.0.0 |
|
| #
a4700cb7 |
| 02-Apr-2025 |
Nick Fitzgerald <[email protected]> |
Analyze whether a module requires a GC heap during its compilation (#10508)
* Analyze whether a module requires a GC heap during its compilation
And avoid forcing the allocation of a GC heap for mo
Analyze whether a module requires a GC heap during its compilation (#10508)
* Analyze whether a module requires a GC heap during its compilation
And avoid forcing the allocation of a GC heap for modules that will not use it.
Split out from https://github.com/bytecodealliance/wasmtime/issues/9350
* Simplify condition for allocating GC heap
show more ...
|