Commit Graph

8834 Commits

Author SHA1 Message Date
Afonso Bordado
d20194fa4c Enable all aarch64 features in QEMU CI runner, except PAC (#3325)
* Enable all aarch64 features in QEMU CI runner, except PAC

* Upgrade QEMU version to 6.1.0
2021-09-15 09:30:17 -05:00
Chris Fallin
2412e8d784 Merge pull request #3317 from dheaton-arm/implement-swiden
Implement `SwidenLow` and `SwidenHigh` for the interpreter
2021-09-14 08:57:57 -07:00
Alex Crichton
b759514124 Allow wasmtime/v8 to differ on errors slightly (#3348)
I'm not sure why when run repeatedly v8 has different limits on
call-stack-size but it's not particularly interesting to assert exact
matches here, so this should fix a fuzz-bug-failure found on oss-fuzz.
2021-09-14 10:40:24 -05:00
dheaton-arm
99cc95d630 Factor out shared logic for widening ops.
Copyright (c) 2021, Arm Limited
2021-09-14 13:08:35 +01:00
dheaton-arm
a595bd22e3 Replace loops with iterator methods.
Copyright (c) 2021, Arm Limited
2021-09-14 12:37:36 +01:00
dheaton-arm
d2cbe4fc30 Fix failing test from old x86 backend
Copyright (c) 2021, Arm Limited
2021-09-14 12:37:36 +01:00
dheaton-arm
75ef00f1fd Implement SwidenLow and SwidenHigh for the interpreter
Implemented `SwidenLow` and `SwidenHigh` for the Cranelift interpreter,
doubling the width and halving the number of lanes preserving the low
and high halves respectively.

Conversions are performed using signed extension.

Copyright (c) 2021, Arm Limited
2021-09-14 12:37:36 +01:00
Alex Crichton
4d4779b563 Restore running precompiled modules with the CLI (#3343)
* Restore running precompiled modules with the CLI

This was accidentally broken when `Module::deserialize` was split out of
`Module::new` long ago, so this adds the detection in the CLI to call
the appropriate method to load the module. This feature is gated behind
an `--allow-precompiled` flag to enable, by default, passing arbitrary
user input to the `wasmtime` command.

Closes #3338

* Fix test on Windows
2021-09-13 15:30:46 -05:00
Dan Gohman
d1fce1e836 Modify the poll_oneoff_files test tolerate OS differences. (#3346)
Modify the `poll_oneoff_files` test to avoid assuming that `poll_oneoff`
returns all pending events, as it may sometimes return only a subset of
events. When multiple events are expected, use a loop, and loop until
all events have been recorded.
2021-09-13 14:59:50 -05:00
Chris Fallin
192586506d Merge pull request #3342 from akirilov-arm/aarch64_lowering_type_checks
Cranelift AArch64: Improve the type checks for IR operations
2021-09-13 10:12:06 -07:00
Chris Fallin
7421e1a65b Merge pull request #3324 from dheaton-arm/implement-shuffle
Implement `Shuffle` for the interpreter
2021-09-13 09:49:59 -07:00
Chris Fallin
9323762d71 Merge pull request #3314 from dheaton-arm/implement-bitops
Implement bit operations for Cranelift interpreter
2021-09-13 09:29:10 -07:00
Denis
e85a57d51b Updated README.md with reference to C Conan package (#3307) 2021-09-13 09:26:38 -05:00
Anton Kirilov
8805e25042 Cranelift AArch64: Improve the type checks for IR operations
There were cases where the AArch64 backend assumed that an IR
operation would always operate on certain types (the most likely
reason being that the corresponding WebAssembly instruction did
not cover anything else), even though the definition of the IR
operation imposed no constraints like that.

Copyright (c) 2021, Arm Limited.
2021-09-13 14:46:45 +01:00
Dan Gohman
4d86f0ca10 Update to cap-std 0.19.0 and rsix 0.22.4. (#3331)
This pulls in the s390x fix needed by #3330.

Also a small `rsix` API update; `PollFdVec` has been removed in favor of
just using `Vec<PollFd>`.
2021-09-11 12:28:30 -05:00
Dan Gohman
256e942aa0 Tidy up redundant use declarations. (#3333)
This is just a minor code cleanup.
2021-09-11 12:26:54 -05:00
Chris Fallin
587f603018 Merge pull request #3316 from dheaton-arm/implement-uwiden
Implement `UwidenLow` and `UwidenHigh` for the interpreter
2021-09-10 12:32:50 -07:00
Chris Fallin
962e61eb34 Merge pull request #3306 from afonso360/trampoline-simd-bools
Implement SIMD bools in trampoline
2021-09-10 12:31:53 -07:00
Afonso Bordado
3c1133379c cranelift: Add is_bool_vector helper 2021-09-10 15:46:14 +01:00
Afonso Bordado
85d468dc5a cranelift: Add coerce_bools_to_ints helper 2021-09-10 15:38:30 +01:00
Afonso Bordado
d31bdff7db cranelift: Use bool args in simd tests 2021-09-10 15:10:51 +01:00
Afonso Bordado
9460a4fb16 cranelift: Support bool vectors in trampoline 2021-09-10 15:10:51 +01:00
dheaton-arm
4a4f940fac Move immediate value retrieval to imm
Copyright (c) 2021, Arm Limited
2021-09-10 12:36:33 +01:00
dheaton-arm
e7d570ddd9 Collect into Result rather than unwrap
Copyright (c) 2021, Arm Limited
2021-09-10 12:26:48 +01:00
dheaton-arm
924b0368e9 Rewrite as iterator methods
Copyright (c) 2021, Arm Limited
2021-09-10 09:41:23 +01:00
Nick Fitzgerald
37c094faf5 Merge pull request #3323 from fitzgen/unwind-info-cleanups
Unwind info cleanups
2021-09-09 14:38:52 -07:00
Nick Fitzgerald
4b256ab968 Place unwind info directly after the text section, even when debug info is enabled
When debug info was enabled, we would put the debug info sections in between the
text section and the unwind info section. But the unwind info is encoded in a
position-independent manner (so that we don't need relocs for it) that relies on
it directly following the text section. The result of the misplacement was some
crashes inside the unwinder.
2021-09-09 13:39:30 -07:00
Nick Fitzgerald
0499cca2fa Name unwind info .eh_frame in the Wasmtime's compiled ELF artifact
We were previously using `_wasmtime_eh_frame` but there is no good reason to
add the prefix Wasmtime-specific prefix. Using the standard name allows for
better inspection with standard tools like `dwarfdump`.
2021-09-09 12:54:49 -07:00
Nick Fitzgerald
dd0bc3237e Do not write a DWARF section if it is empty
There is no point in writing an empty DWARF section, and this will make our ELF
files a tiny bit smaller.
2021-09-09 12:54:13 -07:00
Alex Crichton
e26b91e890 Remove unnecessary annotations on Module::get_export (#3318)
I think these were historically needed but nowadays not necessary!
2021-09-09 11:54:50 -07:00
Pat Hickey
bd19f43f84 rewrite Store::{entering,exiting}_native_code_hook into Store::call_hook (#3313)
which provides additional detail on what state transition is being made
2021-09-09 09:20:45 -05:00
Alex Crichton
8ebaaf928d Remove the wasmtime wasm2obj command (#3301)
* Remove the `wasmtime wasm2obj` command

This commit removes the `wasm2obj` subcommand of the `wasmtime` CLI.
This subcommand has a very long history and dates back quite far. While
it's existed, however, it's never been documented in terms of the output
it's produced. AFAIK it's only ever been used for debugging to see the
machine code output of Wasmtime on some modules. With recent changes to
the module serialization output the output of `wasmtime compile`, the
`*.cwasm` file, is now a native ELF file which can be fed to standard
tools like `objdump`. Consequently I dont think there's any remaining
need to keep `wasm2obj` around itself, so this commit removes the
subcommand.

* More code to delete

* Try to fix debuginfo tests
2021-09-08 10:40:58 -05:00
dheaton-arm
5824cca0f8 Fix test failures from old x86 backend
Copyright (c) 2021, Arm Limited
2021-09-08 15:43:08 +01:00
dheaton-arm
f7a1b3f9bd Implement UwidenLow and UwidenHigh for the interpreter
Implemented `UwidenLow` and `UwidenHigh` for the Cranelift interpreter,
doubling the width and halving the number of lanes preserving the low
and high halves respectively. Conversions are performed using unsigned
zero extension.

Copyright (c) 2021, Arm Limited
2021-09-08 14:17:11 +01:00
dheaton-arm
dfe1c914ea Cast types back to expected in macros
Also neatened `popcnt` a little following feedback.

Copyright (c) 2021, Arm Limited
2021-09-08 12:36:01 +01:00
dheaton-arm
bca3cb32ef Implement Shuffle for the interpreter
Implemented `Shuffle` for the Cranelift interpreter, to shuffle two SIMD
vectors together based on an immediate mask of 16 bytes.

Copyright (c) 2021, Arm Limited
2021-09-08 11:13:57 +01:00
dheaton-arm
9f647301ff Implement bit operations for Cranelift interpreter
Implemented for the Cranelift interpreter:
- `Bitrev` to reverse the order of the bits in an integer.
- `Cls` to count the leading bits which are the same as the sign bit in
an integer, yielding one less than the size of the integer for 0 and -1.
- `Clz` to count the number of leading zeros in the bitwise representation of the
integer.
- `Ctz` to count the number of trailing zeros in the bitwise representation of the
integer.
- `Popcnt` to count the number of ones in the bitwise representation of the
integer.

Copyright (c) 2021, Arm Limited
2021-09-08 11:07:22 +01:00
Chris Fallin
164835ecf5 Merge pull request #3309 from afonso360/fix-build
cranelift: Fix build error
2021-09-07 10:50:18 -07:00
Afonso Bordado
3f62ef6e58 cranelift: Fix Build error
#3304 and #3268 are slightly incomptible and caused the build to fail
when they were merged together
2021-09-07 18:13:45 +01:00
Damian Heaton
dd23a21b9b Implement Swizzle and Splat for interpreter (#3268)
* Implement `Swizzle` and `Splat` for interpreter

Implemented for the Cranelift interpreter:
- `Swizzle` to shuffle an `i8x16` SIMD vector based
on the indices specified in another vector of the same size.
- `Splat` to create a SIMD vector with all lanes having the same value.

Copyright (c) 2021, Arm Limited

* Fix old x86 backend failing test

Copyright (c) 2021, Arm Limited

* Represent i16x8 and above as hex

Copyright (c) 2021, Arm Limited
2021-09-07 09:53:49 -07:00
Afonso Bordado
63e9a81deb Implement vany_true and vall_true instructions in interpreter (#3304)
* cranelift: Implement ZeroExtend for a bunch of types in interpreter

* cranelift: Implement VConst on interpreter

* cranelift: Implement VallTrue on interpreter

* cranelift: Implement VanyTrue on interpreter

* cranelift: Mark `v{all,any}_true` tests as machinst only

* cranelift: Disable `vany_true` tests on aarch64

The `b64x2` case produces an illegal instruction. See #3305
2021-09-07 09:50:39 -07:00
Alex Crichton
c73673559b Avoid vector allocations in wasm->host calls (#3294)
This commit improves the runtime support for wasm-to-host invocations
for functions created with `Func::new` or `wasmtime_func_new` in the C
API. Previously a `Vec` (sometimes a `SmallVec`) would be dynamically
allocated on each host call to store the arguments that are coming from
wasm and going to the host. In the case of the `wasmtime` crate we need
to decode the `u128`-stored values, and in the case of the C API we need
to decode the `Val` into the C API's `wasmtime_val_t`.

The technique used in this commit is to store a singular `Vec<T>` inside
the "store", be it the literal `Store<T>` or within the `T` in the case
of the C API, which can be reused across wasm->host calls. This means
that we're unlikely to actually perform dynamic memory allocation and
instead we should hit a faster path where the `Vec` always has enough
capacity.

Note that this is just a mild improvement for `Func::new`-based
functions. It's still the case that `Func::wrap` is much faster, but
unfortunately the C API doesn't have access to `Func::wrap`, so the main
motivation here is accelerating the C API.
2021-09-03 15:14:21 -05:00
Chris Fallin
0473e1990a Merge pull request #3299 from afonso360/fuzzer-brtable
Cranelift CLIF Fuzzer add jump tables and `br_table`
2021-09-03 12:43:55 -07:00
Chris Fallin
3db8043a02 Merge pull request #3300 from cfallin/cranelift-mtg-20210906
Cranelift agenda for Mon Sep 6: cancel meeting (empty agenda + US holiday).
2021-09-03 12:01:03 -07:00
Chris Fallin
ab7157088f Cranelift agenda for Mon Sep 6: cancel meeting (empty agenda + US holiday). 2021-09-03 11:58:54 -07:00
Alex Crichton
ca3947911e Refactor the internals of Store<T> (#3291)
* Refactor the internals of `Store<T>`

This commit is an overdue refactoring and renaming of some internals of
the `Store` type in Wasmtime. The actual implementation of `Store<T>`
has evolved from the original implementation to the point where some of
the aspects of how things are structured no longer makes sense. There's
also always been a lot of unnecessary gymnastics when trying to get
access to various store pieces depending on where you are in `wasmtime`.

This refactoring aims to simplify all this and make the internals much
easier to read/write. The following changes were made:

* The `StoreOpaque<'_>` type is deleted, along with the `opaque()`
  method.

* The `StoreInnermost` type was renamed to `StoreOpaque`.
  `StoreOpaque<'_>` is dead. Long live `StoreOpaque`. This renaming
  and a few small tweaks means that this type now suffices for all
  consumers.

* The `AsContextMut` and `AsContext` traits are now implemented for
  `StoreInner<T>`.

These changes, while subtly small, help clean up a lot of the internals
of `wasmtime`. There's a lot less verbose `&mut
store.as_context_mut().opaque()` now. Additionally many methods can
simply start with `let store = store.as_context_mut().0;` and use things
internally. One of the nicer aspects of using references directly is
that the compiler automatically reborrows references as necessary
meaning there's lots of less manual reborrowing.

The main motivation for this change was actually somewhat roundabout
where I found that when `StoreOpaque<'_>` was being captured in closures
and iterators it's 3 pointers wide which is a lot of data to move
around. Now things capture over `&mut StoreOpaque` which is just one
nice and small pointer to move around. In any case though I've long
wanted to revisit the design of these internals to improve the
ergonomics. It's not expected that this change alone will really have
all that much impact on the performance of `wasmtime`.

Finally a doc comment was added to `store.rs` to try to explain all the
`Store`-related types since there are a nontrivial amount.

* Rustfmt
2021-09-03 13:55:18 -05:00
Alex Crichton
50ce19a4a4 Remove an indirect function call in Func::new (#3293)
This commit optimizes the runtime execution of `Func::new` by removing
an indirect function call that happens whenever a host function is
called. This indirection was generally done to prevent monomoprhizing a
lot into consumer code but the few extra functions this makes
monomorphic are fairly small, and in general wasm->host call performance
is pretty important.

While not a massive win this is expected to improve codegen, especially
because with the indirect call removed the compiler should now be able
to prove more often when a `Func::new` closure doesn't panic or return
an error.
2021-09-03 13:40:51 -05:00
Afonso Bordado
81d5781e6c cranelift: CLIF fuzzer generate jump tables and br_table 2021-09-03 19:10:49 +01:00
Afonso Bordado
cbfae6f336 cranelift: CLIF fuzzer refactor param count generation 2021-09-03 19:10:49 +01:00
Chris Fallin
36b7e81979 Merge pull request #3094 from afonso360/fuzzer-branching
Cranelift CLIF Fuzzer generate blocks and branches
2021-09-03 10:30:14 -07:00