Commit Graph

6699 Commits

Author SHA1 Message Date
Yury Delendik
a817470fab Fix signature of wasmtime_module_new 2020-07-15 14:07:36 -05:00
Andrew Brown
6a01b32474 Enable final SIMD spec tests for x86 2020-07-15 11:32:08 -07:00
Andrew Brown
3576d8c5bb Translate Wasm's widen instructions to Cranelift's [u|s]widen_[low|high] 2020-07-15 11:32:08 -07:00
Andrew Brown
f0b083c6ad Legalize [u|s]widen_high for x86
Use `x86_palignr` and `[u|s]widen_low` for legalizing this instruction.
2020-07-15 11:32:08 -07:00
Andrew Brown
c8ddf8a34c Encode [u|s]widen_low for x86 2020-07-15 11:32:08 -07:00
Andrew Brown
fafef7db77 Add x86_palignr instructions
This instruction is necessary for implementing `[s|u]widen_high`.
2020-07-15 11:32:08 -07:00
Andrew Brown
0e5e8a62c8 Add DerivedFunction for doubling lane widths and halving the number of lanes (i.e. merging)
Certain operations (e.g. widening) will have operands with types like `NxM` but will return results with types like `(N*2)x(M/2)` (double the lane width, halve the number of lanes; maintain the same number of vector bits). This is equivalent to applying two `DerivedFunction`s to the type: `DerivedFunction::DoubleWidth` then `DerivedFunction::HalfVector`. Since there is no easy way to apply multiple `DerivedFunction`s (e.g. most of the logic is one-level deep, 1d5a678124/cranelift/codegen/meta/src/gen_inst.rs (L618-L621)), I added `DerivedFunction::MergeLanes` to do the necessary type conversion.
2020-07-15 11:32:08 -07:00
Chris Fallin
12a31c88d7 Merge pull request #2021 from akirilov-arm/VectorSize
AArch64: Introduce an enum to specify vector instruction operand sizes
2020-07-15 09:43:18 -07:00
Alex Crichton
806d197472 Update platform support docs (#2023)
Be sure to mention Linux AArch64 as a supported platform of Wasmtime
now.
2020-07-15 10:22:08 -05:00
Benjamin Bouvier
abf157bd69 machinst x64: Only use the feature flag to enable the x64 new backend;
Before this patch, running the x64 new backend would require both
compiling with --features experimental_x64 and running with
`use_new_backend`.

This patches changes this behavior so that the runtime flag is not
needed anymore: using the feature flag will enforce usage of the new
backend everywhere, making using and testing it much simpler:

    cargo run --features experimental_x64 ;; other CLI options/flags

This also gives a hint at what the meta language generation would look
like after switching to the new backend.

Compiling only with the x64 codegen flag gives a nice compile time speedup.
2020-07-15 13:11:28 +02:00
Anton Kirilov
95b0b05af2 AArch64: Introduce an enum to specify vector instruction operand sizes
Copyright (c) 2020, Arm Limited.
2020-07-14 21:37:44 +01:00
Chris Fallin
bc1e960b9e Merge pull request #2019 from akirilov-arm/show_freg_sized
AArch64: Remove show_freg_sized()
2020-07-14 12:39:51 -07:00
Anton Kirilov
400639245c AArch64: Remove show_freg_sized()
It provides the same functionality as show_vreg_scalar().

Copyright (c) 2020, Arm Limited.
2020-07-14 11:27:46 -07:00
Chris Fallin
4ba3ee3368 Merge pull request #2016 from jgouly/saturating-math
arm64: Implement saturating SIMD arithmetic
2020-07-14 11:24:10 -07:00
Chris Fallin
fad2affad0 Merge pull request #1852 from cfallin/reftypes
Reference type support in MachInst backend and on AArch64
2020-07-14 11:22:31 -07:00
Chris Fallin
1d09c8e46b Merge pull request #1939 from bjorn3/128bit_switch
Fix Switch for 128bit integers
2020-07-14 11:16:33 -07:00
Joey Gouly
aa84a4173c arm64: Implement saturating SIMD arithmetic
Copyright (c) 2020, Arm Limited.
2020-07-14 18:19:11 +01:00
Chris Fallin
26529006e0 Address review comments. 2020-07-14 10:17:29 -07:00
Chris Fallin
08353fcc14 Reftypes part two: add support for stackmaps.
This commit adds support for generating stackmaps at safepoints to the
new backend framework and to the AArch64 backend in particular. It has
been tested to work with SpiderMonkey.
2020-07-14 10:17:27 -07:00
Chris Fallin
b93e8c296d Initial reftype support in aarch64, modulo safepoints.
This commit adds the inital support to allow reftypes to flow through
the program when targetting aarch64. It also adds a fix to the
`ModuleTranslationState` needed to send R32/R64 types over from the
SpiderMonkey embedding.

This commit does not include any support for safepoints in aarch64
or the `MachInst` infrastructure; that is in the next commit.

This commit also makes a drive-by improvement to `Bint`, avoiding an
unneeded zero-extension op when the extended value comes directly from a
conditional-set (which produces a full-width 0 or 1).
2020-07-14 10:14:18 -07:00
bjorn3
88a84e90ef Fix Switch for 128bit integers 2020-07-14 18:07:52 +02:00
Chris Fallin
4edd165d25 Merge pull request #1992 from akirilov-arm/InstSize
Refactor the InstSize enum in the AArch64 backend
2020-07-14 08:58:49 -07:00
Anton Kirilov
79dfac5514 Refactor the InstSize enum in the AArch64 backend
The main issue with the InstSize enum was that it was used both for
GPR and SIMD & FP operands, even though machine instructions do not
mix them in general (as in a destination register is either a GPR
or not). As a result it had methods such as sf_bit() that made
sense only for one type of operand.

Another issue was that the enum name was not reflecting its purpose
accurately - it was meant to represent an instruction operand size,
not an instruction size, which is fixed in A64 (always 4 bytes).

Now the enum is split into one for GPR operands and another for
scalar SIMD & FP operands.

Copyright (c) 2020, Arm Limited.
2020-07-14 15:04:35 +01:00
Alex Crichton
85ffc8f595 Switch CI back to nightly channel (#2014)
* Switch CI back to nightly channel

I think all upstream issues are now fixed so we should be good to switch
back to nightly from our previously pinned version.

* Fix doc warnings
2020-07-13 18:40:47 -05:00
Alex Crichton
1000f21338 Update wasmparser to 0.59.0 (#2013)
This commit is intended to update wasmparser to 0.59.0. This primarily
includes bytecodealliance/wasm-tools#40 which is a large update to how
parsing and validation works. The impact on Wasmtime is pretty small at
this time, but over time I'd like to refactor the internals here to lean
more heavily on that upstream wasmparser refactoring.

For now, though, the intention is to get on the train of wasmparser's
latest `main` branch to ensure we get bug fixes and such.

As part of this update a few other crates and such were updated. This is
primarily to handle the new encoding of `ref.is_null` where the type is
not part of the instruction encoding any more.
2020-07-13 16:22:41 -05:00
Nick Fitzgerald
9bafb173a0 Merge pull request #1996 from fitzgen/ref-types-in-c-api
Support reference types in the C API
2020-07-13 10:58:42 -07:00
Nick Fitzgerald
3638dba855 examples: Run the correct example executable on Windows
We were accidentally always running the `fib-debug/main` example because of
shenanigans with alphabetical ordering and hard coding "main.exe" as the command
we run. Now we properly detect which example we built and run the appropriate
executable.
2020-07-13 09:34:20 -07:00
Chris Fallin
4b6ebc0c27 Merge pull request #1999 from bnjbvr/fix-aarch64-ishl-by-zero
machinst aarch64: fix encoding generation of left-shift by 0
2020-07-13 09:25:21 -07:00
Chris Fallin
f4f5eed254 Merge pull request #1977 from jgouly/simd_shift
arm64: Implement SIMD shift instructions
2020-07-13 09:24:19 -07:00
Nick Fitzgerald
9f0ec620f0 wasmtime-c-api: Remove duplicate tests of examples
The canonical examples tests will be the examples run via `cargo run -p
run-examples` from now on. Those tests have two advantages over the ones being
deleted:

1. They will automatically pick up new examples and run/test them.
2. They support all of Linux, MacOS, and Windows, while the tests being deleted
   are Linux only.
2020-07-13 08:42:55 -07:00
Peter Huene
f48f9eb4b3 Merge pull request #2010 from whitequark/fix-windows-creat_trunc
WASI: make O_CREAT|O_TRUNC actually truncate files on Windows
2020-07-11 17:11:22 -07:00
Peter Huene
41b4721512 Add a test case for WASI file truncation. 2020-07-10 14:28:08 -07:00
Yury Delendik
b2551bb4d0 Make wasmtime_environ::Module serializable (#2005)
* Define WasmType/WasmFuncType in the Cranelift
* Make `Module` serializable
2020-07-10 15:56:43 -05:00
Nick Fitzgerald
22d6b68795 gitignore: Ignore the foo file
It is created by the `run-examples` crate.
2020-07-10 13:53:05 -07:00
Nick Fitzgerald
ec331a088c run-examples: Provide more error context for debugging
Use `anyhow` for nice errors and provide error context on commands that we run.
2020-07-10 13:51:58 -07:00
Nick Fitzgerald
2040a654d6 CI: collect backtraces for example tests 2020-07-10 13:37:24 -07:00
Nick Fitzgerald
89603bc6b3 wasmtime-c-api: Make wasm_table_set *not* take ownership of its reference
Same for `wasm_table_grow` and `wasm_table_new` and their `init` values.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
d07fdca73a wasmtime-c-api: Use a safe helper for initializing MaybeUninit out pointers 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
377b213fd5 wasmtime-c-api: Remove unused HostInfoState struct 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
b73b2e0d5a wasmtime-c-api: Make wasmtime_externref_new write to an out pointer
The C API prefers not to return structs by value.

Same for `wasmtime_externref_new_with_finalizer`.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
b9bb095e0f wasmtime-c-api: Remove nested options from wasm_ref_t representation 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
742f8ee1fc wasmtime-c-api: Make wasmtime_externref_new proxy to wasmtime_externref_new_with_finalizer 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
4a349ee299 wasmtime: Add externref Rust example 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
5ed8a9ba0e wasmtime-c-api: Add an externrefs example for the C API 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
267bf16683 wasmtime-c-api: Add Wasmtime-specific APIs for externrefs
This commit adds APIs to create new `externref` values (with and without
finalizers) and to get an `externref`'s wrapped data.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
4c01ffd087 wasmtime-c-api: Document new reference types support 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
aaf4c941b8 wasmtime-c-api: Add support for funcref values 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
4cdf8b7cfd wasmtime-c-api: Add support for externref values
This required that `wasm_val_t` have a `Drop` implementation, an explicit
`Clone` implementation, and no longer be `Copy`, which rippled out through the
crate a bit.

Additionally, `wasm_func_call` and friends were creating references to
uninitialized data for its out pointers and assigning to them. As soon as
`wasm_val_t` gained a `Drop` impl and tried to drop the old value of the
assignment (which is uninitialized data), then things blew up. The fix is to
properly represent the out pointers with `MaybeUninit`, and use `ptr::write` to
initialize them without dropping the old data.

Part of #929
2020-07-10 13:09:08 -07:00
whitequark
92f33284b6 WASI: make O_CREAT|O_TRUNC actually truncate files on Windows
Fixes #2009.
2020-07-10 19:23:37 +00:00
Jakub Konka
c3d385e935 Add link to C API docs in the guide (#2006) 2020-07-10 09:29:52 -05:00