* vet: prune lockfile
When running `cargo vet` in #7900, it warned me that we should consider
pruning some unused entries, etc. This is the result of running `cargo
vet prune`.
* vet: a couple more post-#7908
* x64: Refactor multiplication instructions
This commit is inspired after reading over some code from #7865
and #7866. The goal of this commit was to refactor
scalar multiplication-related instructions in the x64 backend to more
closely align with their native instructions. Changes include:
* The `MulHi` instruction is renamed to `Mul`. This represents either
`mul` or `imul` producing a doublewide result.
* A `Mul8` instruction was added to correspond to `Mul` for the 8-bit
variants that produce a doublewide result in the `AX` register rather
than the other instructions which split between `RAX` and `RDX`.
* The `UMulLo` instruction was removed as now it's covered by `Mul`
* The `AluRmiROpcode::Mul` opcode was removed in favor of new `IMul` and
`IMulImm` instructions. Register allocation and emission already had
special cases for `Mul` which felt better as standalone instructions
rather than putting in an existing variant.
Lowerings using `imul` are not affected in general but the `IMulImm`
instruction has different register allocation behavior than before which
allows the destination to have a different register than the first
operand. The `umulhi` and `smulhi` instructions are also reimplemented
with their 8-bit variants instead of extension-plus-16-bit variants.
* Remove outdated emit tests
These are all covered by the filetests framework now too.
* Fix Winch build
* Refactor `wasmtime::FuncType` to hold a handle to its registered type
Rather than holding a copy of the type directly, it now holds a `RegisteredType`
which internally is
* A `VMSharedTypeIndex` pointing into the engine's types registry.
* An `Arc` handle to the engine's type registry.
* An `Arc` handle to the actual type.
The last exists only to keep it so that accessing a `wasmtime::FuncType`'s
parameters and results fast, avoiding any new locking on call hot paths.
This is helping set the stage for further types and `TypeRegistry` refactors
needed for Wasm GC.
* Update the C API for the function types refactor
prtest:full
* rustfmt
* Fix benches build
* winch: Add support for WebAssembly loads/stores
Closes https://github.com/bytecodealliance/wasmtime/issues/6529
This patch adds support for all the instructions involving WebAssembly
loads and stores for 32-bit memories. Given that the `memory64` proposal
is not enabled by default, this patch doesn't include an
implementation/tests for it; in theory minimal tweaks to the
currrent implementation will be needed in order to support 64-bit
memories.
Implemenation-wise, this change, follows a similar pattern as Cranelift
in order to calculate addresses for dynamic/static heaps, the main
difference being that in some cases, doing less work at compile time is
preferred; the current implemenation only checks for the general case of
out-of-bounds access for dynamic heaps for example.
Another important detail regarding the implementation, is the
introduction of `MacroAssembler::wasm_load` and
`MacroAssembler::wasm_store`, which internally use a common
implemenation for loads and stores, with the only difference that the
`wasm_*` variants set the right flags in order to signal that these
operations are not trusted and might trap.
Finally, given that this change introduces support for the last set of
instructions missing for a Wasm MVP, it removes most of Winch's copy of
the spectest suite, and switches over to using the official test suite
where possible (for tests that don't use SIMD or Reference Types).
Follow-up items:
* Before doing any deep benchmarking I'm planning on landing a couple of
improvements regarding compile times that I've identified in parallel
to this change.
* The `imports.wast` tests are disabled because I've identified a bug
with `call_indirect`, which is not related to this change and exists
in main.
* Find a way to run the `tests/all/memory.rs` (or perhaps most of
integration tests) with Winch.
--
prtest:full
* Review comments
Purely mechanical, not functional changes.
This better matches the wording of the spec and of `wasmparser`, especially as
we prepare to implement Wasm GC, where there can be references to concrete types
that are not functions (and are structs or arrays instead).
In #7846 I added `cargo-vet` entries to trust the `windows` crate, just
like we already trust several related `windows-*` crates. I did not,
however, update the lockfile, which means that #7807 continued to fail
the `cargo vet --locked` CI check. This change is the result of simply
running `cargo vet`.
Add a test to expose issues with unbounded recursion through `iadd`
during egraph rewrites, and bound the recursion of
`will_simplify_with_ireduce`.
Fixes#7874
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
* Add function accepting explicit CPU delta time to GuestProfiler
* Remove unused import
* Modify existing signature instead of adding new
* Use qualified Duration instead of import to prevent unused warnings when building without features
* Fix a few egraph rules that needed `subsume`
There were a few rules that dropped value references from the LHS
without using subsume. I think they were probably benign as they
produced constant results, but this change is in the spirit of our
revised guidelines for egraph rules.
* Augment egraph rule guideline 2 to talk about constants
* Cranelift: Use a fixpoint loop to compute the best value for each eclass
Fixes#7857
* Remove fixpoint loop early-continue optimization
* Add document describing optimization rule invariants
* Make select optimizations use subsume
* Remove invalid debug assert
* Remove now-unused methods
* Add commutative adds to cost tests
* Add wasmtime-c-api-impl to the list of crates to publish
* Enable rustdoc and publishing for c-api crate
* Provide paths to c-api headers as cargo links metadata
* Add a README section about using wasm-c-api in a rust crate
* In C API doc comment, mention use case for crates w/ C bindings
* Enable publishing for wasmtime-c-api-macros (prtest:full)
* Move c-api crates later in the publishing sequence (prtest:full)
Looks like it's been awhile since our last update. I've updated the
dependency here and additionally vetted the various dependency upgrades.
I notably did not vet `zstd-sys` since that would require vetting all of
zstd's C implementation itself which I am not, nor do I suspect many of
are, equipped to do. In lieu of that I've updated the exemption of
`zstd-sys` to the newer version.
Closes#7869
* Update and add lots of docs, mostly for components
When I originally implemented the embedding API for the component model
I left a lot of `// TODO: say more here` style comments assuming I'd
come back around before stabilization. While I didn't quite make it in
time for Wasmtime 17 this is my attempt to improve things for the
future. This should add substantive documentation for all component-model
related things and flesh out some more details here and there. Nowhere
near comprehensive but, hey, Rome wasn't built in a day either.
* Update crates/wasmtime/src/runtime/component/component.rs
Co-authored-by: Jeff Parsons <jeff@parsons.io>
* Update crates/wasmtime/src/runtime/component/component.rs
Co-authored-by: Jeff Parsons <jeff@parsons.io>
---------
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Co-authored-by: Jeff Parsons <jeff@parsons.io>
* Add C API for GuestProfiler
* GuestProfiler C API: remove unsafe and add docs
* Fix clang-format complaints
* rename to wasmtime_guestprofiler_t for consistency, change to passing tuples by struct type, clarify docs
* rustfmt
* out is marked "own" too
* gate on profiling feature
* mpk: enable MPK if available in CI
After discussing several options for testing MPK in CI, this stopgap
measure at least provides some coverage. Other options include
maintaining a separate MPK-enabled CI runner (configuration is not
transparent, hard to maintain) or running the MPK-enabled tests in a
system-mode QEMU VM (tricky to get right, also hard to maintain). For
now, those of us at the Cranelift meeting agreed this at least gets some
CI testing for the MPK bits, which shouldn't be changing too often.
Since not all GitHub runners have MPK available, we only set the
`WASMTIME_TEST_FORCE_MPK` environment variable when it is. This change
also emits a warning to the GitHub logs in either case for easier
troubleshooting (e.g., to attempt to provide context if MPK logic breaks
and is only found in a later CI run).
prtest:full
* review: create a separate matrix entry
As requested by @alexcrichton, this change limits the MPK testing (and
the associated warnings) to a new matrix target: `Test Linux x86_64 with
MPK`.
* Fix handling of `Tunables` on cross-compiles
This commit fixes how Wasmtime handles `Tunables` when targetting
non-host platforms (or namely platforms with different pointer widths).
Previously the host's `Tunables` would always be used instead of the
target's tunables which meant that modules couldn't be loaded on the
other platform due to the host having differing tunables by default.
This commit updates tunables in `wasmtime::Config` to all be optional
and loading the actual `Tunables` is deferred until the target is known
during `Engine`-creation time.
* Fix warning
Using an epoch of `1` and setting its duration to the full timeout
configured does not work for `wasmtime serve`, as the epoch is counted
globally per engine. This commit switches to dividing the timeout by 10,
and expiring an instance after 11 epochs have been observed, giving a
maximum overshoot of 10%.
Co-authored-by: Jamey Sharp <jsharp@fastly.com>
Like the rest of the `windows-*` crates published by Kenny Kerr, this
change also adds the `windows` crate itself to the trusted list. This is
necessary for use in #7807.
Simplify the implementation of the serve command by removing the
explicit Service trait impl, and using `service_fn` instead.
Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit updates the `wasmtime` crate itself to have the
`component-model` feature enabled by default. This was also done for the
CLI but only for clarity because the `component-model` feature was
already eanbled by default transitively through the `serve` feature.
Don't force-enable the `wasmtime-wast` crate if the `component-model`
feature is active, only activate component model support if
`wasmtime-wast` is otherwise activated.
* Shuffle some items around in `wasmtime`
This is a follow-up to #7766 with some more changes and reorganization.
These are some small items here and there which shouldn't have any
actual impact on functionality but are intended to reorganize a bit.
Changes here include:
* Move component artifact definitions to `wasmtime-environ` as core
module ones already live there.
* Rename the module with module artifacts from `instantiate` to
`module_artifacts`.
* Make `wasmtime-jit-icache-coherence` an optional dependency as only
the `runtime` feature requires it.
* Reorganize serialized metadata for wasmtime ELF files to consolidate
everything back into `wasmtime::engine::serialization`. This is to
prevent the definition of the serialization format being spread across
a few files.
* Touching up the `serialization` module to compile in all builds of the
`wasmtime` crate.
* fix docs typo
---------
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Currently translation of Wasm code uses the `FUNCREF_MASK` constant
which has type `usize` but this type is not always appropriate in
cross-compiled situations. This commit fixes the usage of `FUNCREF_MASK`
by using the platform-independent value (a negative value) along with
some extra asserts and an explantation of how to update if necessary.
Purely mechanical, no functional changes.
This is to help differentiate between value types (i32, i64, reference types,
etc...) and defined types (function signatures, struct definitions, array
definitions).
* Add `runtime` feature to `wasmtime` crate
This feature can be disabled to build `wasmtime` only for compilation.
This can be useful when cross-compiling, especially on a target that
can't run wasmtime itself (e.g. `wasm32`).
* prtest:full
* don't round pages without runtime feature
* fix async assertions
* move profiling into runtime
* enable runtime for wasmtime-wasi
* enable runtime for c-api
* fix build_artifacts in non-cache case
* fix miri extensions
* enable runtime for wast
* enable runtime for explorer
* support cranelift all-arch on wasm32
* add doc links for `WeakEngine`
* simplify lib runtime cfgs
* move limits and resources to runtime
* move stack to runtime
* move coredump and debug to runtime
* add runtime to coredump and async features
* add wasm32 build job
* combine engine modules
* single compile mod
* remove allow for macro paths
* add comments