Commit Graph

9447 Commits

Author SHA1 Message Date
Benjamin Bouvier
2649d2352c Support vtune profiling of trampolines too (#3687)
* Provide helpers for demangling function names

* Profile trampolines in vtune too

* get rid of mapping

* avoid code duplication with jitdump_linux

* maintain previous default display name for wasm functions

* no dash, grrr

* Remove unused profiling error type
2022-01-19 09:49:23 -06:00
Mrmaxmeier
2afd6900f4 runtime: expose DefaultMemoryCreator (#3670) 2022-01-18 09:17:33 -06:00
Chris Fallin
06a7bfdcbd Merge pull request #3692 from akirilov-arm/abi_isa_flags
Cranelift: Pass the ISA-specific compilation flags to the ABI implementations
2022-01-17 22:46:58 -08:00
Anton Kirilov
89919f4b1f Pass the ISA-specific compilation flags to the ABI implementations
Copyright (c) 2021, Arm Limited.
2022-01-14 14:18:01 +00:00
Nick Fitzgerald
df37074218 Merge pull request #3690 from fitzgen/a-bunch-more-isle
cranelift: Port a bunch more lowerings to ISLE on x64
2022-01-13 18:08:31 -08:00
Nick Fitzgerald
a052285340 Fix typo: s/sentinals/sentinels/ 2022-01-13 16:50:15 -08:00
Nick Fitzgerald
658c5d33c1 cranelift: Port trap and resumable_trap lowering to ISLE on x64 2022-01-13 15:57:17 -08:00
Nick Fitzgerald
5bb3645bd4 cranelift: Port ineg SIMD lowering to ISLE on x64 2022-01-13 15:57:17 -08:00
Nick Fitzgerald
7d943f68c5 Merge pull request #3688 from fitzgen/ushr-simd-isle
cranelift: Port `ushr` SIMD lowerings to ISLE on x64
2022-01-13 15:35:05 -08:00
Nick Fitzgerald
5917f1d2c2 cranelift: Port ineg scalar lowering to ISLE on x64 2022-01-13 15:08:01 -08:00
Nick Fitzgerald
b78731839b cranelift: Use x64_ prefix to disambiguate with clif in ISLE
Instead of using `m_` like we used to, which was short for "mach inst" but not
obvious or clear at all.
2022-01-13 14:59:09 -08:00
Nick Fitzgerald
a41fdb0303 cranelift: Port rotr lowering to ISLE on x64 2022-01-13 14:59:09 -08:00
Nick Fitzgerald
4120e40318 cranelift: Update assertions to indicate that rotl is fully ported to ISLE on x64 2022-01-13 14:59:09 -08:00
Nick Fitzgerald
4e34dd8239 cranelift: Port ushr SIMD lowerings to ISLE on x64 2022-01-13 14:39:06 -08:00
Alex Crichton
46ade3dab3 Try to fix CI for Rust 1.58 (#3689)
PATH lookup for WIndows command execution was tweaked slightly to not
search the cwd, so let's see if this fixes things...
2022-01-13 16:38:32 -06:00
Nick Fitzgerald
a7dba81c1d cranelift: Port ishl SIMD lowerings to ISLE (#3686) 2022-01-13 09:34:37 -06:00
Chris Fallin
13f17db297 Merge pull request #3680 from bjorn3/remove_code_sink
Remove the CodeSink interface in favor of MachBufferFinalized
2022-01-12 10:47:23 -08:00
Nick Fitzgerald
eeca41d666 Merge pull request #3683 from bytecodealliance/demangle-names-in-profiling
Try demangling names before forwarding them to the profiler
2022-01-12 10:31:56 -08:00
Benjamin Bouvier
e53f213ac4 Try demangling names before forwarding them to the profiler
Before this PR, each profiler (perf/vtune, at the moment) had to have a
demangler for each of the programming languages that could have been
compiled to wasm and fed into wasmtime. With this, wasmtime now
demangles names before even forwarding them to the underlying profiler,
which makes for a unified representation in profilers, and avoids
incorrect demangling in profilers.
2022-01-12 19:17:42 +01:00
bjorn3
17021bc77a Extract helper functions 2022-01-12 17:19:34 +01:00
Nick Fitzgerald
7454f1f3af cranelift: port sshr to ISLE on x64 (#3681) 2022-01-12 09:13:58 -06:00
bjorn3
f0e821b9e0 Remove all Sink traits 2022-01-11 19:03:10 +01:00
bjorn3
b803514d55 Remove sink arguments from compile_and_emit
The data can be accessed after the fact using context.mach_compile_result
2022-01-11 18:17:29 +01:00
bjorn3
55d722db05 Remove CodeSink 2022-01-11 17:10:37 +01:00
bjorn3
a48a60f958 Remove reloc_external from CodeSink
And introduce MachBufferFinalized::relocs() in the place.
2022-01-11 16:54:27 +01:00
bjorn3
63e2360346 Remove trap from CodeSink
And introduce MachBufferFinalized::traps() in the place.
2022-01-11 16:42:52 +01:00
bjorn3
38aaa6e1da Remove add_call_site from CodeSink and RelocSink
And introduce MachBufferFinalized::call_sites() in the place.
2022-01-11 16:32:57 +01:00
bjorn3
379c9c65a3 Inline MemoryCodeSink::write 2022-01-11 15:10:02 +01:00
bjorn3
37598ad170 Remove end_codegen method from CodeSink 2022-01-11 14:52:04 +01:00
bjorn3
354c4f7bf8 Remove unused CodeSink methods 2022-01-11 14:52:04 +01:00
bjorn3
88baac4ca6 Move the TestCodeSink functionality to MachBufferFinalized 2022-01-11 14:40:53 +01:00
Alex Crichton
1ef0abb12c Update lots of isa/*/*.clif tests to precise-output (#3677)
* Update lots of `isa/*/*.clif` tests to `precise-output`

This commit goes through the `aarch64` and `x64` subdirectories and
subjectively changes tests from `test compile` to add `precise-output`.
This then auto-updates all the test expectations so they can be
automatically instead of manually updated in the future. Not all tests
were migrated, largely subject to the whims of myself, mainly looking to
see if the test was looking for specific instructions or just checking
the whole assembly output.

* Filter out `;;` comments from test expctations

Looks like the cranelift parser picks up all comments, not just those
trailing the function, so use a convention where `;;` is used for
human-readable-comments in test cases and `;`-prefixed comments are the
test expectation.
2022-01-10 13:38:23 -06:00
Alex Crichton
a8ea0ec097 cranelift: Add ability to auto-update test expectations (#3612)
* cranelift: Add ability to auto-update test expectations

One of the problems of the current `*.clif` testing is that the files
are difficult to update when widespread changes are made (such as
removing modification of the frame pointer). Additionally when changing
register allocation or similar it can cause a large number of changes in
tests but the tests themselves didn't actually break. For this reason
this commit adds the ability to automatically update test expectations.

The idea behind this commit is that tests of the form `test compile` can
also optionally be flagged with the `precise-output` flag:

    test compile precise-output

and when doing so the compiled form of each function is asserted to 100%
match the following comments and their test expectations. If a match is
not found then a `BLESS=1` environment variable can be used to
automatically rewrite the test file itself with the correct assertion.
If the environment variable isn't present and the expectation doesn't
match then the test fails.

It's hoped that, if approved, a follow-up commit can add
`precise-output` to all current `test compile` tests (or make it the
default) and all tests can be mass-updated. When developing locally test
expectations need not be written and instead tests can be run with
`BLESS=1` and the output can be manually verified. The environment
variable will not be present on CI which means that changes to the
output which don't also change the test expectation will cause CI to
fail. Furthermore this should still make updates to the test output
easily readable in review on CI because the test expectations are
intended to look the same as before.

Closes #1539

* Use raw vcode output in tests

* Fix a merge conflict

* Review comments
2022-01-10 11:59:45 -06:00
Chris Fallin
c6a62427a4 Merge pull request #3676 from bytecodealliance/bnjbvr-patch-1
Meeting notes for Cranelift meeting on 2022-01-10
2022-01-10 09:55:51 -08:00
Benjamin Bouvier
092be49175 Meeting notes for Cranelift meeting on 2022-01-10 2022-01-10 18:43:48 +01:00
Nick Fitzgerald
2e2620c07f Merge pull request #3671 from alexcrichton/table-ops-terminate
fuzz: Fix infinite loops in table_ops fuzzers
2022-01-10 09:34:07 -08:00
Alex Crichton
fd2636c25a wasmtime: Make rustix an unconditional dependency (#3675)
This is unconditionally used on aarch64 and otherwise trying to manage
the precise clause for making it conditional vs unconditional probably
isn't worth it.

Closes #3672
2022-01-10 10:47:35 -06:00
Piotr Sikora
642102e699 Fix build with clang on s390x. (#3673)
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2022-01-10 09:27:27 -06:00
Alex Crichton
2459776424 fuzz: Fix infinite loops in table_ops fuzzers
I forgot in the recent refactoring to add back in fuel support to the
`table_ops` fuzzer. This commit re-adds the previously existent logic to
always use fuel to cancel execution of the table_ops fuzzer.
2022-01-08 17:19:00 -08:00
Cheng Kai
894a4d8301 Remove unnecessary into_iter/collect (#3667)
* Remove unnecessary into_iter/collect

flags and isa_flags were already of the correct type in
HashedEngineCompileEnv's implementation.

* Cargo fmt
2022-01-07 17:35:51 -06:00
Alex Crichton
ab1d845ac1 Refactor fuzzing configuration and sometimes disable debug verifier. (#3664)
* fuzz: Refactor Wasmtime's fuzz targets

A recent fuzz bug found is related to timing out when compiling a
module. This timeout, however, is predominately because Cranelift's
debug verifier is enabled and taking up over half the compilation time.
I wanted to fix this by disabling the verifier when input modules might
have a lot of functions, but this was pretty difficult to implement.

Over time we've grown a number of various fuzzers. Most are
`wasm-smith`-based at this point but there's various entry points for
configuring the wasm-smith module, the wasmtime configuration, etc. I've
historically gotten quite lost in trying to change defaults and feeling
like I have to touch a lot of different places. This is the motivation
for this commit, simplifying fuzzer default configuration.

This commit removes the ability to create a default `Config` for
fuzzing, instead only supporting generating a configuration via
`Arbitrary`. This then involved refactoring all targets and fuzzers to
ensure that configuration is generated through `Arbitrary`. This should
actually expand the coverage of some existing fuzz targets since
`Arbitrary for Config` will tweak options that don't affect runtime,
such as memory configuration or jump veneers.

All existing fuzz targets are refactored to use this new method of
configuration. Some fuzz targets were also shuffled around or
reimplemented:

* `compile` - this now directly calls `Module::new` to skip all the
  fuzzing infrastructure. This is mostly done because this fuzz target
  isn't too interesting and is largely just seeing what happens when
  things are thrown at the wall for Wasmtime.

* `instantiate-maybe-invalid` - this fuzz target now skips instantiation
  and instead simply goes into `Module::new` like the `compile` target.
  The rationale behind this is that most modules won't instantiate
  anyway and this fuzz target is primarily fuzzing the compiler. This
  skips having to generate arbitrary configuration since
  wasm-smith-generated-modules (or valid ones at least) aren't used
  here.

* `instantiate` - this fuzz target was removed. In general this fuzz
  target isn't too interesting in isolation. Almost everything it deals
  with likely won't pass compilation and is covered by the `compile`
  fuzz target, and otherwise interesting modules being instantiated can
  all theoretically be created by `wasm-smith` anyway.

* `instantiate-wasm-smith` and `instantiate-swarm` - these were both merged
  into a new `instantiate` target (replacing the old one from above).
  There wasn't really much need to keep these separate since they really
  only differed at this point in methods of timeout. Otherwise we much
  more heavily use `SwarmConfig` than wasm-smith's built-in options.

The intention is that we should still have basically the same coverage
of fuzzing as before, if not better because configuration is now
possible on some targets. Additionally there is one centralized point of
configuration for fuzzing for wasmtime, `Arbitrary for ModuleConfig`.
This internally creates an arbitrary `SwarmConfig` from `wasm-smith` and
then further tweaks it for Wasmtime's needs, such as enabling various
wasm proposals by default. In the future enabling a wasm proposal on
fuzzing should largely just be modifying this one trait implementation.

* fuzz: Sometimes disable the cranelift debug verifier

This commit disables the cranelift debug verifier if the input wasm
module might be "large" for the definition of "more than 10 functions".
While fuzzing we disable threads (set them to 1) and enable the
cranelift debug verifier. Coupled with a 20-30x slowdown this means that
a module with the maximum number of functions, 100, gives:

    60x / 100 functions / 30x slowdown = 20ms

With only 20 milliseconds per function this is even further halved by
the `differential` fuzz target compiling a module twice, which means
that, when compiling with a normal release mode Wasmtime, if any
function takes more than 10ms to compile then it's a candidate for
timing out while fuzzing. Given that the cranelift debug verifier can
more than double compilation time in fuzzing mode this actually means
that the real time budget for function compilation is more like 4ms.

The `wasm-smith` crate can pretty easily generate a large function that
takes 4ms to compile, and then when that function is multiplied 100x in
the `differential` fuzz target we trivially time out the fuzz target.

The hope of this commit is to buy back half our budget by disabling the
debug verifier for modules that may have many functions. Further
refinements can be implemented in the future such as limiting functions
for just the differential target as well.

* Fix the single-function-module fuzz configuration

* Tweak how features work in differential fuzzing

* Disable everything for baseline differential fuzzing
* Enable selectively for each engine afterwards
* Also forcibly enable reference types and bulk memory for spec tests

* Log wasms when compiling

* Add reference types support to v8 fuzzer

* Fix timeouts via fuel

The default store has "infinite" fuel so that needs to be consumed
before fuel is added back in.

* Remove fuzzing-specific tests

These no longer compile and also haven't been added to in a long time.
Most of the time a reduced form of original the fuzz test case is added
when a fuzz bug is fixed.
2022-01-07 15:12:25 -06:00
Nick Fitzgerald
ab5aea7b28 Merge pull request #3665 from fitzgen/re-add-tests
cranelift: Re-add some tests that were accidentally removed
2022-01-07 11:37:53 -08:00
Alex Crichton
3ab6ef048b aarch64: Migrate popcnt to ISLE (#3662)
Nothing too unusual here, the translation was quite straightforward!
2022-01-07 13:06:53 -06:00
Nick Fitzgerald
95d8dd1424 cranelift: Re-add some tests that were accidentally removed 2022-01-07 11:00:58 -08:00
Chris Fallin
ebb0e4052b Merge pull request #3663 from teymour-aldridge/patch-1
Add a link to the JIT demo.
2022-01-07 10:44:08 -08:00
Teymour Aldridge
8d50cf3e23 Add a link to the JIT demo. 2022-01-07 16:08:05 +00:00
Nick Fitzgerald
6b5e9d8732 Merge pull request #3659 from fitzgen/vselect-isle
cranelift: Port `vselect` over to ISLE on x64
2022-01-06 14:51:33 -08:00
Nick Fitzgerald
056f7c2674 cranelift: Port vselect over to ISLE on x64 2022-01-06 14:10:57 -08:00
Chris Fallin
a98f9982fd Merge pull request #3655 from bjorn3/machinst_cleanups2
Remove MachBackend
2022-01-06 13:32:36 -08:00
Alex Crichton
72e2b7fe80 aarch64: Migrate bitrev/clz/cls/ctz to ISLE (#3658)
This commit migrates these existing instructions to ISLE from the manual
lowerings implemented today. This was mostly straightforward but while I
was at it I fixed what appeared to be broken translations for I{8,16}
for `clz`, `cls`, and `ctz`. Previously the lowerings would produce
results as-if the input was 32-bits, but now I believe they all
correctly account for the bit-width.
2022-01-06 15:18:32 -06:00