Commit Graph

8416 Commits

Author SHA1 Message Date
Alex Crichton
e8b8947956 Bump to 0.28.0 (#2972) 2021-06-09 14:00:13 -05:00
bjorn3
e6f399419c Atomic hotswapping in JIT mode (#2786)
* Introduce new_got_entry and new_plt_entry functions

* Return NonNull<*const u8> from get_got_address

* Make GOT entry writes atomic

* Defer GOT updates until relocations and protection

Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-06-09 09:51:11 -07:00
Alex Crichton
884a6500e9 Add a safe method for accessing memory and T (#2971)
This is currently a very common operation in host bindings where if wasm
gives a host function a relative pointer you'll want to simulataneously
work with the host state and the wasm memory. These two regions are
distinct and safe to borrow mutably simulataneously but it's not obvious
in the Rust type system that this is so, so add a helper method here to
assist in doing so.
2021-06-08 09:37:31 -05:00
Pat Hickey
8b4bdf92e2 make ResourceLimiter operate on Store data; add hooks for entering and exiting native code (#2952)
* wasmtime_runtime: move ResourceLimiter defaults into this crate

In preparation of changing wasmtime::ResourceLimiter to be a re-export
of this definition, because translating between two traits was causing
problems elsewhere.

* wasmtime: make ResourceLimiter a re-export of wasmtime_runtime::ResourceLimiter

* refactor Store internals to support ResourceLimiter as part of store's data

* add hooks for entering and exiting native code to Store

* wasmtime-wast, fuzz: changes to adapt ResourceLimiter API

* fix tests

* wrap calls into wasm with entering/exiting exit hooks as well

* the most trivial test found a bug, lets write some more

* store: mark some methods as #[inline] on Store, StoreInner, StoreInnerMost

Co-authored-By: Alex Crichton <alex@alexcrichton.com>

* improve tests for the entering/exiting native hooks

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2021-06-08 09:37:00 -05:00
Chris Fallin
ffb92d9109 Merge pull request #2966 from akirilov-arm/simd_int_to_int_extend
Enable the simd_int_to_int_extend test for AArch64
2021-06-06 23:34:52 -07:00
Johnnie Birch
1770880e19 x64: add support for packed promote and demote (#2783)
* Add support for x64 packed promote low

* Add support for x64 packed floating point demote

* Update vector promote low and demote by adding constraints

Also does some renaming and minor refactoring
2021-06-04 15:59:20 -07:00
Pat Hickey
38ab7a03dd Merge pull request #2946 from bytecodealliance/pch/eager_per_thread_init
expose eager thread-local resource initialization on Engine
2021-06-04 15:42:08 -07:00
Alex Crichton
e516f0339a Update wasm-smith to generate more wasm (#2967)
This brings in bytecodealliance/wasm-tools#277 which should improve the
wasm programs that wasm-smith generates.
2021-06-04 17:11:19 -05:00
Pat Hickey
613309b76c missing docs 2021-06-04 14:22:08 -07:00
Pat Hickey
035d541fd9 add docs 2021-06-04 14:04:14 -07:00
Pat Hickey
2a4c51b77d switch eager vs lazy instantiation to a criterion bench 2021-06-04 12:25:08 -07:00
Pat Hickey
895ee2b85f make Module::deserialize's version check optional via Config (#2945)
* make Module::deserialize's version check optional via Config

A SerializedModule contains the CARGO_PKG_VERSION string, which is
checked for equality when loading. This is a great guard-rail but
some users may want to disable this check (e.g. so they can implement
their own versioning scheme)

* rename config to deserialize_check_wasmtime_version

* add test

* fix doc links

* fix

* thank you rustdoc
2021-06-04 14:18:02 -05:00
Pat Hickey
0a96b6b60a overhead is on calls, not instantiation 2021-06-04 11:35:30 -07:00
Pat Hickey
bf1d1a4e7a add test for eager thread initialization 2021-06-04 11:22:23 -07:00
Pat Hickey
1136917192 golf 2021-06-04 10:47:46 -07:00
Pat Hickey
ff87f45604 expose eager thread-local initialization by the Engine 2021-06-04 10:47:46 -07:00
Anton Kirilov
5e8a8fe5a0 Enable the simd_int_to_int_extend test for AArch64
Copyright (c) 2021, Arm Limited.
2021-06-04 16:10:02 +01:00
Pat Hickey
357b4c7b60 Merge pull request #2947 from bytecodealliance/pch/global_module_rwlock
global module registry: switch from Mutex to RwLock
2021-06-03 16:30:53 -07:00
Alex Crichton
0c90d789e8 Update Cargo.lock, remove deny.toml warning (#2965)
This runs through and updates all our dependencies, additionally
removing the need for ignoring a rustsec warning.

Closes #2882
2021-06-03 17:11:07 -05:00
Alex Crichton
05baddfb2b Add the ability to cache typechecking an instance (#2962)
* Add the ability to cache typechecking an instance

This commit adds the abilty to cache the type-checked imports of an
instance if an instance is going to be instantiated multiple times. This
can also be useful to do a "dry run" of instantiation where no wasm code
is run but it's double-checked that a `Linker` possesses everything
necessary to instantiate the provided module.

This should ideally help cut down repeated instantiation costs slightly
by avoiding type-checking and allocation a `Vec<Extern>` on each
instantiation. It's expected though that the impact on instantiation
time is quite small and likely not super significant. The functionality,
though, of pre-checking can be useful for some embeddings.

* Fix build with async
2021-06-03 17:04:07 -05:00
Pat Hickey
b6483e19d4 global module registry: switch from Mutex to RwLock
@acfoltzer identified this on a code walk through wasmtime with me,
and it was already noted in a comment that we could change if motivated.
2021-06-03 14:50:57 -07:00
Andrew Brown
e25bf362ab Switch to using TargetFrontendConfig in the frontend memory tests
Commit 7d36fd9a1e avoided these
x86-specific tests altogether. This change avoids any dependency on x86
entirely by specifying a frontend configuration (SystemV + U64); this is
enough information for the `FunctionBuilder` to correctly generate the
syscalls.
2021-06-03 11:01:13 -07:00
Chris Fallin
88b6e88781 Merge pull request #2963 from olivierlemasle/main
Remove empty crates directories
2021-06-03 10:21:09 -07:00
Olivier Lemasle
9dde98e33c Remove empty crates directories
In commit 33c791e1f5 (PR #2944), I added LICENSE files to all published
crates. However, since then PR #2897 has been merged and remove 3 crates,
resulting in license files in empty directories.
2021-06-03 18:42:07 +02:00
Alex Crichton
7a1b7cdf92 Implement RFC 11: Redesigning Wasmtime's APIs (#2897)
Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
2021-06-03 09:10:53 -05:00
Chris Fallin
a5a28b1c5b Merge pull request #2958 from abrown/fix-avx512-flags
x64: fix AVX512 flag checks
2021-06-02 18:03:51 -07:00
Olivier Lemasle
7d36fd9a1e Restrict running tests dependent of x86_64
These 5 tests fail with the error "This test requires x86_64 support." when
executed on another architecture.
2021-06-02 10:35:35 -07:00
Andrew Brown
8dc4cc9fe3 x64: fix AVX512 flag checks
Previously, the multiple flags for certain AVX512 instructions were
checked using `OR`: e.g., if the CPU has AVX512VL `OR` AVX512DQ,
emit `VPMULLQ`. This is incorrect--the logic should be `AND`. The Intel
Software Developer Manual, vol. 1, sec. 15.4, has more information on
this (notable there is the suggestion to check with `XGETBV` that the OS
is allowing the use of the XMM registers--but that is a separate issue).
This change switches to `AND` logic in the new backend.
2021-06-01 11:41:16 -07:00
Andrew Brown
2a9f458ea3 x64: lower i8x16.shuffle to VPERMI2B when possible
When shuffling values from two different registers, the x64 lowering for
`i8x16.shuffle` must first shuffle each register separately and then OR
the results with SSE instructions. With `VPERMI2B`, available in
AVX512VL + AVX512VBMI, this can be done in a single instruction after
the shuffle mask has been moved into the destination register. This
change uses `VPERMI2B` for that case when the CPU supports it.
2021-06-01 11:40:53 -07:00
Benjamin Bouvier
51edea9e57 cranelift: introduce a new WasmtimeAppleAarch64 calling convention
The previous choice to use the WasmtimeSystemV calling convention for
apple-aarch64 devices was incorrect: padding of arguments was
incorrectly computed. So we have to use some flavor of the apple-aarch64
ABI there.

Since we want to support the wasmtime custom convention for multiple
returns on apple-aarch64 too, a new custom Wasmtime calling convention
was introduced to support this.
2021-06-01 17:29:12 +02:00
Benjamin Bouvier
aa2c0cd0ec CI: put tests into a separate script so they can be run externally (#2956) 2021-06-01 17:28:47 +02:00
Olivier Lemasle
eadafb1554 s390x: Fix import
cranelift-codegen's build failed on s390x, with this error:

```
error[E0432]: unresolved import `crate::isa::unwind::systemv`
 --> cranelift/codegen/src/isa/s390x/mod.rs:6:25
  |
6 | use crate::isa::unwind::systemv::RegisterMappingError;
  |                         ^^^^^^^ could not find `systemv` in `unwind`
```

This import should be used only with `unwind` feature enabled.
2021-06-01 15:16:41 +02:00
Andrew Brown
40d546c420 Upgrade capstone to v0.8 (#2948) 2021-05-28 09:51:14 -05:00
Olivier Lemasle
33c791e1f5 Add license files
This commit adds LICENSE files to all **published** crates which do
not have it already (most of the crates have it).

Providing the license files is a requiment of the Apache 2.0 License.
2021-05-27 11:56:58 -07:00
Alex Crichton
b90d7d6aed Remove long-outdated misc/rust crate (#2942)
I had no idea this was still in the repository, much less building!
There are much different ways to use wasmtime in Rust nowadays, such as
the `wasmtime` crate!
2021-05-27 12:05:35 -05:00
Amanieu d'Antras
76664fc73e Optimize codegen for SecondaryMap indexing (#2940)
Moves the slow path which resizes the vector out-of-line. The actual
indexing is also done in the out-of-line path which avoids the need for
a second bounds check in the fast path after a potential resize.
2021-05-27 11:09:15 -05:00
Alex Crichton
8127346b4d ci: Use something else for zip files on Windows (#2941)
Apparently `powershell Compress-Archive` produces zip files with
backslashes in filesnames which makes them unable to be extracted with
some Unix variants of extraction. For example [this failure][build] and
using macOS's built-in unzip feature it creates filenames with
backslashes in them rather than subdirectories.

[build]: https://github.com/bytecodealliance/wasmtime-go/runs/2680596219?check_suite_focus=true
2021-05-27 11:08:19 -05:00
Alex Crichton
a2e71dafac ci: Don't test release binaries, nightly, or beta (#2939)
This commit attempts to slim down our CI (more from #2933) by removing
testing both in debug and release mode. I can't actually recall a
concrete issue that this has turned up on CI itself, and otherwise we're
spending quite a lot of time building all of the dev-dependencies in
release mode when testing.

Additionally it removes testing for nightly/beta channels of Rust. One
of the main benefits of this, staying on top of breakage, is already
moot because we pin to a nightly anyway. We have a few nightly
references elsewhere in CI (fuzzing/docs) so we can largely rely on that
(and upstream testing with rust-lang/rust). We in general shouldn't need
to do nightly/beta testing on all builds.

The release builders were actually the only location that MinGW and
AArch64 was tested however. This means that the old nightly/beta
builders are now replaced with AArch64 and MinGW builders. Overall, the
changes made to CI here are:

* Upgrade to QEMU 6.0.0. I thought this would make aarch64 emulation
  faster, but it didn't. Seems good to stay up to date though.
* Replace nightly/beta testing in debug mode with MinGW and AArch64 testing.
* Use `-g0` for C compilation on MinGW because otherwise `gcc` as used
  on CI generates an ICE (!!)
* Exclude `wasi-crypto` from testing. We already exclude
  `wasmtime-wasi-crypto` and it was an accident we were testing the
  `wasi-crypto` crate (which isn't even part of this workspace).
* Remove testing DWARF on the old backend step, which nowadays didn't
  actually do that.
* Remove testing on release builders, making then purely tasked with
  release builds, nothing else.
* Rename `QEMU_VERSION` to `QEMU_BUILD_VERSION` so qemu doesn't just
  immediately exit after printing its version.

Timing wise the release builds are ~20-30 minutes faster, depending on
the platform. This is not really because of testing time but rather we
have a huge dependency tree when `dev-dependencies` are considered
(criterion, tokio, proptest, ...).

MinGW tests are pretty fast since we don't run examples (we're not too
interested in doing examples there, just windows/mac/linux coverage).
AArch64 tests are run with optimizations enabled because unoptimized
tests take ~45 minutes to finish while optimized tests take ~20 minutes.
The build is naturally much faster in debug mode but apparently under
QEMU emulation the debug mode binaries are *extremely* slow compared to
the release binaries, which means that extra time we spend compiling
release tests is more than made up by faster test emulation time.

Closes #2938
2021-05-26 10:12:29 -05:00
Nick Fitzgerald
137e6e8332 Merge pull request #2937 from fitzgen/bench-api-stdio-and-repeated-instantiations
bench-api: pass in explicit stdio files, allow repeated instantiations per compilation
2021-05-25 14:44:51 -07:00
Andrew Brown
459fce3467 x64: lower i8x16.popcnt to VPOPCNTB when possible
When AVX512VL or AVX512BITALG are available, Wasm SIMD's `popcnt`
instruction can be lowered to a single x64 instruction, `VPOPCNTB`,
instead of 8+ instructions.
2021-05-25 12:16:25 -07:00
Alex Crichton
2b0649c74c ci: Remove "publish" step (#2936)
This commit removes the publish step in GitHub actions, insteading
folding all functionality into the release build steps. This avoids
having a separately scheduled job after all the release build jobs which
ends up getting delayed for quite a long time given the current
scheduling algorithm.

This involves refactoring the tarball assembly scripts and refactoring the
github asset upload script too. Tarball assembly now manages everything
internally and does platform-specific bits where necessary. The upload
script is restructured to be run in parallel (in theory) and hopefully
catches various errors and tries to not stomp over everyone else's work.
The main trickiness here is handling `dev`, which is less critical for
correctness than than tags themselves.

As a small tweak build-wise the QEMU build for cross-compiled builders
is now cached unlike before where it was unconditionally built, shaving
a minute or two off build time.
2021-05-25 12:52:41 -05:00
Nick Fitzgerald
18fabd7700 bench-api: Allow multiple instantiations per compilation
We used to allow at most one instantiation per compilation, but there is no
fundamental reason why that should be the case. Allowing multiple instantiations
per compilation allows us to, for example, benchmark repeated instantiation
within Wasmtime's pooling allocator.

This additionally switches to using host functions for WASI and for
`bench_{start,end}` rather than defining them on the linker, this way we can use
a new store for every instantiation and don't need to keep other instances alive
when instantiating new instances.

Finally, we switch all timing to be done through callback functions, rather than
having the bench API caller implicitly start/end timers around bench API
calls. This allows us to more precisely measure phases and exclude things like
file I/O performed when creating a WASI context.
2021-05-24 16:53:22 -07:00
Alex Crichton
e5ac9350b1 ci: Try other syntax for concurrency key (#2935)
After #2932 that [immediately failed][build] on the main branch so this
tries a different key to see if it'll work...

[build]: https://github.com/bytecodealliance/wasmtime/actions/runs/872766013/workflow
2021-05-24 18:26:14 -05:00
Alex Crichton
beaa07eb96 ci: Merge all doc builders into one (#2934)
Also move the gh-pages pushing step from the `publish` phase to just
this singular doc builder.

The motivation for this is to eventually remove the `publish` step since
it interacts badly with GitHub's scheduling of actions. This is
hopefully the first step towards that by removing the doc publish part
of the phase.
2021-05-24 18:26:05 -05:00
Nick Fitzgerald
ba6635dba0 bench-api: Pass in explicit stdin/stdout/stderr
Instead of inheriting stdio, pass in explicit file paths that are opened for
reading (stdin) or writing (stderr/stdout). This will allow sightglass to assert
that benchmarks produce the expected output.
2021-05-24 15:20:10 -07:00
Nick Fitzgerald
13741284b3 bench-api: Add a feature for the old x86_64 backend
This makes it easier to benchmark old vs new backends.
2021-05-24 15:20:10 -07:00
Alex Crichton
8c2413e009 Try to ease up on CI usage slightly (#2932)
* First remove `fail-fast: false` annotations to fail faster. If desired
  this could always be added in a on-off fashion to PRs.
* Next use the new `concurrency` feature to try to cancel previous
  builds, ideally meaning that if a branch is pushed to multiple times
  it only runs CI once.
2021-05-24 16:31:48 -05:00
Chris Fallin
f2fe0c669e Merge pull request #2929 from cfallin/bb-offsets
Provide BB layout info externally in terms of code offsets.
2021-05-24 14:27:53 -07:00
Chris Fallin
37ca06ad3a Merge pull request #2928 from afonso360/aarch64-i128-ops
Implement iadd,isub,imul for i128 in AArch64
2021-05-24 13:27:36 -07:00
Chris Fallin
800cf25bb5 Make the CFG metadata computation conditional on a flag. 2021-05-24 13:01:15 -07:00