Commit Graph

8397 Commits

Author SHA1 Message Date
Chris Fallin
a1c9b06cea Fix spillslot reload of narrow values: zero-extend, don't sign-extend.
Previously, the x64 backend's ABI code would generate a sign-extending
load when loading a less-than-64-bit integer from a spillslot. This is
incorrect: e.g., for i32s > 0x80000000, this would result in all high
bits set.

This interacts poorly with another optimization. Normally, the invariant
is that the high bits of a register holding a value of a certain type,
beyond that type's bits, are undefined. However, as an optimization, we
recognize and use the fact that on x86-64, 32-bit instructions zero the
upper 32 bits. This allows us to elide a 32-to-64-bit zero-extend op
(turning it into just a move, which can then sometimes disappear
entirely due to register coalescing).

If a spill and reload happen between the production of a 32-bit value
from an instruction known to zero the upper bits and its use, then we
will rely on zero upper bits that might actually be set by a
sign-extend. This will result in incorrect execution.

As a fix, we stick to a simple invariant: we always spill and reload a
full 64 bits when handling integer registers on x64. This ensures that
no bits are mangled.
2021-05-19 12:19:19 -07:00
Till Schneidereit
3b3b126fe2 Refer to BA security policy (#2912) 2021-05-19 18:24:42 +02:00
Chris Fallin
33086493dc Merge pull request #2911 from olivierlemasle/tests
cranelift: move wasmtests in cranelift-wasm
2021-05-18 15:09:29 -07:00
Olivier Lemasle
954f7d3876 cranelift: move wasmtests in cranelift-wasm
Move test data used by cranelift-wasm's tests in
the crate directory, to make the tests autonomous.

Fixes #2910
2021-05-18 22:48:52 +02:00
Peter Huene
18c61cdfa4 Merge pull request #2900 from peterhuene/benchmark-instantiation
Implement simple benchmarks for instantiation.
2021-05-17 16:52:13 -07:00
Andrew Brown
7ef3ae2903 x64: implement vselect with variable blend instructions
This change implements `vselect` using SSE4.1's `BLENDVPS`, `BLENDVPD`,
and `PBLENDVB`. `vselect` is a lane-selecting instruction that is used
by
[simple_preopt.rs](fa1faf5d22/cranelift/codegen/src/simple_preopt.rs (L947-L999))
to lower `bitselect` to a single x86 instruction when the condition mask
is known to be boolean (all 1s or 0s, e.g., from a conversion). This is
better than `bitselect` in general, which lowers to 4-5 instructions.
The old backend had the `vselect` lowering; this simply introduces it to
the new backend.
2021-05-17 11:23:33 -07:00
Andrew Brown
0742bb4699 Update cast crate, remove cargo-deny rules (#2909)
Previously the inclusion of the `criterion` crate had brought in a
transitive dependency to `cast`, which used old versions of several
libraries. Now that https://github.com/japaric/cast.rs/pull/26 is merged
and a new version published, we can update `cast` and remove the
cargo-deny rules for the duplicated, older versions.
2021-05-17 11:40:10 -05:00
Olivier Lemasle
b5f29bd3b2 Update wasm-tools crates (#2908)
wasmparser 0.78 adds the Unknown name subsection type.
2021-05-17 10:08:17 -05:00
Andrew Brown
bc0df92137 peepmatic: rebuild peephole optimizers after cranelift/meta change 2021-05-17 06:54:45 -07:00
Andrew Brown
84b6f05971 cranelift: remove unreachable scalar lowerings of saturating arithmetic
Since `uadd_sat`, `sadd_sat`, `usub_sat`, and `ssub_sat` are now only
available to vector types, this removes the lowering code for the
scalar versions of these instructions in the arm32 and aarch64 backends.
2021-05-17 06:54:45 -07:00
Andrew Brown
1fe7676831 cranelift: only allow vector types with saturating arithmetic
This fixes #2883 by restricting which types are available to the `uadd_sat`, `sadd_sat`, `usub_sat`, and `ssub_sat` IR operations.
2021-05-17 06:54:45 -07:00
Andrew Brown
e676589b0c x64: lower i64x2.imul to VPMULLQ when possible
This adds the machinery to encode the VPMULLQ instruction which is
available in AVX512VL and AVX512DQ. When these feature sets are
available, we use this instruction instead of a lengthy 12-instruction
sequence.
2021-05-13 20:14:05 -07:00
Andrew Brown
5929a5e6ee x64: improve arithmetic filetests 2021-05-13 20:14:05 -07:00
Andrew Brown
c982d2be65 x64: move multiplication lowering
Since the lowering of `imul` complicated the other ALU operations it was
matched with and since future commits will alter the multiplication
lowering further, this change moves the `imul` lowering to its own match
block.
2021-05-13 20:14:05 -07:00
Peter Huene
1b8efa7bbd Implement simple benchmarks for instantiation.
This adds benchmarks around module instantiation using criterion.

Both the default (i.e. on-demand) and pooling allocators are tested
sequentially and in parallel using a thread pool.

Instantiation is tested with an empty module, a module with a single page
linear memory, a larger linear memory with a data initializer, and a "hello
world" Rust WASI program.
2021-05-13 19:27:39 -07:00
Chris Fallin
fa1faf5d22 Merge pull request #2749 from MaxGraey/fix-small-memset
cranelift: properly splatting bytes in emit_small_memset
2021-05-13 13:39:28 -07:00
MaxGraey
38140900f1 properly splatting bytes in emit_small_memset 2021-05-13 22:05:30 +03:00
Andrew Brown
6fb2a24c6b Temporarily ignore multiple versions of criterion's build dependencies
Until https://github.com/japaric/cast.rs/pull/26 is resolved, the `cast`
crate will pull in older versions of the `rustc_version`, `semver`, and
`semver-parser` crates. `cast` is a build dependency of `criterion`
which is used for benchmarking and is itself a dev dependency, not a
normal dependency.
2021-05-13 10:46:08 -07:00
Andrew Brown
011e94f3fa x64: add benchmarks for EVEX encoding
This change adds a criterion-enabled benchmark, x64-evex-encoding, to
compare the performance of the builder pattern used to encode EVEX
instructions in the new x64 backend against the function pattern
used to encode EVEX instructions in the legacy x86 backend. At face
value, the results imply that the builder pattern is faster, but no
efforts were made to analyze and optimize these approaches further.
2021-05-13 10:46:08 -07:00
Andrew Brown
c89e6b2353 x64: make the x64 module public
In order to benchmark portions of the x64 module, this change makes it a
public module of cranelift-codegen.
2021-05-13 10:46:08 -07:00
Andrew Brown
02796fc670 x64: move encodings to a separate module
In order to benchmark the encoding code with criterion, the functions
and structures must be public. Moving this code to its own module
(instead of keeping as a submodule to `inst`), allows `inst` to remain
private. This avoids having to expose and document (or ignore
documenting) the numerous instruction variants in `inst` while allowing
access to the encoding code. This commit changes no functionality.
2021-05-13 10:46:08 -07:00
Dan Gohman
05d57d8ded Update to cap-std 0.13.10 and system-interface 0.6.4.
This includes fixes for bytecodealliance/cap-std#169,
bytecodealliance/system-interface#15, and bytecodealliance/system-interface#16.
2021-05-12 13:21:32 -07:00
Benjamin Bouvier
d7053ea9c7 Upgrade to the latest versions of gimli, addr2line, object (#2901)
* Upgrade to the latest versions of gimli, addr2line, object

And adapt to API changes. New gimli supports wasm dwarf, resulting in
some simplifications in the debug crate.

* upgrade gimli usage in linux-specific profiling too

* Add "continue" statement after interpreting a wasm local dwarf opcode
2021-05-12 10:53:17 -05:00
Afonso Bordado
ac624da8d9 Handle i128 arguments in the aarch64 ABI
When dealing with params that need to be split, we follow the
arch64 ABI and split the value in two, and make sure that start that
argument in an even numbered xN register.

The apple ABI does not require this, so on those platforms, we start
params anywhere.
2021-05-12 13:06:13 +01:00
Peter Huene
60f7b23ea1 Merge pull request #2899 from bytecodealliance/pch/even_longer_timeout
wasi-tokio: up test timeouts from 20ms to 50ms
2021-05-11 19:48:43 -07:00
Pat Hickey
c81dbe498f try upping 20ms to 50ms timeouts... 2021-05-11 17:12:48 -07:00
Peter Huene
e36fff894a Merge pull request #2879 from peterhuene/allow-unknown-exports
Implement the `allow-unknown-exports` option for the run command.
2021-05-11 12:45:48 -07:00
Chris Fallin
64202cc017 Merge pull request #2893 from bjorn3/no_errno
Remove errno dependency from cranelift-jit
2021-05-11 10:50:59 -07:00
Pat Hickey
e97cdb64f1 Merge pull request #2896 from bytecodealliance/pch/wasi_stdio_test_timeout
wasi stdio tests: increase timeout
2021-05-11 10:39:23 -07:00
Pat Hickey
e66909f710 wasi-tokio: increase timeout in poll_oneoff test here as well 2021-05-11 09:24:15 -07:00
Pat Hickey
7ec93cb977 poll_oneoff_stdio test: increase timeout to 20ms 2021-05-11 09:22:12 -07:00
bjorn3
05b9037bbb Use .map() 2021-05-11 17:11:43 +02:00
bjorn3
bb769afe6b Remove errno dependency from cranelift-jit 2021-05-11 12:58:39 +02:00
Chris Fallin
5fb2c8c235 Merge pull request #2874 from uweigand/s390x-backend
Support IBM z/Architecture
2021-05-10 13:53:23 -07:00
Chris Fallin
db8ccb54b6 Merge pull request #2886 from afonso360/x64-i128-shift-amt
Allow i128 amount operands on shift instructions in the x64 backend
2021-05-10 12:50:21 -07:00
Afonso Bordado
e021995323 Allow i128 amount operands on shift instructions in the x64 backend
Fixes #2727.
2021-05-10 18:32:20 +01:00
Ulrich Weigand
89b5fc776d Support IBM z/Architecture
This adds support for the IBM z/Architecture (s390x-ibm-linux).

The status of the s390x backend in its current form is:
- Wasmtime is fully functional and passes all tests on s390x.
- All back-end features supported, with the exception of SIMD.
- There is still a lot of potential for performance improvements.
- Currently the only supported processor type is z15.
2021-05-10 16:01:16 +02:00
Pat Hickey
f60ae73d15 Merge pull request #2832 from bytecodealliance/pch/wiggle_sync_shimming
wasi-common support for tokio, & wiggle support for async methods containing sync code
2021-05-07 17:43:42 -07:00
Pat Hickey
bae1a5693d 10ms here, and let it timeout in addition to ready? 2021-05-07 16:20:12 -07:00
Pat Hickey
74e9b385df lets try 10ms, macos ci timed out with 5ms 2021-05-07 16:07:15 -07:00
Pat Hickey
548b6c5311 windows fixes 2021-05-07 15:51:33 -07:00
Pat Hickey
86bd56f6d1 turn off fail-fast again 2021-05-07 15:42:03 -07:00
Pat Hickey
b450094dad debug 2021-05-07 15:19:17 -07:00
Pat Hickey
68fdadde26 tokio poll_oneoff test: CI needs more than 1ms to complete it 2021-05-07 15:19:02 -07:00
Dan Gohman
ec5d8016f7 On Windows, ignore files for which full_metadata fails.
On Windows, `metadata` computes only partial metadata results, which don't
include what WASI needs for the `inode` field in `readdir` results. cap-std
has a `full_metadata` function which is able to include this extra
information, however it has more strict access requirements, so it sometimes
fails even when plain `metadata` would succeed.

Make WASI's `readdir` silently skip over files that can't be accessed by
`full_metadata`. These files wouldn't be openable in any other way by
WASI programs, so the only benefit of listing them would be to
let applications know that they exist. This allows it to avoid failing
and avoid returning bogus results.

This is part of a fix for bytecodealliance/cap-std#169.
2021-05-07 14:47:39 -07:00
Pat Hickey
ee8a8a2a90 poll_oneoff_stdio test: loosen up contract
permit both readable events to be delivered in very short interval,
rather than simultaneously.
2021-05-07 14:27:23 -07:00
Pat Hickey
9b09272936 poll_oneoff: bound tests for time, rather than instant completion 2021-05-07 12:19:51 -07:00
Pat Hickey
b7593cb8fe Merge remote-tracking branch 'origin/main' into pch/wiggle_sync_shimming 2021-05-06 17:54:03 -07:00
Pat Hickey
002b0744eb Merge pull request #2881 from bytecodealliance/pch/cargo_deny_ignore_RUSTSEC-2021-0064
cargo deny: ignore RUSTSEC-2021-0064
2021-05-06 17:43:10 -07:00
Pat Hickey
9d6f64b33d cargo deny: ignore RUSTSEC-2021-0064
Transient dependencies depend on two different versions of `cpuid-bool`.

This advisory does not appear to be urgent. We should review this ignore
after a few weeks to see if our deps have switched over.

text of the advisory:

Issued
May 6, 2021
Package
cpuid-bool (crates.io)
Type
Unmaintained
Details
https://github.com/RustCrypto/utils/pull/381
Patched
no patched versions
Description
Please use the `cpufeatures`` crate going forward:

https://github.com/RustCrypto/utils/tree/master/cpufeatures

There will be no further releases of cpuid-bool.
2021-05-06 17:08:05 -07:00