11213 Commits

Author SHA1 Message Date
T0b1
a9d0dd56fb fix 2023-05-23 13:38:01 +02:00
T0b1
0df60ce50f custom regalloc 2023-04-27 16:16:48 +02:00
T0b1
3742c97bf0 better vcode printing 2023-04-27 16:14:28 +02:00
Alex Crichton
edae6c0217 x64: Add non-SSE4.1 lowerings of pmov{s,z}x* (#6279)
* x64: Add non-SSE4.1 lowerings of `pmov{s,z}x*`

This commit adds lowerings for a suite of sign/zero extension
instructions which don't require SSE4.1. Like before these lowerings are
based on LLVM's output.

This commit also deletes special casees for `i16x8.extmul_{low,high}_*`
since the output of the special case is the same as the default lowering
of all the component instructions used within as well.

* Remove SSE4.1 specialization of `uwiden_high`

LLVM prefers the `punpckh*`-based lowerings and at least according to
`llvm-mca` these are slightly better cycle-wise too.
2023-04-27 02:15:34 +00:00
Alex Crichton
57dabd3b0b Fix publishing artifacts from the main branch (#6290)
Previously an `event` filter was applied to lookup the merge queue's
github run ID but this filter doesn't work after #6288. The filter isn't
strictly necessary, though, so remove it.
2023-04-26 18:15:30 +00:00
Alex Crichton
d75adc4421 Run full CI once a day on main (#6288)
Use this to prime caches used by PRs to `main` and additionally the
merge queue used to merge into `main`.

While I'm here additionally update the trigger for merge-queue-based PRs
to use `merge_group:` now that it's been fixed.

Closes #6285
2023-04-26 15:54:23 +00:00
Saúl Cabrera
5d833a766e cranelift: Add missing control plane parameter to compile_with_cache (#6289)
It seems that this fell through given that the incremental cache is
behind a cargo feature. I noticed this while building
`cranelift-codegen` via `cargo build --all-features`.

I decided to add a check in CI to hopefully prevent this in the future,
but I'm happy to remove it / update it if there's a better way or another way.
2023-04-26 15:37:35 +00:00
Dan Gohman
ec6755512f Remove maintenance badges from the Cargo.toml files. (#6286)
Several of these badges were out of date, with some crates in wide production
use marked as "experimental". Insted of trying to keep them up to date, just
remove them, since they are [no longer displayed on crates.io].

[no longer displayed on crates.io]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section
2023-04-26 01:33:09 +00:00
Jamey Sharp
9616ead607 cargo vet audits for guest profiling support (#6284)
These audits are necessary for in-process guest profiling support,
currently under development in PR #6282.
2023-04-25 17:57:28 +00:00
Afonso Bordado
62cbb5045e riscv64: Implement a few SIMD arithmetic ops (#6268)
* riscv64: Swap order of `VecAluRRR` source registers

These were accidentally reversed from what we declare in the isle emit helper

* riscv64: Add SIMD `isub`

* riscv64: Add SIMD `imul`

* riscv64: Add `{u,s}mulhi`

* riscv64: Add `b{and,or,xor}`

* cranelift: Move `imul.i8x16` runtest to separate file

Looks like x86 does not implement it

* riscv64: Better formatting for `VecAluOpRRR`

* cranelift: Enable x86 SIMD tests with `has_sse41=false`
2023-04-25 16:39:33 +00:00
Afonso Bordado
4337ccd4b7 riscv64: Support non 128bit vector sizes (#6266)
* riscv64: Add `Zvl` extensions

* riscv64: Allow lowering SIMD operations that fit in a vector register

* riscv64: Support non 128bit vector sizes

* riscv64: Add Zvl Presets

* riscv64: Precompute `min_vec_reg_size`
2023-04-25 14:50:00 +00:00
Jamey Sharp
c7b83e8ef9 wasmtime: remove drop(&mut ...) used to silence warnings (#6278)
The `Config` needs to be mutable while building a compiler, but in a
build configuration without a compiler, declaring it as `mut` produces a
warning since nothing else needs that.

I found the existing workaround for this warning confusing, so this PR
removes `mut` from the binding for `config` and instead re-binds the
variable in builds where we call `build_compiler`.
2023-04-25 14:15:53 +00:00
Afonso Bordado
5113739601 riscv64: Enable more instructions in the fuzzer (#6271)
These have been fixed in the past, and I've been forgeting to re-enable them.
2023-04-25 11:03:16 +00:00
Saúl Cabrera
a1732b2906 winch(fuzz): Initial support for differential fuzzing (#6281)
* winch(fuzz): Initial support for differential fuzzing

This commit introduces initial support for differential fuzzing for Winch. In
order to fuzz winch, this change introduces the `winch` cargo feature. When the
`winch` cargo feature is enabled the differential fuzz target uses `wasmi` as
the differential engine and `wasm-smith` and `single-inst` as the module sources.

The intention behind this change is to have a *local* approach for fuzzing and
verifying programs generated by Winch and to have an initial implementation that
will allow us to eventually enable this change by default. Currently it's not
worth it to enable this change by default given all the filtering that needs to
happen to ensure that the generated modules are supported by Winch.

It's worth noting that the Wasm filtering code will be temporary, until Winch
reaches feature parity in terms of Wasm operators.

* Check build targets with the `winch` feature flag

* Rename fuzz target feature to `fuzz-winch`
2023-04-25 03:56:24 +00:00
Jamey Sharp
bd473dba31 wasmtime-runtime: Re-export backtrace Frame type (#6280)
This crate re-exports the `Backtrace` type at top-level from a nested
module. `Backtrace` in turn has `Frame` in its public API, which is not
re-exported anywhere. This is legal and external users can call methods
on `Frame`, but it doesn't appear in the rustdocs, making it
unnecessarily difficult to figure out how to use this API. Re-exporting
`Frame` fixes that, and also allows naming the type directly if needed.
2023-04-25 01:02:54 +00:00
Alex Crichton
d2bb4aa13b x64: Add non-SSE4.1 lowering for pmulld (#6259)
Adds a lowering for SSE2 for i32x4-based multiplication which only first
became available in SSE4.1
2023-04-24 17:24:19 +00:00
yuyang
c9a9c2c191 Specify a read parameter for ISLE's Lexer. (#6123)
* fix col

* fix test failure

* specify read method.

* modify isle lexer

* remove a fn
2023-04-24 16:11:34 +00:00
Alex Crichton
4b703f9dce Fix differential fuzzing when Wasmtime hits an OOM (#6273)
OSS-Fuzz found a case where the `differential` fuzzer was failing and
the underlying cause was that Wasmtime was hitting an OOM while Wasmi
wasn't. This meant that the two modules were producing "different
results" since memories had differing lengths, but this isn't a failure
we're interested in. This commit updates the differential fuzzer to
discard the test case once the Wasmtime half reaches OOM.
2023-04-24 16:00:24 +00:00
Brendan Burns
3e06a0a2bd Minor cleanups. (#6270) 2023-04-24 15:50:53 +00:00
Afonso Bordado
c14838d9e6 riscv64: Delete CSR Instructions (#6267) 2023-04-23 15:41:00 +00:00
Nick Fitzgerald
8145e6b5b1 Add a wildcard audit for arbitrary (#6264) 2023-04-21 22:33:19 +00:00
Brendan Burns
43ec4816f1 Make streams owned by request/response that they are tied to. (#6228)
* Make streams owned by request/response that they are tied to.

* Address comments, fix tests.

* Address comment.

* Update crates/wasi-http/src/streams_impl.rs

Co-authored-by: Pat Hickey <pat@moreproductive.org>

* Switch to BytesMut

---------

Co-authored-by: Pat Hickey <pat@moreproductive.org>
2023-04-21 18:17:06 +00:00
Jamey Sharp
efdfc361f8 Allow WASI to open directories without O_DIRECTORY (#6163)
* Allow WASI to open directories without O_DIRECTORY

The `O_DIRECTORY` flag is a request that open should fail if the named
path is not a directory. Opening a path which turns out to be a
directory is not supposed to fail if this flag is not specified.
However, wasi-common required callers to use it when opening
directories.

With this PR, we always open the path the same way whether or not the
`O_DIRECTORY` flag is specified. However, after opening it, we `stat` it
to check whether it turned out to be a directory, and determine which
operations the file descriptor should support accordingly. In addition,
we explicitly check whether the precondition defined by `O_DIRECTORY` is
satisfied.

Closes #4947 and closes #4967, which were earlier attempts at fixing the
same issue, but which had race conditions.

prtest:full

* Add tests from #4967/#4947

This test was authored by Roman Volosatovs <rvolosatovs@riseup.net> as
part of #4947.

* Tests: Close FDs before trying to unlink files

On Windows, when opening a path which might be a directory using
`CreateFile`, cap-primitives also removes the `FILE_SHARE_DELETE` mode.

That means that if we implement WASI's `path_open` such that it always
uses `CreateFile` on Windows, for both files and directories, then
holding an open file handle prevents deletion of that file.

So I'm changing these test programs to make sure they've closed the
handle before trying to delete the file.
2023-04-21 16:55:35 +00:00
bjorn3
91d1d246cd Allow serializing all cranelift-module data structures (#6172)
* Remove ModuleCompiledFunction

The same information can be retrieved using

ctx.compiled_code().unwrap().code_info().total_size

In addition for Module implementations that don't immediately compile the
given function there is no correct value that can be returned.

* Don't give anonymous functions and data objects an internal name

This internal name can conflict if a module is serialized and then
deserialized into another module. It also wasn't used by any of the
Module implementations anyway.

* Allow serializing all cranelift-module data structures

This allows a Module implementation to serialize it's internal state and
deserialize it in another compilation session. For example to implement
LTO or to load the module into cranelift-interpreter.

* Use expect
2023-04-21 12:39:15 +00:00
Max Große
8078404a15 docs(wasi-tut): update error message (#6261) 2023-04-21 09:37:34 +00:00
Trevor Elliott
d9e27c5441 Bump regalloc2 to 0.7.0 (#6237)
* Bump RA2 to 0.7.0

* Certify the RA2 update

* Import the rustc-hash audit

* Updates for regalloc2

prtest:full

* Update tests
2023-04-21 00:47:58 +00:00
Dan Gohman
1a077dfd6b Fix poll_oneoff's handling of non-regular files. (#6258)
`poll_oneoff` uses `system_interface::ReadReady` to compute how many
bytes are ready to be read, which is part of the Preview1 `poll_oneoff`
API. This updates to system-interface 0.25.7 which has a fix to handle
special files such as /dev/urandom and /dev/null properly.

Fixes #6239.
2023-04-21 00:34:29 +00:00
Remo Senekowitsch
1192697c7e refactor BlockLoweringOrder::new (#6255)
Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com>
Co-authored-by: Moritz Waser <mzrw.dev@pm.me>
2023-04-20 22:24:32 +00:00
Jamey Sharp
8376944b3f Allow Trevor and me to request PR benchmarks (#6256) 2023-04-20 22:13:32 +00:00
Trevor Elliott
e6339b2725 s390x: Remove uses of copy_reg (#6253)
* Remove uses of `copy_reg` in s390x lowerings

* Update tests

* Add one copy back in for smulhi to avoid an inserted move
2023-04-20 22:05:55 +00:00
Alex Crichton
a2a38edd8a x64: Add non-SSE 4.1 lowerings for v{all,any}_true (#6232)
This commit adds lowerings to the x64 backend for two more CLIF
instructions that currently require SSE 4.1. These lowerings are
inspired by LLVM's lowerings and avoid the use of SSE 4.1 instructions.
2023-04-20 21:56:59 +00:00
Afonso Bordado
60e4a00413 riscv64: Initial SIMD Vector Implementation (#6240)
* riscv64: Remove unused code

* riscv64: Add vector types

* riscv64: Initial Vector ABI Load/Stores

* riscv64: Vector Loads/Stores

* riscv64: Fix `vsetvli` encoding error

* riscv64: Add SIMD `iadd` runtests

* riscv64: Rename `VecSew`

The SEW name is correct, but only for VType. We also use this type
in loads/stores as the Efective Element Width, so the name isn't
quite correct in that case.

* ci: Add V extension to RISC-V QEMU

* riscv64: Misc Cleanups

* riscv64: Check V extension in `load`/`store` for SIMD

* riscv64: Fix `sumop` doc comment

* cranelift: Fix comment typo

* riscv64: Add convert for VType and VecElementWidth

* riscv64: Remove VecElementWidth converter
2023-04-20 21:54:43 +00:00
Trevor Elliott
7ad2fe32c9 aarch64: Avoid a copy in the extract_vector lowering (#6252)
* Avoid a move in the aarch64 lowering of extract_vector

* Update tests
2023-04-20 18:24:12 +00:00
Trevor Elliott
b667f5fa5b Avoid introducing a move for struct return (#6245)
* Move sret_reg handling to Lower:new, from gen_arg_setup

* Update exp files

* Review feedback

* Review feedback
2023-04-20 18:13:40 +00:00
wasmtime-publish
620ec03ca4 Update release date of Wasmtime 8.0.0 (#6248)
Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
2023-04-20 14:04:42 +00:00
Dan Gohman
c59bb8db39 Update several dependencies. (#6171)
This updates to rustix 0.37.13, which contains some features we can use to
implement more features in wasi-common for the wasi-sockets API. This also
pulls in several other updates to avoid having multiple versions of rustix.

This does introduce multiple versions of windows-sys, as the errno and tokio
crates are currently using 0.45 while rustix and other dependencies have
updated to 0.48; PRs updating these are already in flight so this will
hopefully be resolved soon.

It also includes cap-std 1.0.14, which disables the use of `openat2` and
`statx` on Android, fixing a bug where some Android devices crash the
process when those syscalls are executed.
2023-04-20 14:03:49 +00:00
Trevor Elliott
f89ac63766 riscv64: Remove the gen_move2 helper (#6246)
* Remove gen_move2 from riscv64

* Update exp files
2023-04-19 21:04:30 +00:00
Pat Hickey
8e76ec82be wasi-common: export StringArray type (#6244)
reusable elsewhere: @mtr is gonna use it in wasi-nn.
2023-04-19 20:13:25 +00:00
Alex Crichton
b23691032b Fix default architecture for winch (#6242)
* Fix default architecture for winch

This updates the `winch/codegen/build.rs` script to default to the
target architecture being compiled for as opposed to the host
architecture that's performing the compile.

Closes #6241

* Auto-enable other future architectures
2023-04-19 19:45:48 +00:00
Alex Crichton
077d4755d9 Mark loads from VMCallerCheckedAnyfunc as readonly (#6243)
This commit marks the loads of `*mut VMContext` and the callee function
pointer as `readonly` in the context of indirect function calls and
additionally calls to imported functions (which are indirect). Once a
`VMCallerCheckedAnyfunc` is initialized it's never modified so it should
be valid to mark these as readonly and if called in a loop should be
hoistable outside of the loop.
2023-04-19 19:22:25 +00:00
Pat Hickey
0a062369a8 delete wasi truncation_rights test (#6236)
This test was not meaningfully executing, because wasi-common never
provides rights containing RIGHTS_PATH_FILESTAT_SET_SIZE - this flag is
not even defined in wasi-common/srd/dir.rs as one of the DirCaps flags.

Even when you get rid of that guard that skips the meat of the test,
path_open was being called with OFLAGS_TRUNC but without
RIGHTS_FD_WRITE, which boils down to an `open(2)` with OFLAGS_TRUNC set
and none of the access modes set, so it will always fail with EINVAL.

So, it doesn't look like this test ever would have meaningfully passed,
even in pre-wiggle-rewrite version of wasi-common it landed in back in
late 2019. Late 2019! before the pandemic! our eyes were so full of
stars and dreams of the future!

The behavior we really care about for truncation are taken care of
by the fd_filestat_set test, which shows fd_filestat_set_size works
correctly, and the file_truncation test, which shows that opening
with OFLAGS_TRUNC will truncate the file.
2023-04-19 16:40:42 +00:00
Trevor Elliott
ef7af28ef0 Bump hashbrown to 0.13.2 (#6238) 2023-04-18 23:12:09 +00:00
Alex Crichton
b6bb6a196a Add support for binary/octal literals to ISLE (#6234)
* Add support for binary/octal literals to ISLE

In a number of x64-changes recently some u8 immediates are interpreted
as four bit-packed 2-bit numbers and I have a tough time going between
hex and these bit-packed numbers. I've been writing `0xAA == 0b...` in
comments to indicate the intent but I figured it'd be a bit clearer if
the binary literal was accepted directly!

This is a minor update to the ISLE lexer to allow for binary `0b00...`
and octal `0o00...` literals in the same manner as hex literals. Some
comments in the x64 backend are then removed to use the binary literal
syntax directly.

* Update ISLE reference for octal/binary

* Update ISLE tests for octal/binary
2023-04-18 23:04:04 +00:00
Trevor Elliott
c17a3d89f7 cranelift: Remove EBB references from docs (#6235)
* Remove ebb references from compare-llvm.md

* Remove EBB references from ir.md

* Remove EBB references from testing.md

* Fix grammar

* Clean up discussion of conditionals terminating BBs

* Remove a reference to boolean types
2023-04-18 23:01:45 +00:00
Lann
51ed20ab4d Add Engine::precompile_compatibility_hash (#5826)
This method returns a Hash, the output of which can be used to index
precompiled binaries from one Engine instance that can be deserialized
by another Engine instance.
2023-04-18 21:21:16 +00:00
Alexa VanHattum
a486aa37ad Update doc for which integer types are supported (#6233)
* Update doc for which integer types are supported

* Update ir.md
2023-04-18 20:02:31 +00:00
Bobby Holley
5e4b928161 Run cargo-vet prune. (#6231) 2023-04-18 18:23:46 +00:00
Pat Hickey
24b607cf75 wasi-common: change behavior of path_readlink to truncate on too-small buffers (#6225)
this is the same behavior as exists in posix readlink(2)
2023-04-18 18:12:30 +00:00
Dan Gohman
2494867c5f Add a WASI test for a creating an absolute-path symlink. (#6071)
Wasmtime disallows guests from using `path_symlink` to create
absolute-path symlinks, as they could confuse other code into
accessing resources on the host that the guest otherwise doesn't
have access to.

This patch adds a test for this behavior.
2023-04-18 17:48:51 +00:00
Alex Crichton
62f8928bee x64: Add non-SSE4.1 lowerings of ceil/trunc/floor/nearest (#6224)
* x64: Add non-SSE4.1 lowerings of ceil/trunc/floor/nearest

This commit adds lowerings that work with SSE2 for CLIF `ceil`, `trunc`,
`floor`, and `nearest` instructions over vectors. To get these working
`insertlane` for float vectors was also implemented for non-SSE4.1
instructions as well.

Note that the goal of these lowerings is not speed but rather "it
works", so the decompose-to-call-libcalls logic for vector is probably
horrendously slow but should at least be correct.

* Skip new tests on riscv64

* Update cranelift/codegen/src/isa/x64/inst.isle

Co-authored-by: Andrew Brown <andrew.brown@intel.com>

---------

Co-authored-by: Andrew Brown <andrew.brown@intel.com>
2023-04-18 17:23:18 +00:00