History log of /wasmtime-44.0.1/winch/codegen/src/isa/mod.rs (Results 1 – 25 of 28)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
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
# b112bb85 09-Jan-2026 Nick Fitzgerald <[email protected]>

Migrate winch-codegen to `wasmtime_environ::error` (#12297)


Revision tags: 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, v38.0.2, v38.0.1, 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, 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 ...


# 7a66c39a 23-Apr-2025 Alex Crichton <[email protected]>

Remove some `#![expect(clippy::allow_attributes_without_reason)]` (#10661)

Clean up some crates by migrating from `#[allow]` to `#[expect]`
(ideally) or `#[allow]`-with-reason


Revision tags: v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0, v29.0.1, v29.0.0, v28.0.1, v28.0.0
# 792cccce 06-Dec-2024 Saúl Cabrera <[email protected]>

winch: Track the callee calling convention (#9757)

* winch: Track the callee calling convention

This commit aims to improve the consistency of call emission in Winch.

Prior to this commit, the cal

winch: Track the callee calling convention (#9757)

* winch: Track the callee calling convention

This commit aims to improve the consistency of call emission in Winch.

Prior to this commit, the calling convention at Winch's assembler layer
was hardcoded. Even though the calling convention invariants are
correctly handled early on in the code generation process and this has
no effect on the generated code, it could lead to subtle bugs if
Cranelift's emission infrastructure changes. It could also be confusing
when trying to implement call instrutions for other backends.

This change is motivated by some of the questions in https://github.com/bytecodealliance/wasmtime/pull/9751

* Clippy fixes

show more ...


Revision tags: v27.0.0
# 194b4803 07-Nov-2024 Alex Crichton <[email protected]>

Remove the use of `MemoryStyle` in Winch (#9581)

This applies a similar change as #9576 but to Winch. Similar to the
previous PR one case needed some reshuffling, but otherwise all current
behavior

Remove the use of `MemoryStyle` in Winch (#9581)

This applies a similar change as #9576 but to Winch. Similar to the
previous PR one case needed some reshuffling, but otherwise all current
behavior is maintained and this should otherwise be a refactoring.

show more ...


Revision tags: v26.0.1, v25.0.3, v24.0.2
# 2f684ba1 22-Oct-2024 Saúl Cabrera <[email protected]>

winch: Implement Fuel-Based Interruption (#9472)

* winch: Implement Fuel-Based Interruption

Closes: https://github.com/bytecodealliance/wasmtime/issues/8090

This commit introduces the initial impl

winch: Implement Fuel-Based Interruption (#9472)

* winch: Implement Fuel-Based Interruption

Closes: https://github.com/bytecodealliance/wasmtime/issues/8090

This commit introduces the initial implementation of fuel-based
interruption in Winch.

To maintain consistency with existing fuel semantics, this
implementation closely follows the Wasmtime/Cranelift approach, with the
following exception:

* Local Fuel Cache: Given Winch's emphasis on compilation speed,
this implementation does not optimize for minimizing loads and stores.
As a result, checking and incrementing fuel currently requires
explicit loads and stores. Future optimizations may be considered to
improve this aspect.

This commit also includes a small refactoring in the visitor, which
introduces more generic "visitor hook" which enable handling the invariants that need
to happen before and after emitting machine code for each Wasm operator.

* Use the vmruntime limits directly

* Remove unsupported fuel warning

show more ...


Revision tags: v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0
# a659b5a9 16-Sep-2024 bjorn3 <[email protected]>

Couple of cleanups to the ABI computation (#9253)

* Remove WasmtimeSystemV call conv

It is no longer used by Wasmtime

* Remove CallConv::extends_* methods

They all match only a single call conv a

Couple of cleanups to the ABI computation (#9253)

* Remove WasmtimeSystemV call conv

It is no longer used by Wasmtime

* Remove CallConv::extends_* methods

They all match only a single call conv anyway.

* Avoid isa:: prefix for referencing CallConv where possible

* Update callconv list in the clif ir reference

* Use push_non_formal where expected

show more ...


# 721600ca 27-Aug-2024 Saúl Cabrera <[email protected]>

winch: Improve result handling for Aarch64 (#9171)

* winch: Improve result handling for Aarch64

This commit introduces missing tests for Aarch64's ABI implementation.
Compared to the x64 counterpar

winch: Improve result handling for Aarch64 (#9171)

* winch: Improve result handling for Aarch64

This commit introduces missing tests for Aarch64's ABI implementation.
Compared to the x64 counterpart, the aarch64 implementation was missing
tests for multi-value.

Additionally, this commit fixes an issue with how multi-value returns
are handlded in Winch's default calling convention, which only allows
1 register result, independent of the register class.

This commit also refactors the register indexing environment so that it
can be easily shared across the existing backends.

* Keep comments on Aarch64 register assignment

show more ...


Revision tags: v24.0.0, v23.0.2, v23.0.1, v23.0.0, v22.0.0, v21.0.1, v21.0.0, v20.0.2, v20.0.1, v20.0.0, v17.0.3, v19.0.2, v18.0.4
# 5036bb0b 02-Apr-2024 RoboSchmied <[email protected]>

Fix: 4 typos (#8291)

Signed-off-by: RoboSchmied <[email protected]>


Revision tags: v19.0.1
# d38d387a 28-Mar-2024 Alex Crichton <[email protected]>

Fix rustdoc warnings on Nightly (#8258)

* Fix rustdoc warnings on Nightly

I noticed during a failed doc build of another PR we've got a number of
warnings being emitted, so resolve all those here.

Fix rustdoc warnings on Nightly (#8258)

* Fix rustdoc warnings on Nightly

I noticed during a failed doc build of another PR we've got a number of
warnings being emitted, so resolve all those here.

* Fix more warnings

* Fix rebase conflicts

show more ...


# 355990b4 22-Mar-2024 Alex Crichton <[email protected]>

Exit through Cranelift-generated trampolines for builtins (#8152)

* Exit through Cranelift-generated trampolines for builtins

This commit changes how builtin functions in Wasmtime (think
`memory.gr

Exit through Cranelift-generated trampolines for builtins (#8152)

* Exit through Cranelift-generated trampolines for builtins

This commit changes how builtin functions in Wasmtime (think
`memory.grow`) are implemented. These functions are required to exit
through some manner of trampoline to handle runtime requirements for
backtracing right now. Currently this is done via inline assembly for
each architecture (or external assembly for s390x). This is a bit
unfortunate as it's a lot of hand-coding and making sure everything is
right, and it's not easy to update as it's multiple platforms to update.

The change in this commit is to instead use Cranelift-generated
trampolines for this purpose instead. The path for invoking a builtin
function now looks like:

* Wasm code calls a statically known symbol for each builtin.
* The statically known symbol will perform exit trampoline duties (e.g.
pc/fp/etc) and then load a function pointer to the host
implementation.
* The host implementation is invoked and then proceeds as usual.

The main new piece for this PR is that all wasm modules and functions
are compiled in parallel but an output of this compilation phase is what
builtin functions are required. All builtin functions are then unioned
together into one set and then anything required is generated just
afterwards. That means that only one builtin-trampoline per-module is
generated per-builtin.

This work is inspired by #8135 and my own personal desire to have as
much about our ABI details flowing through Cranelift as we can. This in
theory makes it more flexible to deal with future improvements to our
ABI.

prtest:full

* Fix some build issues

* Update winch test expectations

* Update Winch to use new builtin shims.

This commit refactors the Winch compiler to use the new trampolines for
all Wasmtime builtins created in the previous commits. This required a
fair bit of refactoring to handle plumbing through a new kind of
relocation and function call.

Winch's `FuncEnv` now contains a `PrimaryMap` from `UserExternalNameRef`
to `UserExternalName`. This is because there's now more than one kind of
name than just wasm function relocations, so the raw index space of
`UserExternalNameRef` is no longer applicable. This required threading
`FuncEnv` to more locations along with some refactorings to ensure that
lifetimes work out ok.

The `CompiledFunction` no longer stores a trait object of how to map
name refs to names and now directly has a `Primarymap`. This also means
that Winch's return value from its `TargetIsa` is a `CompiledFunction`
as opposed to the previous just-a-`MachBuffer` so it can also package up
all the relocation information. This ends up having `winch-codegen`
depend on `wasmtime-cranelift-shared` as a new dependency.

* Review feedback

show more ...


# d69ba34e 21-Mar-2024 Trevor Elliott <[email protected]>

winch: Switch to using cranelift for all trampolines (#8109)

* Switch winch over to using cranelift for all trampolines

* Fix unused code warnings

* Fix unused code warnings

prtest:full


Revision tags: v19.0.0, v18.0.3, v18.0.2, v17.0.2, v18.0.1, v18.0.0, v17.0.1
# 0bcceda3 25-Jan-2024 Trevor Elliott <[email protected]>

winch: Emit unwind info in the x64 backend (#7798)

* Enable all winch tests on windows

prtest:mingw-x64

* Plumb through x64 unwind info creation

* Add the frame regs unwind info

* Emit UnwindInf

winch: Emit unwind info in the x64 backend (#7798)

* Enable all winch tests on windows

prtest:mingw-x64

* Plumb through x64 unwind info creation

* Add the frame regs unwind info

* Emit UnwindInfo::SaveReg instructions

* Review feedback

* Comment the offset_downward_to_clobbers value

show more ...


Revision tags: v17.0.0, v16.0.0, v15.0.1
# ef07f40f 27-Nov-2023 Alex Crichton <[email protected]>

Update the wasm-tools family of crates (#7587)

This commit updates to the latest wasm-tools and `wit-bindgen` to bring
the family of crates forward. This update notably includes Nick's work
on packe

Update the wasm-tools family of crates (#7587)

This commit updates to the latest wasm-tools and `wit-bindgen` to bring
the family of crates forward. This update notably includes Nick's work
on packed indices in the `wasmparser` crate for validation for the
upcoming implementation of GC types. This meant that translation from
`wasmparser` types to Wasmtime types now may work with a "type id"
instead of just a type index which required plumbing not only Wasmtime's
own type information but additionally `wasmparser`'s type information
throughout translation.

This required a fair bit of refactoring to get this working but no
change in functionality is intended, only a different way of doing
everything prior.

show more ...


Revision tags: v15.0.0
# f0162a40 14-Nov-2023 Saúl Cabrera <[email protected]>

winch: Multi-Value Part 1 (#7535)

* winch: Introduce `ABIParams` and `ABIResults`

This commit prepares Winch to support WebAssembly Multi-Value.

The most notorious piece of this change is the int

winch: Multi-Value Part 1 (#7535)

* winch: Introduce `ABIParams` and `ABIResults`

This commit prepares Winch to support WebAssembly Multi-Value.

The most notorious piece of this change is the introduction of the
`ABIParams` and `ABIResults` structs which are type wrappers around the
concept of an `ABIOperand`, which is the underlying main representation
of a param or result.

This change also consolidates how the size for WebAssembly types is
derived by introducing `ABI::sizeof`, as well as introducing
`ABI::stack_slot_size` to concretely indicate the stack slot size in
bytes for stack params, which is ABI dependent.

* winch: Add the necessary ABI building blocks for multi-value

This change adds the necessary changes at the ABI level in order to
handle multi-value.

The most notable modifications in this change are:

* Modifying Winch's default ABI to reverse the order of results,
ensuring that results that go in the stack should always come first;
this makes it easier to respect the following two stack invariants:

* Spilled memory values always precede register values
* Spilled values are stored from oldest to newest, matching their
respective locations on the machine stack.

* Modify all calling conventions supported by Winch so that only one result, the first one is stored in
registers. This differs from their vanilla counterparts in that these
ABIs can handle multiple results in registers. Given that Winch is not
a generic code generator, keeping the ABI close to what Wasmtime
expects makes it easier to pass multiple results at trampolines.

* Add more multi-value tests

This commit adds more tests for multi-value and improves documentation.

prtest:full

* Address review feedback

show more ...


Revision tags: v14.0.4, v14.0.3, v14.0.2, v13.0.1, v14.0.1, v14.0.0
# 4f47f3ec 13-Oct-2023 Saúl Cabrera <[email protected]>

winch: Add a subset of known libcalls and improve call emission (#7228)

* winch: Add known a subset of known libcalls and improve call emission

This change is a follow up to:
- https://github.com/b

winch: Add a subset of known libcalls and improve call emission (#7228)

* winch: Add known a subset of known libcalls and improve call emission

This change is a follow up to:
- https://github.com/bytecodealliance/wasmtime/pull/7155
- https://github.com/bytecodealliance/wasmtime/pull/7035

One of the objectives of this change is to make it easy to emit
function calls at the MacroAssembler layer, for cases in which it's
challenging to know ahead-of-time if a particular functionality can be
achieved natively (e.g. rounding and SSE4.2). The original implementation
of function call emission, made this objective difficult to achieve and
it was also difficult to reason about.
I decided to simplify the overall approach to function calls as part of
this PR; in essence, the `call` module now exposes a single function
`FnCall::emit` which is reponsible of gathtering the dependencies and
orchestrating the emission of the call. This new approach deliberately
avoids holding any state regarding the function call for simplicity.

This change also standardizes the usage of `Callee` as the main
entrypoint for function call emission, as of this change 4 `Callee`
types exist (`Local`, `Builtin`, `Import`, `FuncRef`), each callee kind
is mappable to a `CalleeKind` which is the materialized version of
a callee which Cranelift understands.

This change also moves the creation of the `BuiltinFunctions` to the
`ISA` level given that they can be safely used accross multiple function
compilations.

Finally, this change also introduces support for some of the
"well-known" libcalls and hooks those libcalls at the
`MacroAssembler::float_round` callsite.

--

prtest:full

* Review comments

* Remove unnecessary `into_iter`

* Fix remaining lifetime parameter names

show more ...


# 4b288ba8 29-Sep-2023 Saúl Cabrera <[email protected]>

winch(x64): Call indirect (#7100)

* winch(x64): Call indirect

This change adds support for the `call_indirect` instruction to Winch.

Libcalls are a pre-requisite for supporting `call_indirect` in

winch(x64): Call indirect (#7100)

* winch(x64): Call indirect

This change adds support for the `call_indirect` instruction to Winch.

Libcalls are a pre-requisite for supporting `call_indirect` in order to
lazily initialy funcrefs. This change adds support for libcalls to
Winch by introducing a `BuiltinFunctions` struct similar to Cranelift's
`BuiltinFunctionSignatures` struct.

In general, libcalls are handled like any other function call, with the
only difference that given that not all the information to fulfill the
function call might be known up-front, control is given to the caller
for finalizing the call.

The introduction of function references also involves dealing with
pointer-sized loads and stores, so this change also adds the required
functionality to `FuncEnv` and `MacroAssembler` to be pointer aware,
making it straight forward to derive an `OperandSize` or `WasmType` from
the target's pointer size.

Finally, given the complexity of the call_indirect instrunction, this
change bundles an improvement to the register allocator, allowing it to
track the allocatable vs non-allocatable registers, this is done to
avoid any mistakes when allocating/de-allocating registers that are not
alloctable.

--
prtest:full

* Address review comments

* Fix typos
* Better documentation for `new_unchecked`
* Introduce `max` for `BitSet`
* Make allocatable property `u64`

* winch(calls): Overhaul `FnCall`

This commit simplifies `FnCall`'s interface making its usage more
uniform throughout the compiler. In summary, this change:

* Avoids side effects in the `FnCall::new` constructor, and also makes
it the only constructor.
* Exposes `FnCall::save_live_registers` and
`FnCall::calculate_call_stack_space` to calculate the stack space
consumed by the call and so that the caller can decide which one to
use at callsites depending on their use-case.

* tests: Fix regset tests

show more ...


Revision tags: minimum-viable-wasi-proxy-serve, v13.0.0, v12.0.2, v11.0.2, v10.0.2, v12.0.1, v12.0.0, v11.0.1, v11.0.0
# 39c96c7a 28-Jun-2023 Alex Crichton <[email protected]>

Remove Wasmtime ABIs from Cranelift (#6649)

* Remove Wasmtime ABIs from Cranelift

This commit removes the `Wasmtime*` family of ABIs from Cranelift. These
were originally added to support multi-val

Remove Wasmtime ABIs from Cranelift (#6649)

* Remove Wasmtime ABIs from Cranelift

This commit removes the `Wasmtime*` family of ABIs from Cranelift. These
were originally added to support multi-value in Wasmtime via the
`TypedFunc` API, but they should now no longer be necessary. In general
this is a higher-level Wasmtime concern than something all backends of
Cranelift should have to deal with.

Today with recent refactorings it's possible to remove the reliance on
ABI details for multi-value and instead codify it directly into the
Cranelift IR generated. For example wasm calls are able to have a
"purely internal" ABI which Wasmtime's Rust code doesn't see at all, and
the Rust code only interacts with the native ABI. The native ABI is
redefined to be what the previous Wasmtime ABIs were, which is to return
the first of a 2+ value return through a register (native return value)
and everything else through a return pointer.

* Remove some wasmtime_system_v usage in tests

* Add back WasmtimeSystemV for s390x

* Fix some docs and references in winch

* Fix another doc link

show more ...


Revision tags: v10.0.1, v10.0.0, v9.0.4, v9.0.3, v9.0.2
# 92024ad1 26-May-2023 Luna P-C <[email protected]>

Function references (#5288)

* Make wasmtime-types type check

* Make wasmtime-environ type check.

* Make wasmtime-runtime type check

* Make cranelift-wasm type check

* Make wasmtime-cranelift typ

Function references (#5288)

* Make wasmtime-types type check

* Make wasmtime-environ type check.

* Make wasmtime-runtime type check

* Make cranelift-wasm type check

* Make wasmtime-cranelift type check

* Make wasmtime type check

* Make wasmtime-wast type check

* Make testsuite compile

* Address Luna's comments

* Restore compatibility with effect-handlers/wasm-tools#func-ref-2

* Add function refs feature flag; support testing

* Provide function references support in helpers

- Always support Index in blocktypes
- Support Index as table type by pretending to be Func
- Etc

* Implement ref.as_non_null

* Add br_on_null

* Update Cargo.lock to use wasm-tools with peek

This will ultimately be reverted when we refer to
wasm-tools#function-references, which doesn't have peek, but does have type
annotations on CallRef

* Add call_ref

* Support typed function references in ref.null

* Implement br_on_non_null

* Remove extraneous flag; default func refs false

* Use IndirectCallToNull trap code for call_ref

* Factor common call_indirect / call_ref into a fn

* Remove copypasta clippy attribute / format

* Add a some more tests for typed table instructions

There certainly need to be many more, but this at least catches the bugs fixed
in the next commit

* Fix missing typed cases for table_grow, table_fill

* Document trap code; remove answered question

* Mark wasm-tools to wasmtime reftype infallible

* Fix reversed conditional

* Scope externref/funcref shorthands within WasmRefType

* Merge with upstream

* Make wasmtime compile again

* Fix warnings

* Remove Bot from the type algebra

* Fix table tests.

`wast::Cranelift::spec::function_references::table`
`wast::Cranelift::spec::function_references::table_pooling`

* Fix table{get,set} tests.

```
wast::Cranelift::misc::function_references::table_get
wast::Cranelift::misc::function_references::table_get_pooling
wast::Cranelift::misc::function_references::table_set
wast::Cranelift::misc::function_references::table_set_pooling
```

* Insert subtype check to fix local_get tests.

```
wast::Cranelift::spec::function_references::local_get
wast::Cranelift::spec::function_references::local_get_pooling
```

* Fix compilation of `br_on_non_null`.

The branch destinations were the other way round... :-)

Fixes the following test failures:
```
wast::Cranelift::spec::function_references::br_on_non_null
wast::Cranelift::spec::function_references::br_on_non_null_pooling
```

* Fix ref_as_non_null tests.

The test was failing due to the wrong error message being printed. As
per upstream folks' suggest we were using the trap code
`IndirectCallToNull`, but it produces an unexpected error message.

This commit reinstates the `NullReference` trap code. It produces the
expected error message. We will have to chat with the maintainers
upstream about how to handle these "test failures".

Fixes the following test failures:

```
wast::Cranelift::spec::function_references::ref_as_non_null
wast::Cranelift::spec::function_references::ref_as_non_null_pooling
```

* Fix a call_ref regression.

* Fix global tests.

Extend `is_matching_assert_invalid_error_message` to circumvent the textual error message failure.

Fixes the following test failures:
```
wast::Cranelift::spec::function_references::global
wast::Cranelift::spec::function_references::global_pooling
```

* Cargo update

* Update

* Spell out some cases in match_val

* Disgusting hack to subvert limitations of type reconstruction.

In the function `wasmtime::values::Val::ty()` attempts to reconstruct
the type of its underlying value purely based on the shape of the
value. With function references proposal this sort of reconstruction
is no longer complete as a source reference type may have been
nullable. Nullability is not inferrable by looking at the shape of the
runtime object alone.

Consequently, the runtime cannot reconstruct the type for
`Val::FuncRef` and `Val::ExternRef` by looking at their respective
shapes.

* Address workflows comments.

* null reference => null_reference for CLIF parsing compliance.

* Delete duplicate-loads-dynamic-memory-egraph (again)

* Idiomatic code change.

* Nullability subtyping + fix non-null storage check.

This commit removes the `hacky_eq` check in `func.rs`. Instead it is
replaced by a subtype check. This subtype check occurs in
`externals.rs` too.

This commit also fixes a bug. Previously, it was possible to store a
null reference into a non-null table cell. I have added to new test
cases for this bug: one for funcrefs and another for externrefs.

* Trigger unimplemented for typed function references. Format values.rs

* run cargo fmt

* Explicitly match on HeapType::Extern.

* Address cranelift-related feedback

* Remove PartialEq,Eq from ValType, RefType, HeapType.

* Pin wasmparser to a fairly recent commit.

* Run cargo fmt

* Ignore tail call tests.

* Remove garbage

* Revert changes to wasmtime public API.

* Run cargo fmt

* Get more CI passing (#19)

* Undo Cargo.lock changes

* Fix build of cranelift tests

* Implement link-time matches relation. Disable tests failing due to lack of public API support.

* Run cargo fmt

* Run cargo fmt

* Initial implementation of eager table initialization

* Tidy up eager table initialisation

* Cargo fmt

* Ignore type-equivalence test

* Replace TODOs with descriptive comments.

* Various changes found during review (#21)

* Clarify a comment

This isn't only used for null references

* Resolve a TODO in local init

Don't initialize non-nullable locals to null, instead skip
initialization entirely and wasm validation will ensure it's always
initialized in the scope where it's used.

* Clarify a comment and skipping the null check.

* Remove a stray comment

* Change representation of `WasmHeapType`

Use a `SignatureIndex` instead of a `u32` which while not 100% correct
should be more correct. This additionally renames the `Index` variant to
`TypedFunc` to leave space for future types which aren't functions to
not all go into an `Index` variant.

This required updates to Winch because `wasmtime_environ` types can no
longer be converted back to their `wasmparser` equivalents. Additionally
this means that all type translation needs to go through some form of
context to resolve indices which is now encapsulated in a `TypeConvert`
trait implemented in various locations.

* Refactor table initialization

Reduce some duplication and simplify some data structures to have a more
direct form of table initialization and a bit more graceful handling of
element-initialized tables. Additionally element-initialize tables are
now treated the same as if there's a large element segment initializing
them.

* Clean up some unrelated chagnes

* Simplify Table bindings slightly

* Remove a no-longer-needed TODO

* Add a FIXME for `SignatureIndex` in `WasmHeapType`

* Add a FIXME for panicking on exposing function-references types

* Fix a warning on nightly

* Fix tests for winch and cranelift

* Cargo fmt

* Fix arity mismatch in aarch64/abi

---------

Co-authored-by: Daniel Hillerström <[email protected]>
Co-authored-by: Daniel Hillerström <[email protected]>
Co-authored-by: Alex Crichton <[email protected]>

show more ...


# afde47c2 24-May-2023 Saúl Cabrera <[email protected]>

winch: Drop `FuncEnv` trait (#6443)

This commit is a small cleanup to drop the usage of the `FuncEnv` trait.

In https://github.com/bytecodealliance/wasmtime/pull/6358, we agreed on
making `winch-co

winch: Drop `FuncEnv` trait (#6443)

This commit is a small cleanup to drop the usage of the `FuncEnv` trait.

In https://github.com/bytecodealliance/wasmtime/pull/6358, we agreed on
making `winch-codegen` directly depend on `wasmtime-environ`.

Introducing a direct relatioship between `winch-codegen` and
`wasmtime-environ` means that the `FuncEnv` trait is no longer serving
its original purpose, and we can drop the usage of the trait and use the
types exposed from `winch-codegen` directly instead.

Even though this change drops the `FuncEnv` trait, it still keeps
a `FuncEnv` struct, which is used during code generation.

show more ...


Revision tags: v9.0.1, v9.0.0
# 20c58362 16-May-2023 Saúl Cabrera <[email protected]>

winch: Implement new trampolines (#6358)

* winch: Implement new trampolines

This change is a follow-up to
https://github.com/bytecodealliance/wasmtime/pull/6262, in which the new
trampolines, descr

winch: Implement new trampolines (#6358)

* winch: Implement new trampolines

This change is a follow-up to
https://github.com/bytecodealliance/wasmtime/pull/6262, in which the new
trampolines, described [here](https://github.com/bytecodealliance/rfcs/blob/main/accepted/tail-calls.md#new-trampolines-and-vmcallercheckedanyfunc-changes),
were introduced to Wasmtime.

This change, focuses on the `array-to-wasm`,
`native-to-wasm` and `wasm-to-native` trampolines to restore Winch's
working state prior to the introduction of the new trampolines. It's
worth noting that the new approach for trampolines make it easier to support
the `TypedFunc` API in Winch. Prior to the introduction of the new
trampolines, it was not obvious how to approach it.

This change also introduces a pinned register that will hold the
`VMContext` pointer, which is loaded in the `*-to-wasm` trampolines;
the `VMContext` register is a pre-requisite to this change to support
the `wasm-to-native` trampolines.

Lastly, with the introduction of the `VMContext` register and the
`wasm-to-native` trampolines, this change also introduces support for
calling function imports, which is a variation of the already existing
calls to locally defined functions.

The other notable piece of this change aside from the trampolines is
`winch-codegen`'s dependency on `wasmtime-environ`. Winch is so closely
tied to the concepts exposed by the wasmtime crates that it makes sense
to tie them together, even though the separation provides some
advantages like easier testing in some cases, in the long run, there's
probably going to be less need to test Winch in isolation and rather
we'd rely more on integration style tests which require all of Wasmtime
pieces anyway (fuzzing, spec tests, etc).

This change doesn't update the existing implmenetation of
`winch_codegen::FuncEnv`, but the intention is to update that part after
this change.

prtest:full

* tests: Ignore miri in Winch integration tests

* Remove hardcoded alignment and addend

show more ...


Revision tags: v6.0.2, v7.0.1, v8.0.1, v8.0.0
# 9dd0b59c 14-Apr-2023 Saúl Cabrera <[email protected]>

winch(x64): Improve ABI support in trampolines (#6204)

This commit improves ABI support in Winch's trampolines mainly by:

* Adding support for the `fastcall` calling convention.
* By storing/restor

winch(x64): Improve ABI support in trampolines (#6204)

This commit improves ABI support in Winch's trampolines mainly by:

* Adding support for the `fastcall` calling convention.
* By storing/restoring callee-saved registers.

One of the explicit goals of this change is to make tests available in the x86_64 target
as a whole and remove the need exclude the windows target.

This commit also introduces a `CallingConvention` enum, to better
reflect the subset of calling conventions that are supported by Winch.

show more ...


# 3a92aa3d 05-Apr-2023 Kevin Rizzo <[email protected]>

winch: Initial integration with wasmtime (#6119)

* Adding in trampoline compiling method for ISA

* Adding support for indirect call to memory address

* Refactoring frame to externalize defined loc

winch: Initial integration with wasmtime (#6119)

* Adding in trampoline compiling method for ISA

* Adding support for indirect call to memory address

* Refactoring frame to externalize defined locals, so it removes WASM depedencies in trampoline case

* Adding initial version of trampoline for testing

* Refactoring trampoline to be re-used by other architectures

* Initial wiring for winch with wasmtime

* Add a Wasmtime CLI option to select `winch`

This is effectively an option to select the `Strategy` enumeration.

* Implement `Compiler::compile_function` for Winch

Hook this into the `TargetIsa::compile_function` hook as well. Currently
this doesn't take into account `Tunables`, but that's left as a TODO for
later.

* Filling out Winch append_code method

* Adding back in changes from previous branch

Most of these are a WIP. It's missing trampolines for x64, but a basic
one exists for aarch64. It's missing the handling of arguments that
exist on the stack.

It currently imports `cranelift_wasm::WasmFuncType` since it's what's
passed to the `Compiler` trait. It's a bit awkward to use in the
`winch_codegen` crate since it mostly operates on `wasmparser` types.
I've had to hack in a conversion to get things working. Long term, I'm
not sure it's wise to rely on this type but it seems like it's easier on
the Cranelift side when creating the stub IR.

* Small API changes to make integration easier

* Adding in new FuncEnv, only a stub for now

* Removing unneeded parts of the old PoC, and refactoring trampoline code

* Moving FuncEnv into a separate file

* More comments for trampolines

* Adding in winch integration tests for first pass

* Using new addressing method to fix stack pointer error

* Adding test for stack arguments

* Only run tests on x86 for now, it's more complete for winch

* Add in missing documentation after rebase

* Updating based on feedback in draft PR

* Fixing formatting on doc comment for argv register

* Running formatting

* Lock updates, and turning on winch feature flags during tests

* Updating configuration with comments to no longer gate Strategy enum

* Using the winch-environ FuncEnv, but it required changing the sig

* Proper comment formatting

* Removing wasmtime-winch from dev-dependencies, adding the winch feature makes this not necessary

* Update doc attr to include winch check

* Adding winch feature to doc generation, which seems to fix the feature error in CI

* Add the `component-model` feature to the cargo doc invocation in CI

To match the metadata used by the docs.rs invocation when building docs.

* Add a comment clarifying the usage of `component-model` for docs.rs

* Correctly order wasmtime-winch and winch-environ in the publish script

* Ensure x86 test dependencies are included in cfg(target_arch)

* Further constrain Winch tests to x86_64 _and_ unix

---------

Co-authored-by: Alex Crichton <[email protected]>
Co-authored-by: Saúl Cabrera <[email protected]>

show more ...


# af4d94c8 28-Mar-2023 Saúl Cabrera <[email protected]>

winch(x64): Initial implementation for function calls (#6067)

* winch(x64): Initial implementation for function calls

This change adds the main building blocks for calling locally defined
functions

winch(x64): Initial implementation for function calls (#6067)

* winch(x64): Initial implementation for function calls

This change adds the main building blocks for calling locally defined
functions. Support for function imports will be added iteratively after this
change lands and once trampolines are supported.

To support function calls, this change introduces the following functionality to
the MacroAssembler:

* `pop` to pop the machine stack into a given register, which in the case of
this change, translates to the x64 pop instruction.

* `call` to a emit a call to locally defined functions.

* `address_from_sp` to construct memory addresses with the SP as a base.

* `free_stack` to emit the necessary instrunctions to claim stack space.

The heavy lifting of setting up and emitting the function call is done through
the implementation of `FnCall`.

* Fix spill behaviour in function calls and add more documentation

This commits adds a more detailed documentation to the `call.rs` module.

It also fixes a couple of bugs, mainly:

* The previous commit didn't account for memory addresses used as arguments for
the function call, any memory entry in the value stack used as a function
argument should be tracked and then used to claim that memory when the function
call ends. We could `pop` and do this implicitly, but we can also track this
down and emit a single instruction to decrement the stack pointer, which will
result in better code.

* Introduce a differentiator between addresses relative or absolute to the stack
pointer. When passing arguments in the stack -- assuming that SP at that point
is aligned for the function call -- we should store the arguments relative to
the absolute position of the stack pointer and when addressing a memory entry in
the Wasm value stack, we should use an address relative to the offset and the
position of the stack pointer.

* Simplify tracking of the stack space needed for emitting a function call

show more ...


Revision tags: v7.0.0, v6.0.1, v5.0.1, v4.0.1
# 013b35ff 08-Mar-2023 Kevin Rizzo <[email protected]>

winch: Refactoring wasmtime compiler integration pieces to share more between Cranelift and Winch (#5944)

* Enable the native target by default in winch

Match cranelift-codegen's build script where

winch: Refactoring wasmtime compiler integration pieces to share more between Cranelift and Winch (#5944)

* Enable the native target by default in winch

Match cranelift-codegen's build script where if no architecture is
explicitly enabled then the host architecture is implicitly enabled.

* Refactor Cranelift's ISA builder to share more with Winch

This commit refactors the `Builder` type to have a type parameter
representing the finished ISA with Cranelift and Winch having their own
typedefs for `Builder` to represent their own builders. The intention is
to use this shared functionality to produce more shared code between the
two codegen backends.

* Moving compiler shared components to a separate crate

* Restore native flag inference in compiler building

This fixes an oversight from the previous commits to use
`cranelift-native` to infer flags for the native host when using default
settings with Wasmtime.

* Move `Compiler::page_size_align` into wasmtime-environ

The `cranelift-codegen` crate doesn't need this and winch wants the same
implementation, so shuffle it around so everyone has access to it.

* Fill out `Compiler::{flags, isa_flags}` for Winch

These are easy enough to plumb through with some shared code for
Wasmtime.

* Plumb the `is_branch_protection_enabled` flag for Winch

Just forwarding an isa-specific setting accessor.

* Moving executable creation to shared compiler crate

* Adding builder back in and removing from shared crate

* Refactoring the shared pieces for the `CompilerBuilder`

I decided to move a couple things around from Alex's initial changes.
Instead of having the shared builder do everything, I went back to
having each compiler have a distinct builder implementation. I
refactored most of the flag setting logic into a single shared location,
so we can still reduce the amount of code duplication.

With them being separate, we don't need to maintain things like
`LinkOpts` which Winch doesn't currently use. We also have an avenue to
error when certain flags are sent to Winch if we don't support them. I'm
hoping this will make things more maintainable as we build out Winch.

I'm still unsure about keeping everything shared in a single crate
(`cranelift_shared`). It's starting to feel like this crate is doing too
much, which makes it difficult to name. There does seem to be a need for
two distinct abstraction: creating the final executable and the handling
of shared/ISA flags when building the compiler. I could make them into
two separate crates, but there doesn't seem to be enough there yet to
justify it.

* Documentation updates, and renaming the finish method

* Adding back in a default temporarily to pass tests, and removing some unused imports

* Fixing winch tests with wrong method name

* Removing unused imports from codegen shared crate

* Apply documentation formatting updates

Co-authored-by: Saúl Cabrera <[email protected]>

* Adding back in cranelift_native flag inferring

* Adding new shared crate to publish list

* Adding write feature to pass cargo check

---------

Co-authored-by: Alex Crichton <[email protected]>
Co-authored-by: Saúl Cabrera <[email protected]>

show more ...


12