Commit Graph

8851 Commits

Author SHA1 Message Date
Nick Fitzgerald
a1f4b46f64 Bump Wasmtime to version 0.30.0; cranelift to 0.77.0 2021-09-17 10:33:50 -07:00
Nick Fitzgerald
833c93b25c use public accessors, not private fields for WasmFuncType params/returns 2021-09-17 10:31:13 -07:00
Nick Fitzgerald
b39f087414 Merge pull request from GHSA-q879-9g95-56mx
Add an assertion that a `HostFunc`'s `store` agrees on engines
2021-09-17 10:29:35 -07:00
Nick Fitzgerald
398a73f0dd Merge pull request from GHSA-4873-36h9-wv49
Stop doing fuzzy search for stack maps
2021-09-17 10:28:50 -07:00
Nick Fitzgerald
101998733b Merge pull request from GHSA-v4cp-h94r-m7xf
Fix a use-after-free bug when passing `ExternRef`s to Wasm
2021-09-17 10:27:29 -07:00
Dan Gohman
e56312e61a Add "cargo:rerun-if-changed=build.rs" to some build.rs files.
Add "cargo:rerun-if-changed=build.rs" in some build.rs files to tell
cargo that it doesn't need to scan the whole package. See the
[Cargo docs] for more info.

[Cargo docs]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed
2021-09-16 11:52:21 -07:00
Pat Hickey
faa117cac4 Merge pull request #3349 from bytecodealliance/pch/limiter
add a hook to ResourceLimiter to detect memory grow failure
2021-09-15 18:04:31 -07:00
Pat Hickey
00d65eccaf does this one hang on qemu too? idk 2021-09-15 16:19:51 -07:00
Pat Hickey
12be7cd720 skip the detect_os_oom_failure test on qemu ci 2021-09-15 15:51:19 -07:00
Pat Hickey
27083e72e3 fix warning 2021-09-15 14:51:52 -07:00
Pat Hickey
bb7f58d936 add a hook to ResourceLimiter to detect memory grow failure.
* allow the ResourceLimiter to reject a memory grow before the
memory's own maximum.
* add a hook so a ResourceLimiter can detect any reason that
a memory grow fails, including if the OS denies additional memory
* add tests for this new functionality. I only took the time to
test the OS denial on Linux, it should be possible on Mac OS
as well but I don't have a test setup. I have no idea how to
do this on windows.
2021-09-15 11:50:23 -07:00
Alex Crichton
b31a4ea16b Add Store::consume_fuel to manually consume fuel (#3352)
This can be useful for host functions that want to consume fuel to
reflect their relative cost. Additionally it's a relatively easy
addition to have and someone's asking for it!

Closes #3315
2021-09-15 13:10:11 -05:00
Alex Crichton
9db418cfd9 Improve linking-related error messages (#3353)
Include more contextual information about why the link failed related to
why the types didn't match.

Closes #3172
2021-09-15 11:42:45 -05:00
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
Nick Fitzgerald
d2ce1ac753 Fix a use-after-free bug when passing ExternRefs to Wasm
We _must not_ trigger a GC when moving refs from host code into
Wasm (e.g. returned from a host function or passed as arguments to a Wasm
function). After insertion into the table, this reference is no longer
rooted. If multiple references are being sent from the host into Wasm and we
allowed GCs during insertion, then the following events could happen:

* Reference A is inserted into the activations table. This does not trigger a
  GC, but does fill the table to capacity.

* The caller's reference to A is removed. Now the only reference to A is from
  the activations table.

* Reference B is inserted into the activations table. Because the table is at
  capacity, a GC is triggered.

* A is reclaimed because the only reference keeping it alive was the activation
  table's reference (it isn't inside any Wasm frames on the stack yet, so stack
  scanning and stack maps don't increment its reference count).

* We transfer control to Wasm, giving it A and B. Wasm uses A. That's a use
  after free.

To prevent uses after free, we cannot GC when moving refs into the
`VMExternRefActivationsTable` because we are passing them from the host to Wasm.

On the other hand, when we are *cloning* -- as opposed to moving -- refs from
the host to Wasm, then it is fine to GC while inserting into the activations
table, because the original referent that we are cloning from is still alive and
rooting the ref.
2021-09-14 14:23:42 -07:00
Alex Crichton
eb4089e212 Fix a typo 2021-09-14 14:09:14 -07: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
Nick Fitzgerald
ec4e48d4cb Stop doing fuzzy search for stack maps
The new backends will not emit a stack map for a safepoint if there are zero
live references. Our fuzzy search for stack maps, which was necessary for the
old backend, caused us to use the wrong stack map for some PCs which would in
turn cause us to treat arbitrary stack slots as reference types pointers.
2021-09-13 10:41:26 -07: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
bcb1dc90d6 Add an assertion that a HostFunc's store agrees on engines
This commit adds an assertion which was previously forgotten when
inserting a `HostFunc` into a `Store`. This can happen when a `Linker`
is defined with one engine but it's used to interoperate with a store
defined within a different engine.

A function contains type information that's only valid relative to the
engine that it was defined within. This means that if a function is used
within a different engine then type information may look valid when in
fact it is not. For example it's otherwise possible to insert a function
into an engine with one type and call it in a different engine with a
different type.

Similar to how `Store` misuse is a panic throughout `wasmtime`'s API
this commit also turns this behavior into panic, so there's no API
impact. Documentation has been updated accordingly to indicate that
various functions on `Linker` will panic if a `store` is provided that's
connected to a different `Engine`.
2021-09-08 14:42:02 -07: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