Commit Graph

1123 Commits

Author SHA1 Message Date
Pat Hickey
32f162aa78 fix windows flags 2021-01-12 09:51:09 -08:00
Pat Hickey
75a9dc7fe2 wasi-common: wiggle flags are now bitflags!
this mostly mechanical change is just getting rid of passing to
`contains` by reference.
2021-01-11 18:27:55 -08:00
Pat Hickey
ed44a19e5e wiggle: use bitflags to generate flags
more consistient with the rest of the ecosystem.
2021-01-11 18:20:57 -08:00
Pat Hickey
e2fb99af86 wiggle: depend on bitflags, and re-export it. 2021-01-11 18:04:43 -08:00
Pat Hickey
94467bcd9a wiggle: bugfix, generated code should use Names::runtime_mod not wiggle
as the crate from which these deps come.

I worked around this in lucet, but I'll be able to revert that
workaround.
2021-01-11 18:03:48 -08:00
Nick Fitzgerald
3068d55fa1 wasi-nn: Fix keyword form in Cargo.toml metadata
Keywords may not have spaces, apparently.
2021-01-11 10:46:00 -08:00
Andrew Brown
2adb0e8964 security: upgrade smallvec to 1.6.1
Fixes advisory https://rustsec.org/advisories/RUSTSEC-2021-0003.
2021-01-08 16:54:54 -08:00
Yury Delendik
3580205f12 [Cranelift][Atomics] Add address folding for atomic notify/wait. (#2556)
* fold address in wasm wait and notify ops

* add atomics addr folding tests
2021-01-08 11:55:21 -06:00
Nick Fitzgerald
5de5bf1565 Merge pull request #2550 from bytecodealliance/pch/wiggle_trapping
wiggle: introduce Trap enum
2021-01-07 16:23:21 -08:00
Pat Hickey
539058b329 fix windows 2021-01-07 14:57:18 -08:00
Nick Fitzgerald
5ad82de3c5 Bump Wasmtime to 0.22.0; Cranelift to 0.69.0 2021-01-07 14:51:12 -08:00
Pat Hickey
b149a03d5d wasi-common: instead of panicking, use an Error::Unsupported that Traps 2021-01-07 14:05:49 -08:00
Pat Hickey
07c9b65fa4 fix 2021-01-07 11:45:11 -08:00
Pat Hickey
ec1bfeefb3 fix tests 2021-01-07 11:45:11 -08:00
Pat Hickey
cd3adb1abd Trap::I32Exit is a better name 2021-01-07 11:45:11 -08:00
Pat Hickey
1dab7c8f94 wasi submodule: noreturn annotations are merged into main 2021-01-07 11:45:11 -08:00
Pat Hickey
2483ad4c1c wasi-nn: UserErrorConversion error is now a wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
745c592863 readme: expand wiggle docs 2021-01-07 11:45:11 -08:00
Pat Hickey
4a574c14eb wasi-common: port to use wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
1c7c18b026 WASI submodule: mark proc_exit funcs as noreturn in the witx 2021-01-07 11:45:11 -08:00
Pat Hickey
f8f9b14c6f wiggle: introduce wiggle::Trap, which can be either a String or I32
also, make noreturn functions always return a Trap

wasmtime-wiggle can trivially turn a wiggle::Trap into a wasmtime::Trap.
lucet will have to do the same.
2021-01-07 11:45:11 -08:00
Léo Gaspard
c0c4834c64 wasi-nn: rebuild if the witx files change 2021-01-06 15:56:46 -08:00
Pat Hickey
d4aaae3e86 wasi-nn: remove missing_memory from wasmtime_integration 2021-01-06 10:59:29 -08:00
Pat Hickey
bf2371c8af wasi: get rid of missing_memory config 2021-01-05 17:29:34 -08:00
Pat Hickey
46b1864c9e wiggle-wasmtime: get rid of "missing_memory" error code, we can Trap now
the missing memory behavior was always a silly thing, that we generate a
function for wasmtime which is Result<_, Trap> we can just Err(Trap)
when the memory export is missing.
2021-01-05 17:28:03 -08: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
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
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
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
Louis Pilfold
6bde8519c1 cargo deny config 2020-12-17 11:09:10 +00: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
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
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
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
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
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
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
Andrew Brown
2c765c18c2 Update spec tests 2020-12-07 10:59:55 -08:00
Andrew Brown
f1025322fa Update wasmparser to 0.69.2 2020-12-07 10:59:55 -08:00