Commit Graph

9359 Commits

Author SHA1 Message Date
Alex Crichton
dd85d66ec3 Run PR CI for release branches (#3629)
This was accidentally ommitted from our CI configuration which meant
that release branches didn't get PR CI. They still won't get on-merge CI
but that shouldn't be an issue because the PR CI is the full CI.
2021-12-21 12:52:34 -06:00
Alex Crichton
222d6fbc09 Try to fix patch release process (#3627)
The whole point of patch releases is that they're not on the `main`
branch, so this is an attempt to handle #3621.
2021-12-21 09:50:31 -06:00
Andrew Brown
ad6f76a789 x64: upgrade ittapi-rs crate (for VTune support) (#3623)
This update is no real change in functionality but brings in several of
the latest changes to the `ittapi-rs` library: minor fixes to the C
library, a new license expression for the Cargo crate, better
documentation, updated Rust bindings, and the removal of `cmake` as a
dependency (uses `cc` directly instead).
2021-12-17 19:23:03 -06:00
Andrew Brown
24bc4d6055 docs: replace 'amplxe-cl' with 'vtune' (#3622)
The name of the VTune collector CLI has [now
changed](https://github.com/intel/ittapi/pull/32#discussion_r771417365)
to `vtune`; `amplxe-cl` is deprecated.
2021-12-17 16:59:47 -08:00
Andrew Brown
99b00cd973 docs: update VTune documentation (#3604)
While using VTune, it seemed a good idea to check that the VTune
documentation for Wasmtime was still correct. It is and VTune support
still works (improvements: click-through to x86 assembly is not
available). These changes simply re-organize the documentation and add a
section for running VTune from a GUI.
2021-12-17 15:47:09 -08:00
Alex Crichton
546e901d32 aarch64: Use smaller instruction helpers in ISLE (#3618)
* aarch64: Use smaller instruction helpers in ISLE

This commit moves the aarch64 backend's ISLE to be more similar to the
x64 backend's ISLE where one-liner instruction builders are used for
various forms of instructions instead of always using the
constructor-per-variant-of-`Inst`. Overall I think this change worked
out quite well and sets up some naming idioms as well for various forms
of instructions.

* rebase conflict
2021-12-17 17:28:52 -06:00
Chris Fallin
e10171b7ea Merge pull request #3619 from cfallin/isle-manifest-siphash
Use SipHasher rather than SHA-512 for ISLE manifest.
2021-12-17 13:15:28 -08:00
Chris Fallin
1db76447c5 Merge pull request #3617 from bjorn3/fix_small_popcnt
Fix popcnt for small integers
2021-12-17 13:15:02 -08:00
Chris Fallin
5233175b06 Use SipHasher rather than SHA-512 for ISLE manifest.
Fixes #3609. It turns out that `sha2` is a nontrivial dependency for
Cranelift in many contexts, partly because it pulls in a number of other
crates as well.

One option is to remove the hash check under certain circumstances, as
implemented in #3616. However, this is undesirable for other reasons:
having different dependency options in Wasmtime in particular for
crates.io vs. local builds is not really possible, and so either we
still have the higher build cost in Wasmtime, or we turn off the checks
by default, which goes against the original intent of ensuring developer
safety (no mysterious stale-source bugs).

This PR uses `SipHash` instead, which is built into the standard
library. `SipHash` is deprecated, but it's fixed and deterministic
(across runs and across Rust versions), which is what we need, unlike
the suggested replacement `std::collections::hash_map::DefaultHasher`.
The result is only 64 bits, and is not cryptographically secure, but we
never needed that; we just need a simple check to indicate when we
forget a `rebuild-isle`.
2021-12-17 12:11:05 -08:00
Dan Gohman
7b346b1f12 Update to cap-std 0.22.0. (#3611)
* Update to cap-std 0.22.0.

The main change relevant to Wasmtime here is that this includes the
rustix fix for compilation errors on Rust nightly with the `asm!` macro.

* Add itoa to deny.toml.

* Update the doc and fuzz builds to the latest Rust nightly.

* Update to libc 0.2.112 to pick up the `POLLRDHUP` fix.

* Update to cargo-fuzz 0.11, for compatibility with Rust nightly.

This appears to be the fix for rust-fuzz/cargo-fuzz#277.
2021-12-17 12:00:11 -08:00
bjorn3
32c3afe4b3 Add regression runtests 2021-12-17 20:58:32 +01:00
bjorn3
1dbb747d59 Fix popcnt for small integers 2021-12-17 20:39:53 +01:00
Alex Crichton
e94ebc2263 aarch64: Translate rot{r,l} to ISLE (#3614)
This commit translates the `rotl` and `rotr` lowerings already existing
to ISLE. The port was relatively straightforward with the biggest
changing being the instructions generated around i128 rotl/rotr
primarily due to register changes.
2021-12-17 12:37:17 -06:00
Alex Crichton
d8974ce6bc aarch64: Migrate ishl/ushr/sshr to ISLE (#3608)
* aarch64: Migrate ishl/ushr/sshr to ISLE

This commit migrates the `ishl`, `ushr`, and `sshr` instructions to
ISLE. These involve special cases for almost all types of integers
(including vectors) and helper functions for the i128 lowerings since
the i128 lowerings look to be used for other instructions as well. This
doesn't delete the i128 lowerings in the Rust code just yet because
they're still used by Rust lowerings, but they should be deletable in
due time once those lowerings are translated to ISLE.

* Use more descriptive names for i128 lowerings

* Use a with_flags-lookalike for csel

* Use existing `with_flags_*`

* Coment backwards order

* Update generated code
2021-12-16 17:37:53 -06:00
Chris Fallin
e1e2f3ca15 Merge pull request #3610 from cfallin/fix-narrow-type-rotate
Fix some 16- and 8-bit behavior in x64 backend related to rotates.
2021-12-16 14:06:52 -08:00
Chris Fallin
fd171ca063 Fix OperandSize: need clamp-to-32-bit behavior in most cases, but true-width for shifts. 2021-12-16 12:32:28 -08:00
Chris Fallin
1323ae417e Fix some 16- and 8-bit behavior in x64 backend related to rotates.
Uncovered by @bjorn3 (thanks!): 8- and 16-bit rotates were not working
properly in recent versions of Cranelift with part of the lowering
migrated to ISLE.

This PR fixes a few issues:

- 8- and 16-bit rotate-left needs to mask a constant amount, if any,
  because we use a 32-bit rotate instruction and so don't get the
  appropriate shift-amount masking for free from x86 semantics.

- `operand_size_from_type` was incorrect: it only handled 32- and 64-bit
  types and silently returned `OperandSize::Size32` for everything else.
  Now uses the `OperandSize::from_ty(ty)` helper as the pre-ISLE code
  did.

Our test coverage for narrow value types is not great; this PR adds some
runtests for rotl/rotr but more would always be better!
2021-12-16 11:34:24 -08:00
Alex Crichton
d29b7c8a59 Fix a simd shuffle test (#3607)
Cranelift shuffles require indices to be in-bounds, which the
avx512-using backend also requires via a debug assert, so this commit
fixes a test with simd shuffles to only use in-bounds indices.

This is motivated by another failure on CI where the machine we were
running on presumably had avx512 things enabled. This should fix those
failures.

Closes #3581
2021-12-16 10:36:52 -08:00
Alex Crichton
48a17e9502 Add CLI options for more configuration options (#3603)
This commit adds a few more CLI flags for random fiddly bits in the
`Config` structure to make it a bit easier to play around on the command
line and see the effect of various flags on compiled code.
2021-12-16 10:10:19 -06:00
Alex Crichton
4236319a53 aarch64: Migrate some bit-ops to ISLE (#3602)
* aarch64: Migrate some bit-ops to ISLE

This commit migrates these instructions to ISLE:

* `bnot`
* `band`
* `bor`
* `bxor`
* `band_not`
* `bor_not`
* `bxor_not`

The translations were relatively straightforward but the interesting
part here was trying to reduce the duplication between all these
instructions. I opted for a route that's similar to what the lowering
does today, having a `decl` which takes the `ALUOp` and then performs
further pattern matching internally. This enabled each instruction's
lowering to be pretty simple while we still get to handle all the fancy
cases of shifts, constants, etc, for each instruction.

* Actually delete previous lowerings

* Remove dead code
2021-12-15 10:41:36 -06:00
Alex Crichton
2cdbf32a06 Enable the SIMD proposal by default (#3601)
* Enable the SIMD proposal by default

This commit updates Wasmtime to enable the SIMD proposal for WebAssembly
by default. Support has been implemented for quite some time and
recently fuzzing has been running for multiple weeks without incident,
so it seems like it might be time to go ahead and enable this!

* Refactor CLI feature specification

Don't store a `bool` but rather an `Option<bool>` so we can inherit the
defaults from Wasmtime rather than having to keep the defaults in-sync.
2021-12-14 16:57:52 -06:00
Nick Fitzgerald
8ac4d872db Merge pull request #3600 from alexcrichton/isle-5-uextend-sextend
aarch64: Migrate `uextend`/`sextend` to ISLE
2021-12-14 13:51:08 -08:00
Alex Crichton
d89410ec4e aarch64: Migrate uextend/sextend to ISLE
This commit migrates the sign/zero extension instructions from
`lower_inst.rs` to ISLE. There's actually a fair amount going on in this
migration since a few other pieces needed touching up along the way as
well:

* First is the actual migration of `uextend` and `sextend`. These
  instructions are relatively simple but end up having a number of special
  cases. I've attempted to replicate all the cases here but
  double-checks would be good.

* This commit actually fixes a few issues where if the result of a vector
  extraction is sign/zero-extended into i128 that actually results in
  panics in the current backend.

* This commit adds exhaustive testing for
  extension-of-a-vector-extraction is a noop wrt extraction.

* A bugfix around ISLE glue was required to get this commit working,
  notably the case where the `RegMapper` implementation was trying to
  map an input to an output (meaning ISLE was passing through an input
  unmodified to the output) wasn't working. This requires a `mov`
  instruction to be generated and this commit updates the glue to do
  this. At the same time this commit updates the ISLE glue to share more
  infrastructure between x64 and aarch64 so both backends get this fix
  instead of just aarch64.

Overall I think that the translation to ISLE was a net benefit for these
instructions. It's relatively obvious what all the cases are now unlike
before where it took a few reads of the code and some boolean switches
to figure out which path was taken for each flavor of input. I think
there's still possible improvements here where, for example, the
`put_in_reg_{s,z}ext64` helper doesn't use this logic so technically
those helpers could also pattern match the "well atomic loads and vector
extractions automatically do this for us" but that's a possible future
improvement for later (and shouldn't be too too hard with some ISLE
refactoring).
2021-12-14 07:01:37 -08:00
Alex Crichton
20e090b114 aarch64: Migrate {s,u}{div,rem} to ISLE (#3572)
* aarch64: Migrate {s,u}{div,rem} to ISLE

This commit migrates four different instructions at once to ISLE:

* `sdiv`
* `udiv`
* `srem`
* `urem`

These all share similar codegen and center around the `div` instruction
to use internally. The main feature of these was to model the manual
traps since the `div` instruction doesn't trap on overflow, instead
requiring manual checks to adhere to the semantics of the instruction
itself.

While I was here I went ahead and implemented an optimization for these
instructions when the right-hand-side is a constant with a known value.
For `udiv`, `srem`, and `urem` if the right-hand-side is a nonzero
constant then the checks for traps can be skipped entirely. For `sdiv`
if the constant is not 0 and not -1 then additionally all checks can be
elided. Finally if the right-hand-side of `sdiv` is -1 the zero-check is
elided, but it still needs a check for `i64::MIN` on the left-hand-side
and currently there's a TODO where `-1` is still checked too.

* Rebasing and review conflicts
2021-12-13 17:27:11 -06:00
Alex Crichton
f1225dfd93 Add a compilation section to disable address maps (#3598)
* Add a compilation section to disable address maps

This commit adds a new `Config::generate_address_map` compilation
setting which is used to disable emission of the `.wasmtime.addrmap`
section of compiled artifacts. This section is currently around the size
of the entire `.text` section itself unfortunately and for size reasons
may wish to be omitted. Functionality-wise all that is lost is knowing
the precise wasm module offset address of a faulting instruction or in a
backtrace of instructions. This also means that if the module has DWARF
debugging information available with it Wasmtime isn't able to produce a
filename and line number in the backtrace.

This option remains enabled by default. This option may not be needed in
the future with #3547 perhaps, but in the meantime it seems reasonable
enough to support a configuration mode where the section is entirely
omitted if the smallest module possible is desired.

* Fix some CI issues

* Update tests/all/traps.rs

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* Do less work in compilation for address maps

But only when disabled

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
2021-12-13 13:48:05 -06:00
wasmtime-publish
c1c4c59670 Release Wasmtime 0.32.0 (#3589)
* Bump Wasmtime to 0.32.0

[automatically-tag-and-release-this-commit]

* Update release notes for 0.32.0

Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2021-12-13 13:47:30 -06:00
Chris Fallin
45845d5154 Merge pull request #3597 from bytecodealliance/fitzgen-patch-1
Add notes for Cranelift 2021-12-13 meeting
2021-12-13 08:58:42 -08:00
Nick Fitzgerald
be618cc316 Add notes for Cranelift 2021-12-13 meeting 2021-12-13 08:52:15 -08:00
Andrew Brown
86611d3bbc isle: expand enums in ISLE (#3586)
* x64: expand FloatCC enum in ISLE
* isle: regenerate manifests
* isle: generate all enum fields in `clif.isle`

This expands the `gen_isle` function to write all of the immediate
`enum`s out explicitly in `clif.isle`. Non-`enum` immediates are still
`extern primitive`.

* Only compile `enum_values` with `rebuild-isle` feature
* Only compile `gen_enum_isle` with `rebuild-isle` feature
2021-12-12 18:31:42 -08:00
Chris Fallin
fab77e0d0f Merge pull request #3595 from Monadic-Cat/cranelift-jit-arm64call
Add support for `Arm64Call` relocations in `cranelift-jit`
2021-12-10 15:38:49 -08:00
Monadic Cat
0d6688f81a rustfmt compiled_blob.rs 2021-12-10 16:55:03 -06:00
Monadic Cat
b6ade80025 use an unaligned read and write on compiled blob 2021-12-10 16:42:55 -06:00
Monadic Cat
dcb64dc311 assert that offset is in bounds for Arm64Call 2021-12-10 16:31:10 -06:00
Monadic Cat
ad36df5495 add support for Arm64Call relocations in cranelift-jit 2021-12-10 15:15:59 -06:00
Nick Fitzgerald
da73952021 cranelift-codegen: port bnot lowering to ISLE in x64 2021-12-09 08:38:10 -08:00
Nick Fitzgerald
b5e5366550 Merge pull request #3591 from fitzgen/min-max-isle
cranelift-codegen: Port lowering of `{i,u}{max,min}` to ISLE for x64
2021-12-08 16:33:02 -08:00
Nick Fitzgerald
cded0989aa cranelift-codegen: Port lowering of {i,u}{max,min}` to ISLE for x64 2021-12-08 15:50:42 -08:00
Nick Fitzgerald
471c1e32a4 Consolidate XmmRmR-based instructions together 2021-12-08 15:37:24 -08:00
Nick Fitzgerald
bea0c0d886 Merge pull request #3585 from abrown/assert-tmp-dsts
x64: assert that temporary and destination registers match during renaming
2021-12-08 14:10:54 -08:00
Chris Fallin
7bc17fda39 Fix iadd_ifcout lowering in ISLE to return a register corresponding to the iflags.
This register is not initialized, but we protect against its being used
by never allowing an iflags/fflags-typed value to be used with
`put_value_in_regs`. All `iflags`/`fflags` usages should be handled by
pattern-matching: e.g., `trapif` explicitly matches an `iadd_ifcout`
input.

Eventually (#3249) we need to simplify this by removing
iflags/fflags-tyepd values and using bool flags instead,
pattern-matching to get the same efficient lowerings as today. For now,
this allows the ISLE assertions to pass.
2021-12-08 11:59:38 -08:00
Andrew Brown
acaa84068d aarch64: assert that temporary and destination registers match during renaming 2021-12-08 11:59:11 -08:00
Andrew Brown
594509b734 x64: assert that temporary and destination registers match during renaming 2021-12-08 11:58:45 -08:00
Benjamin Bouvier
34ab2f9b19 Update wasmtime agenda for next meeting (#3590) 2021-12-08 19:14:18 +01:00
Nick Fitzgerald
1a9a034b2a Merge pull request #3587 from fitzgen/isle-exact-dep
cranelift-codegen: depend on an exact version of `isle`
2021-12-07 15:39:27 -08:00
Nick Fitzgerald
6af8d2a292 Rename the isle crate to cranelift-isle
The `isle` crate name is already taken on crates.io :(
2021-12-07 14:56:26 -08:00
Nick Fitzgerald
7e80c061f2 cranelift-codegen: depend on an exact version of isle
This should (hopefully) fix our publish script.
2021-12-07 14:23:41 -08:00
Peter Huene
3fe15ffa49 Merge pull request #3582 from Amanieu/c-api-vec
Fix issues with the C API vector implementation
2021-12-03 17:44:52 -08:00
Amanieu d'Antras
ce67e7fcd1 Fix ownership in *_vec_new functions in the C API
These functions are specified to take ownership of the objects in the
given slice, not clone them.
2021-12-03 23:57:19 +00:00
Amanieu d'Antras
6d61c1578f Add a proper implementation of Clone for C API vector types
The previous implementation used a shallow copy, which is incorrect and
could lead to a use-after-free.
2021-12-03 23:57:19 +00:00
Pat Hickey
1db2f38420 Merge pull request #3584 from bytecodealliance/pch/rust_1.57_warnings
cranelift codegen & filetests: silence new dead code warnings in rust 1.57
2021-12-03 12:36:52 -08:00