Commit Graph

7487 Commits

Author SHA1 Message Date
Alex Crichton
2b325a1878 Try to fix CI (#2544)
This is an attempt to work around rust-lang/rust#80703 to get CI green
again.
2021-01-04 14:50:42 -06:00
hayasshi
4c7e66e58e Fix code in WASI-tutorial.md 2021-01-04 07:06:10 -08:00
Louis Pilfold
40887c655f Upgrade shellexpand dep (#2529)
The previous version depended on the deprecated `dirs` crate.
2021-01-04 09:05:42 -06:00
Yury Delendik
2964023a77 [SIMD][x86_64] Add encoding for PMADDWD (#2530)
* [SIMD][x86_64] Add encoding for PMADDWD

* also for "experimental_x64"
2020-12-24 07:52:50 -06:00
Alex Crichton
ce6e967eeb Add a CLI option for module linking (#2524)
* Add a CLI option for module linking

Forgot to add this earlier!

* Always apt-get update before install
2020-12-18 14:12:02 -06:00
Pat Hickey
4bee07d6f9 Merge pull request #2520 from bytecodealliance/pch/prune_deps
Prune deps, comment deny.toml
2020-12-17 15:33:38 -08:00
Pat Hickey
8a09652d81 delete wasmparser exception from deny.toml 2020-12-17 14:53:04 -08:00
Pat Hickey
fb78025e41 upgrade all wasmparser to 0.71
new simd instructions are left as ubsupported in cranelift-wasm
2020-12-17 14:49:13 -08:00
Pat Hickey
8cf652a2a5 Update deny.toml
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-17 14:26:25 -08:00
David Haynes
02260b7cd0 2499: First pass on TableOps fuzzer generator wasm_encoder migration (#2501)
* 2499: First pass on TableOps fuzzer generator wasm_encoder migration

- wasm binary generated via sections and smushed together into a module
- test: compare generated wat against expected wat
- note: doesn't work
  - Grouped instructions not implemented
  - Vec<u8> to wat String not implemented

* 2499: Add typesection, abstract instruction puts, and update test

- TableOp.insert now will interact with a function object directly
- add types for generated function
- expected test string now reflects expected generated code

* 2499: Mark unused index as _i

* 2499: Function insertion is in proper stack order, and fix off by 1
      index

- imported functions must be typed
- instructions operate on a stack ie. define values as instructions
  before using

* 2499: Apply suggestions from code review

- typo fixing
- oracle ingests binary bytes itself

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* 2499: Code cleanup + renaming vars

- busywork, nothing to see here

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
2020-12-17 15:47:18 -06:00
Chris Fallin
8319244059 Merge pull request #2522 from cfallin/cranelift-native-with-variant
cranelift-native crate: add API variant allowing backend selection.
2020-12-17 13:41:02 -08:00
Chris Fallin
0833a92ddd cranelift-native crate: add API variant allowing backend selection. 2020-12-17 12:14:53 -08:00
Pat Hickey
059cabb4cd deny.toml: comments on why 2020-12-17 11:00:28 -08:00
Pat Hickey
4f5afe92dc wasmtime-debug: tune down features required from object
in order to eliminate a dep on an old wasmparser
2020-12-17 10:59:28 -08:00
Pat Hickey
fe1ff02a80 cargo update 2020-12-17 10:57:47 -08:00
Chris Fallin
0b6b3d0b7a Merge pull request #2517 from cfallin/fix-null-byte-symbols
cranelift-object: reject symbol names with NUL byte without panic'ing.
2020-12-17 10:33:48 -08:00
Pat Hickey
31b9eb03f1 Merge pull request #2519 from EmbarkStudios/cargo-deny
Lint deps tree with cargo deny
2020-12-17 10:33:05 -08:00
Chris Fallin
76fb9a08c7 cranelift-object: reject symbol names with NUL byte without panic'ing.
Avoid a `panic!()`, and return a proper error, on a NUL byte. We hit a
null-byte check inside the `object` crate otherwise; this blocks fuzzing
when testing via a write-object-file-and-dlopen flow.
2020-12-17 09:53:56 -08:00
Louis Pilfold
26b6074420 Download precompiled cargo deny 2020-12-17 13:55:48 +00:00
Louis Pilfold
b4283c514f cargo deny runs on CI 2020-12-17 11:42:41 +00:00
Louis Pilfold
6bde8519c1 cargo deny config 2020-12-17 11:09:10 +00:00
Johnnie Birch
f705a72aeb Refactor packed moves to use xmm_mov instead of xmm_rm_r
Refactors previous packed move implementation to use xmm_mov
instead of xmm_rm_r which looks to simplify register accounting
during lowering.
2020-12-16 17:13:27 -08:00
Johnnie Birch
51973aefbb Implements x64 SIMD loads for the new backend. 2020-12-16 17:13:27 -08:00
Pat Hickey
e33326f4e0 Merge pull request #2516 from goodbyekansas/stdio-filestat-get
Add filestat_get for stdout, stdin and stderr
2020-12-16 11:02:45 -08:00
Chris Fallin
e91987c43c Allow both x86 backends to be included, selected with a "variant" flag. (#2514)
This PR adds a new `isa::lookup_variant()` that takes a `BackendVariant`
(`Legacy`, `MachInst` or `Any`), and exposes both x86 backends as
separate variants if both are compiled into the build.

This will allow some new use-cases that require both backends in the
same process: for example, differential fuzzing between old and new
backends, or perhaps allowing for dynamic feature-flag selection between
the backends.
2020-12-16 09:56:04 -06:00
Sakarias Johansson
22ad43b430 Add filestat_get for stdout, stdin and stderr
This makes fstat work for stdout, stdin and stderr as expected.
This seemed like the only reasonable functions to implement from the
filestat_* set, for stdout, stdin and stderr.

Fixes #2515
2020-12-16 14:33:42 +01:00
Nick Fitzgerald
245abc2bb2 Merge pull request #2512 from fitzgen/bench-api-tweaks
bench-api: Clean up the benchmarking API
2020-12-15 12:18:34 -08:00
Nick Fitzgerald
cc81570a05 bench-api: Clean up the benchmarking API
Mostly just tweaks to docs/naming/readability/tidying up.

The biggest thing is that the wasm bytes are passed in during compilation now,
rather than on initialization, which lets us remove the lifetime from our state
struct and makes wrangling unsafe conversions that much easier.
2020-12-15 11:21:51 -08:00
Nick Fitzgerald
48b401c6f5 Merge pull request #2437 from abrown/bench-api
Introduce benchmarking API
2020-12-15 09:42:48 -08:00
Ulrich Weigand
fe10cc9d52 Fix jitdump header magic field on big-endian platforms (#2511)
The jitdump header contains a "magic" field that is defined to hold
the value 0x4A695444 as u32 in native endianness.  (This allows
consumers of the file to detect the endianness of the platform
where the file was written, and apply it when reading other fields.)

However, current code always writes 0x4A695444 in little-endian
byte order, even on big-endian system.  This makes consumers fail
when attempting to read files written on big-endian platforms.

Fixed by always writing the magic in native endianness.
2020-12-15 08:44:43 -06:00
whitequark
fc4eeae896 Alias yanix::file::OFlags::RSYNC to SYNC on Android.
Android defines O_RSYNC to be the same as O_SYNC:

35bb46188c/libc/include/fcntl.h (L57)
2020-12-14 22:03:43 -08:00
whitequark
1ec1834d6e Treat Android like Linux in wasi_common::sys::unix.
Just like it happens in `yanix::sys`.
2020-12-14 22:03:43 -08:00
whitequark
476ee59774 Define local seekdir and telldir prototypes on Android.
These functions are not yet defined in the `libc` crate.
See https://github.com/rust-lang/libc/pull/1996.
2020-12-14 22:03:43 -08:00
whitequark
919600d10b Stub out the utimesat emulation logic on Android.
Android always has `utimensat` available, so it is not necessary (or
possible, for that matter) to emulate it. Mark the fallback path as
`unreachable!()`.
2020-12-14 22:03:43 -08:00
Chris Fallin
743529b4eb Merge pull request #2492 from uweigand/endian-memory-v5
Support explicit endianness in Cranelift IR MemFlags
2020-12-14 13:59:08 -08:00
Alex Crichton
2d7c2fba5f Update wasm-smith (#2509)
Brings in a few bug fixes for generating module-linking modules
2020-12-14 13:39:38 -06:00
Ulrich Weigand
467a1af83a Support explicit endianness in Cranelift IR MemFlags
WebAssembly memory operations are by definition little-endian even on
big-endian target platforms.  However, other memory accesses will require
native target endianness (e.g. to access parts of the VMContext that is
also accessed by VM native code).  This means on big-endian targets,
the code generator will have to handle both little- and big-endian
memory accesses.  However, there is currently no way to encode that
distinction into the Cranelift IR that describes memory accesses.

This patch provides such a way by adding an (optional) explicit
endianness marker to an instance of MemFlags.  Since each Cranelift IR
instruction that describes memory accesses already has an instance of
MemFlags attached, this can now be used to provide endianness
information.

Note that by default, memory accesses will continue to use the native
target ISA endianness.  To override this to specify an explicit
endianness, a MemFlags value that was built using the set_endianness
routine must be used.  This patch does so for accesses that implement
WebAssembly memory operations.

This patch addresses issue #2124.
2020-12-14 20:15:37 +01:00
Nick Fitzgerald
ed971fcfcc Merge pull request #2505 from alexcrichton/fix-reserve-bug
Fix a memory reservation bug in `reserve_modules`
2020-12-14 10:12:46 -08:00
Nick Fitzgerald
59d435bef4 Merge pull request #2506 from alexcrichton/fix-expect-valid
Fix fuzzer expectation about valid modules
2020-12-14 09:53:01 -08:00
Alex Crichton
42adeba65d Fix fuzzer expectation about valid modules
Recent changes to fuzzers made expectations more strict about handling
errors while fuzzing, but this erroneously changed a module compilation
step to always assume that the input wasm is valid. Instead a flag is
now passed through indicating whether the wasm blob is known valid or
invalid, and only if compilation fails and it's known valid do we panic.
2020-12-14 08:31:46 -08:00
Alex Crichton
c83dee07b7 Fix a memory reservation bug in reserve_modules
This method attempted to reserve space in the `results` list of final
modules. Unfortunately `results.reserve(nmodules)` isn't enough here
because this can be called many times before a module is actually
finished and pushed onto the vector. The attempted logic to work around
this was buggy, however, and would simply trigger geometric growth on
every single reservation because it erroneously assumed that a
reservation would be exactly met.

This is fixed by avoiding looking at the vector's capacity and instead
keeping track of modules-to-be in a side field. This is the incremented
and passed to `reserve` as it represents the number of modules that will
eventually make their way into the result vector.
2020-12-14 07:57:47 -08:00
bjorn3
8f7f8ee0b4 Fix iconst.i8 0 miscompilation 2020-12-12 09:44:05 +01:00
Dan Gohman
1d90c329b4 Remove an unused variable. 2020-12-11 10:52:54 -08:00
Dan Gohman
88a073eac3 rustfmt 2020-12-11 10:52:54 -08:00
Dan Gohman
c3f0471ff2 Fix the return value from wasi-common's fd_readdir.
`fd_readdir` returns a "bufused" value, which indicates the number of
bytes read into the buffer. WASI libc expects this value to be equal
to the size of the buffer if the end of the directory has not yet
been scanned.

Previously, wasi-common's `fd_readdir` was writing as many complete
entries as it could fit and then stopping, but this meant it was
returning size less than the buffer size even when the directory had
more entries. This patch makes it continue writing up until the end
of the buffer, and return that number of bytes, to let WASI libc
know that there's more to be read.

Fixes #2493.
2020-12-11 10:52:54 -08:00
Nick Fitzgerald
9ccef597c2 Merge pull request #2497 from alexcrichton/fuzz-module-linking
Enable fuzzing the module linking implementation
2020-12-11 09:46:03 -08:00
Alex Crichton
25000afe69 Enable fuzzing the module linking implementation
This commit updates all the wasm-tools crates that we use and enables
fuzzing of the module linking proposal in our various fuzz targets. This
also refactors some of the dummy value generation logic to not be
fallible and to always succeed, the thinking being that we don't want to
accidentally hide errors while fuzzing. Additionally instantiation is
only allowed to fail with a `Trap`, other failure reasons are unwrapped.
2020-12-11 08:36:52 -08:00
Andrew Brown
41d668b4da Introduce benchmarking API
The new crate introduced here, `wasmtime-bench-api`, creates a shared library, e.g. `wasmtime_bench_api.so`, for executing Wasm benchmarks using Wasmtime. It allows us to measure several phases separately by exposing `engine_compile_module`, `engine_instantiate_module`, and `engine_execute_module`, which pass around an opaque pointer to the internally initialized state. This state is initialized and freed by `engine_create` and `engine_free`, respectively. The API also introduces a way of passing in functions to satisfy the `"bench" "start"` and `"bench" "end"` symbols that we expect Wasm benchmarks to import. The API is exposed in a C-compatible way so that we can dynamically load it (carefully) in our benchmark runner.
2020-12-10 15:02:10 -08:00
Alex Crichton
e09b9400f8 Restrict threads spawned during fuzzing (#2485)
I was having limited success fuzzing locally because apparently the
fuzzer was spawning too many threads. Looking into it that indeed
appears to be the case! The threads which time out runtime of wasm only
exit after the sleep has completely finished, meaning that if we execute
a ton of wasm that exits quickly each run will generate a sleeping thread.

This commit fixes the issue by using some synchronization to ensure the
sleeping thread exits when our fuzzed run also exits.
2020-12-09 10:34:37 -06:00
Chris Fallin
267d4a8bdb Merge pull request #2490 from cfallin/fix-popcnt-load-width
x64 lowering fix: i32.popcnt should not merge load and make it 64-bit.
2020-12-08 22:28:41 -08:00