|
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, v43.0.0, v42.0.1, 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, v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3 |
|
| #
e069bdd3 |
| 23-Oct-2025 |
Nick Fitzgerald <[email protected]> |
`CodeBuilder` APIs for defining compile-time builtins (#11918)
* `CodeBuilder` APIs for defining compile-time builtins
Compile-time builtins, as described in [the RFC](https://github.com/bytecodeal
`CodeBuilder` APIs for defining compile-time builtins (#11918)
* `CodeBuilder` APIs for defining compile-time builtins
Compile-time builtins, as described in [the RFC](https://github.com/bytecodealliance/rfcs/blob/main/accepted/wasmtime-compile-time-builtins.md), are effectively the sum of three parts:
1. Function inlining 2. Unsafe intrinsics 3. Component composition
The first two have already been implemented in Wasmtime. This commit implements the final part, leveraging `wasm-compose` to link host-defined compile-time builtin components with guest-defined main components. It exposes Wasmtime's unsafe intrinsics only to the host-defined compile-time builtins, not the guest-defined main Wasm component.
Why `wasm-compose` and not `wac`? Because it is in the same repo as the rest of the `wasm-tools` crates, and therefore it is easy to depend on without bringing in duplicate copies of that family of crates into our workspace and builds. Also its programmatic API is somewhat easier to use, and is not spread across multiple crates.
* Fix unused lifetime in `cfg(not(feature = "compile-time-builtins"))`
* Fix an unused warning when `cfg(not(feature = "compile-time-builtins"))`
* Add cargo vet audit for `fixedbitset` version `0.4.2`
* Add cargo vet audit for `bitmaps` version 2.10.0
* Add cargo vet audit for `sized-chunks` diff `0.6.5 -> 0.7.0`
* Add/tweak cargo vet exemptions for some deps
These all have >10,000 daily downloads, and so are okay to exempt per our policy: https://docs.wasmtime.dev/contributing-coding-guidelines.html#policy-for-adding-cargo-vet-entries
* Add cargo vet audit for `wasm-compose` diff `0.236.0 -> 0.238.1`
Don't know why I have to do this certification even though we have a wildcard audit for this crate because it is authored by the Bytecode Alliance...
* Fix visibility of type
* Move compile-time builtins methods to module to cut down on `cfg`s
* Skip checking `heck` in `cargo deny`
Until https://github.com/bytecodealliance/wasm-tools/pull/2359 is merged, released, and updated in this tree.
* Always read compile-time inputs
* Tighten up parse loop and level tracking
* as_deref instead of clone
* Remove 'b lifetime from CodeBuilder
* fix `cfg(not(feature = "compile-time-builtins"))` build
* Ignore tests that run wasm when in MIRI
show more ...
|
|
Revision tags: v38.0.2, v38.0.1 |
|
| #
ad56ff98 |
| 17-Oct-2025 |
Nick Fitzgerald <[email protected]> |
Implement unsafe intrinsics for compile-time builtins (#11825)
* Implement unsafe intrinsics for compile-time builtins
This commit adds the extremely unsafe `wasmtime::CodeBuilder::expose_unsafe_in
Implement unsafe intrinsics for compile-time builtins (#11825)
* Implement unsafe intrinsics for compile-time builtins
This commit adds the extremely unsafe `wasmtime::CodeBuilder::expose_unsafe_intrinsics` method. When enabled, the Wasm being compiled is given access to special imports that correspond to direct, unchecked and unsandboxed, native load and store operations. These intrinsics are intended to be used for implementing fast, inline-able versions of WASI interfaces that are special-cased to a particular host embedding, for example.
Compile-time builtins, as originally described in [the RFC](https://github.com/bytecodealliance/rfcs/pull/43), are basically made up of three parts:
1. A function inliner 2. Unsafe intrinsics 3. Component composition to encapsulate the usage of unsafe intrinsics in a safe interface
Part (1) has been implemented in Wasmtime and Cranelift for a little while now (see `wasmtime::Config::compiler_inlining`). This commit is part (2). After this commit lands, part (3) can be done with `wac` and `wasm-compose`, although follow up work is required to make the developer experience nicer and more integrated into Wasmtime so that the APIs can look like those proposed in the RFC.
* fill out some more docs
* fix non component model builds
* start filling out the doc example
* Factor abi params/returns out; truncate/extend pointers
* Compile unsafe intrinsics on winch as well
* prtest:full
* have the macro define the signature
* ignore tests in MIRI because MIRI can't compile Wasm
* juggle pointer provenance in `Store::data[_mut]`
* add a test for store data provenance and also fix it
* use `VmPtr` for the store data pointer
* finish writing unsafe intrinsics example
* fix up docs and rules around only accessing data from `T` in a `Store<T>`
* Only reserve space for the intrinsics' `VMFuncRef`s if they are in use
* use dangling pointers instead of options
* Rename `StoreInner::data` to `data_no_provenance` and fix some accesses to use the method accessors
* Add comments about the provenance juggling inside `StoreInner::data[_mut]`
* only compile intrinsics that are used
Turns out we don't need to add phases, we already have the info available to do this.
* fix duplicate symbol names
show more ...
|
|
Revision tags: v37.0.2, v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0, v35.0.0, v24.0.4, v33.0.2, v34.0.2, v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0 |
|
| #
703871a2 |
| 27-May-2025 |
Alex Crichton <[email protected]> |
Enable the `useless_conversion` Clippy lint (#10838)
* Enable the `useless_conversion` Clippy lint
We've got lots of types in Wasmtime and convert between them quite a lot, but often over time conv
Enable the `useless_conversion` Clippy lint (#10838)
* Enable the `useless_conversion` Clippy lint
We've got lots of types in Wasmtime and convert between them quite a lot, but often over time conversions become unnecessary through refactorings or similar. This will hopefully enable us to clean up some conversions as they come up to try to have as few as possible ideally.
* Review comments
show more ...
|
|
Revision tags: v33.0.0 |
|
| #
2cd52b76 |
| 29-Apr-2025 |
Ben Brandt <[email protected]> |
Allow creation of a CacheConfig without loading from a file (#10665)
* cache: Add builder pattern for CacheConfig
* wasmtime: Add cache_config method to wasmtime::Config
* Refactor test_builder_de
Allow creation of a CacheConfig without loading from a file (#10665)
* cache: Add builder pattern for CacheConfig
* wasmtime: Add cache_config method to wasmtime::Config
* Refactor test_builder_default to use test_prolog helper
* Remove enabled option from CacheConfigBuilder and always set to true
* Change builder methods to take &mut self and return &mut Self
* Simplify cache configuration API
A new `cache_config(Option<CacheConfig>)` method replaces multiple methods for controlling module caching. Now `None` disables caching, and users can directly provide a cache config or load one from a file.
* Make cache configuration optional
* Add Cache struct to separate configuration from runtime (wip)
* Ensure default values earlier
* Consolidate CacheConfig and CacheConfigBuilder
* Set Cache directly on wastime::Config and make it easier to create one from a file
* Validate after loading file again
* Move cache to top-level module
* Fix tests
show more ...
|
|
Revision tags: v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0 |
|
| #
6dae7eb8 |
| 28-Jan-2025 |
Alex Crichton <[email protected]> |
Enable warnings if `cache` is disabled (#10140)
Continuation of work in #10131
|
|
Revision tags: v29.0.1, v29.0.0, v28.0.1, v28.0.0 |
|
| #
5eee6313 |
| 10-Dec-2024 |
Chris Fallin <[email protected]> |
Wasmtime: support a notion of "custom code publisher". (#9778)
* Wasmtime: support a notion of "custom code publisher".
In some `no_std` environments, virtual memory usage is *generally* prohibited
Wasmtime: support a notion of "custom code publisher". (#9778)
* Wasmtime: support a notion of "custom code publisher".
In some `no_std` environments, virtual memory usage is *generally* prohibited for performance-predictability reasons, but the MMU hardware is still in use for permissions (e.g., `W^X` write-xor-execute). Occasional changes to page mapping permissions are thus necessary when new modules are loaded dynamically, and are acceptable in that context. Wasmtime needs a way to support "publishing" code (making it executable) in such environments.
Rather than try to segment the `signals-based-traps` divide further, and piece out the code-publishing parts from the heap parts, and backdoor a path to `mprotect` in an otherwise `no_std` build, in this PR I have opted to add a trait an impl of which the embedder can provide to the `Config` to implement custom actions for "code publish". This otherwise operates properly in a no-`signals-based-traps` environment, e.g., the module backing memory itself is regularly allocated rather than mmap'd (but is now aligned to the degree requested by the trait impl).
* Review feedback.
* Plumb through custom alignment for runtime code generation
* Add a test for custom code memory.
show more ...
|
|
Revision tags: v27.0.0 |
|
| #
d3132c9d |
| 19-Nov-2024 |
Alex Crichton <[email protected]> |
Add a `signals-based-traps` Cargo compile-time feature (#9614)
* Gate signal handlers behind a new Cargo feature
This commit adds a new on-by-default Cargo feature to the `wasmtime` crate named `si
Add a `signals-based-traps` Cargo compile-time feature (#9614)
* Gate signal handlers behind a new Cargo feature
This commit adds a new on-by-default Cargo feature to the `wasmtime` crate named `signals-based-traps`. This is modeled after the `Config::signals_based_traps` configuration at runtime and can be used to statically disable the use of signal handlers in Wasmtime. This notably reduces the number of platform dependencies that Wasmtime has and provides a mode of avoiding relying on signals altogether.
This introduces a new `MallocMemory` which is a linear memory backed by the system allocator. This new type of memory is enabled when virtual memory guards are disabled and signals-based-traps are disabled. This means that this new type of memory will be candidate for fuzzing for example.
prtest:full
* Fix rebase conflict
* Refactor `MmapVec` documentation and representation
* Remove no-longer-needed `Arc` * Document it may be backed by `Vec<u8>`
show more ...
|
|
Revision tags: v26.0.1, v25.0.3, v24.0.2, v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0, v24.0.0 |
|
| #
f673cde3 |
| 14-Aug-2024 |
Alex Crichton <[email protected]> |
Refactor use of `CodeBuilder` on the CLI (#9125)
* Refactor use of `CodeBuilder` on the CLI
This commit refactors `wasmtime run` and `wasmtime compile` to unconditionally use `CodeBuilder` internal
Refactor use of `CodeBuilder` on the CLI (#9125)
* Refactor use of `CodeBuilder` on the CLI
This commit refactors `wasmtime run` and `wasmtime compile` to unconditionally use `CodeBuilder` internally. This will in theory help out in the future if more debug-related options are added to `CodeBuilder` for example. This refactoring required some changes to `CodeBuilder` to be able to support a query about whether the internal bytes were a component or a module. The text format is now converted to binary immediately when supplied rather than during the compilation phase. This in turn required some API changes to make the selection of supporting the text format a compile-time choice of method rather than a runtime value.
* Fix compile
* Fix no-cranelift build of CLI
show more ...
|
|
Revision tags: v23.0.2, v23.0.1, v23.0.0, v22.0.0 |
|
| #
1512a954 |
| 14-Jun-2024 |
Nick Fitzgerald <[email protected]> |
Add `anyhow` stuff to our internal `wasmtime` crate prelude (#8804)
* Add `anyhow` stuff to our internal `wasmtime` crate prelude
We use it basically everywhere and it is annoying to have to import
Add `anyhow` stuff to our internal `wasmtime` crate prelude (#8804)
* Add `anyhow` stuff to our internal `wasmtime` crate prelude
We use it basically everywhere and it is annoying to have to import.
I also did an audit of existing `use` statements and removed the now-redundant ones and replaced one-off imports with usage of the prelude, so that the prelude is available by default in more places.
* Fix `cargo doc`
show more ...
|
|
Revision tags: v21.0.1, v21.0.0 |
|
| #
1d11b265 |
| 17-May-2024 |
Alex Crichton <[email protected]> |
Remove the native ABI calling convention from Wasmtime (#8629)
* Remove the native ABI calling convention from Wasmtime
This commit proposes removing the "native abi" calling convention used in Was
Remove the native ABI calling convention from Wasmtime (#8629)
* Remove the native ABI calling convention from Wasmtime
This commit proposes removing the "native abi" calling convention used in Wasmtime. For background this ABI dates back to the origins of Wasmtime. Originally Wasmtime only had `Func::call` and eventually I added `TypedFunc` with `TypedFunc::call` and `Func::wrap` for a faster path. At the time given the state of trampolines it was easiest to call WebAssembly code directly without any trampolines using the native ABI that wasm used at the time. This is the original source of the native ABI and it's persisted over time under the assumption that it's faster than the array ABI due to keeping arguments in registers rather than spilling them to the stack.
Over time, however, this design decision of using the native ABI has not aged well. Trampolines have changed quite a lot in the meantime and it's no longer possible for the host to call wasm without a trampoline, for example. Compilations nowadays maintain both native and array trampolines for wasm functions in addition to host functions. There's a large split between `Func::new` and `Func::wrap`. Overall, there's quite a lot of weight that we're pulling for the design decision of using the native ABI.
Functionally this hasn't ever really been the end of the world. Trampolines aren't a known issue in terms of performance or code size. There's no known faster way to invoke WebAssembly from the host (or vice-versa). One major downside of this design, however, is that `Func::new` requires Cranelift as a backend to exist. This is due to the fact that it needs to synthesize various entries in the matrix of ABIs we have that aren't available at any other time. While this is itself not the worst of issues it means that the C API cannot be built without a compiler because the C API does not have access to `Func::wrap`.
Overall I'd like to reevaluate given where Wasmtime is today whether it makes sense to keep the native ABI trampolines. Sure they're supposed to be fast, but are they really that much faster than the array-call ABI as an alternative? This commit is intended to measure this.
This commit removes the native ABI calling convention entirely. For example `VMFuncRef` is now one pointer smaller. All of `TypedFunc` now uses `*mut ValRaw` for loads/stores rather than dealing with ABI business. The benchmarks with this PR are:
* `sync/no-hook/core - host-to-wasm - typed - nop` - 5% faster * `sync/no-hook/core - host-to-wasm - typed - nop-params-and-results` - 10% slower * `sync/no-hook/core - wasm-to-host - typed - nop` - no change * `sync/no-hook/core - wasm-to-host - typed - nop-params-and-results` - 7% faster
These numbers are a bit surprising as I would have suspected no change in both "nop" benchmarks as well as both being slower in the params-and-results benchmarks. Regardless it is apparent that this is not a major change in terms of performance given Wasmtime's current state. In general my hunch is that there are more expensive sources of overhead than reads/writes from the stack when dealing with wasm values (e.g. trap handling, store management, etc).
Overall this commit feels like a large simplification of what we currently do in `TypedFunc`:
* The number of ABIs that Wasmtime deals with is reduced by one. ABIs are pretty much always tricky and having fewer moving parts should help improve the understandability of the system. * All of the `WasmTy` trait methods and `TypedFunc` infrastructure is simplified. Traits now work with simple `load`/`store` methods rather than various other flavors of conversion. * The multi-return-value handling of the native ABI is all gone now which gave rise to significant complexity within Wasmtime's Cranelift translation layer in addition to the `TypedFunc` backing traits. * This aligns components and core wasm where components always use the array ABI and now core wasm additionally will always use the array ABI when communicating with the host.
I'll note that this still leaves a major ABI "complexity" with respect to native functions do not have a wasm ABI function pointer until they're "attached" to a `Store` with a `Module`. That's required to avoid needing Cranelift for creating host functions and that property is still true today. This is a bit simpler to understand though now that `Func::new` and `Func::wrap` are treated uniformly rather than one being special-cased.
* Fix miri unsafety
prtest:full
show more ...
|
|
Revision tags: v20.0.2, v20.0.1 |
|
| #
964f8986 |
| 03-May-2024 |
Alex Crichton <[email protected]> |
Use rustdoc's `doc_auto_cfg` feature instead of `doc_cfg` (#8532)
This commit removes all our `#[cfg_attr(..., doc(cfg(...)))]` annotations throughout Wasmtime and `wasmtime-wasi`. These are all rep
Use rustdoc's `doc_auto_cfg` feature instead of `doc_cfg` (#8532)
This commit removes all our `#[cfg_attr(..., doc(cfg(...)))]` annotations throughout Wasmtime and `wasmtime-wasi`. These are all replaced with `feature(doc_auto_cfg)` which automatically infers the attribute to show rather than requiring us to duplicate it. Spot-checking the docs this looks just-as-readable while being much easier to maintain over time.
show more ...
|
| #
72004aad |
| 30-Apr-2024 |
Nick Fitzgerald <[email protected]> |
Turn the `wasmtime-runtime` crate into the `wasmtime::runtime::vm` module (#8501)
* Expose `wasmtime-runtime` as `crate::runtime::vm` internally for the `wasmtime` crate
* Rewrite uses of `wasmtime
Turn the `wasmtime-runtime` crate into the `wasmtime::runtime::vm` module (#8501)
* Expose `wasmtime-runtime` as `crate::runtime::vm` internally for the `wasmtime` crate
* Rewrite uses of `wasmtime_runtime` to `crate::runtime::vm`
* Remove dep on `wasmtime-runtime` from `wasmtime-cli`
* Move the `wasmtime-runtime` crate into the `wasmtime::runtime::vm` module
* Update labeler for merged crates
* Fix `publish verify`
prtest:full
show more ...
|
| #
fb4f4cd3 |
| 24-Apr-2024 |
yowl <[email protected]> |
Add initial support for DWARF Fission (#8055)
* add cloning for String attributes
* use into_owned instead of to_vec to avoid a clone if possible.
* runs, but does not substitute
* show vars from
Add initial support for DWARF Fission (#8055)
* add cloning for String attributes
* use into_owned instead of to_vec to avoid a clone if possible.
* runs, but does not substitute
* show vars from c program, start cleanup
* tiday
* resolve conflicts
* remove WASI folder
* Add module_builder
add dwarf_package to state for cache
* move dwarf loading to module_environ.rs
pass the dwarf as binary as low as module_environ.rs
* pass dwarf package rather than add to debug_info
* tidy option/result nested if
* revert some toml and whitespace.
* add features cranelift,winch to module_builder and compute_artifacts
remove some `use`s
* address some feedback
remove unused 'use's
* address some feedback
remove unused 'use's
* move wat feature condition to cover whole method.
* More feedback
Another try at wat feature move
* Another try at wat feature move
* change gimli exemption version
add typed-arena exemption
* add None for c-api
* move `use` to #cfg
* fix another config build
* revert unwanted code deletion
* move inner function closer to use
* revert extra param to Module::new
* workaround object crate bug.
* add missing parameter
* add missing parameter
* Merge remote-tracking branch 'origin/main' into dwarf-att-string
# Conflicts: # crates/wasmtime/src/engine.rs # crates/wasmtime/src/runtime/module.rs # src/common.rs
* remove moduke
* use common gimli version of 28.1
* remove wasm feature, revert gimli version
* remove use of object for wasm dwarf
* remove NativeFile workaround, add feature for dwp loading
* sync winch signature
* revert bench api change
* add dwarf for no cache feature
* put back merge loss of module kind
* remove param from docs
* add dwarf fission lldb test
* simplify and include test source
* clang-format
* address feedback, remove packages
add docs simplify return type
* remove Default use on ModuleTypesBuilder
* Remove an `unwrap()` and use `if let` instead
* Use `&[u8]` instead of `&Vec<u8>`
* Remove an `unwrap()` and return `None` instead
* Clean up some code in `transform_dwarf`
* Clean up some code in `replace_unit_from_split_dwarf`
* Clean up some code in `split_unit`
* Minor refactorings and documentation in `CodeBuilder`
* Restrict visibility of `dwarf_package_binary`
* Revert supply-chain folder changes
* Fix compile error on nightly
* prtest:full
* prtest:full
* prtest:full
* prtest:full
* prtest:full
* prtest:full
* prtest:full
* prtest:full
* use lldb 15
* prtest:full
* prtest:full
* load dwp when loading wasm bytes with path
* correct source file name
* remove debug
---------
Co-authored-by: Alex Crichton <[email protected]>
show more ...
|
|
Revision tags: v20.0.0, v17.0.3, v19.0.2, v18.0.4, v19.0.1 |
|
| #
1a7de7cc |
| 28-Mar-2024 |
Alex Crichton <[email protected]> |
Add a `compile` feature to `wasmtime-environ` (#8250)
* Add a `compile` feature to `wasmtime-environ`
This commit adds a compile-time feature to remove some dependencies of the `wasmtime-environ` c
Add a `compile` feature to `wasmtime-environ` (#8250)
* Add a `compile` feature to `wasmtime-environ`
This commit adds a compile-time feature to remove some dependencies of the `wasmtime-environ` crate. This compiles out support for compiling modules/components and makes the crate slimmer in terms of amount of code compiled along with its dependencies. Much of this should already have been statically removed by native linkers so this likely won't have any compile-size impact, but it's a nice-to-have in terms of organization.
This has a fair bit of shuffling around of code, but apart from renamings and movement there are no major changes here.
* Fix compile issue
* Gate `ModuleTranslation` and its methods on `compile`
* Fix doc link
* Fix doc link
show more ...
|