Commit Graph

1005 Commits

Author SHA1 Message Date
Alex Crichton
b73b831892 Replace binaryen -ttf based fuzzing with wasm-smith (#2336)
This commit removes the binaryen support for fuzzing from wasmtime,
instead switching over to `wasm-smith`. In general it's great to have
what fuzzing we can, but our binaryen support suffers from a few issues:

* The Rust crate, binaryen-sys, seems largely unmaintained at this
  point. While we could likely take ownership and/or send PRs to update
  the crate it seems like the maintenance is largely on us at this point.

* Currently the binaryen-sys crate doesn't support fuzzing anything
  beyond MVP wasm, but we're interested at least in features like bulk
  memory and reference types. Additionally we'll also be interested in
  features like module-linking. New features would require either
  implementation work in binaryen or the binaryen-sys crate to support.

* We have 4-5 fuzz-bugs right now related to timeouts simply in
  generating a module for wasmtime to fuzz. One investigation along
  these lines in the past revealed a bug in binaryen itself, and in any
  case these bugs would otherwise need to get investigated, reported,
  and possibly fixed ourselves in upstream binaryen.

Overall I'm not sure at this point if maintaining binaryen fuzzing is
worth it with the advent of `wasm-smith` which has similar goals for
wasm module generation, but is much more readily maintainable on our
end.

Additonally in this commit I've added a fuzzer for wasm-smith's
`SwarmConfig`-based fuzzer which should expand the coverage of tested
modules.

Closes #2163
2020-10-29 10:02:59 -05:00
Alex Crichton
61f0b8fc56 Remove Windows-specific code for static memory bounds
Added in c4e10227de I think the original
reason (which I'm not entirely knowledgeable of) may no longer be
applicable? In any case this is a significant difference on Windows from
other platforms because it makes loads/stores of wasm code have manual
checks instead of relying on the guard page, causing runtime and
compile-time slowdowns on Windows-only.

I originally rediscovered this when investigating #2318 and saw that
both the compile time of the module in question and trap information
tables were much larger than they were on Linux. Removing this
Windows-specific configuration fixed the discrepancies and afterwards
Linux and Windows were basically the same.
2020-10-28 16:49:53 -07:00
Alex Crichton
3461ffa563 Remove source_loc from TrapInformation (#2325)
Turns out this wasn't needed anywhere! Additionally we can construct it
from `InstructionAddressMap` anyway. There's so many pieces of trap
information that it's best to keep these structures small as well.
2020-10-28 13:05:05 -05:00
Leonardo Yvens
bde9555793 Add Trap::trap_code (#2309)
* add Trap::trap_code

* Add non-exhaustive wasmtime::TrapCode

* wasmtime: Better document TrapCode

* move and refactor test
2020-10-27 16:30:45 -05:00
Alex Crichton
f6d5b8772c Compress in-memory representation of FunctionAddressMap (#2321)
This commit compresses `FunctionAddressMap` by performing a simple
coalescing of adjacent `InstructionAddressMap` descriptors if they
describe the same source location. This is intended to handle the common
case where a sequene of machine instructions describes a high-level wasm
instruction.

For the module on #2318 this reduces the cache entry size from 306MB to
161MB.
2020-10-26 13:22:25 -05:00
Alex Crichton
27233857c5 Encode modules with variable-length integers (#2322)
Update `Module::{serialize,deserialize}` to use variable-length integers
with `bincode` to make the output artifacts smaller. Locally this
reduces the size of #2318 from 160 to 110 MB, a 30% decrease in size!
Deserialization performance is slightly slower, but seemingly within the
range of noise locally for me.
2020-10-26 09:52:29 -05:00
Andrew Brown
6ebbab61b9 Update cfg-if dependency 2020-10-23 16:50:51 -07:00
Nick Fitzgerald
c5a2bd3215 Merge pull request #2298 from EmbarkStudios/directories-next2
Replace unmaintained directories crate - RUSTSEC-2020-0054
2020-10-21 15:16:57 -07:00
Nick Fitzgerald
1532834f3e Merge pull request #2305 from alexcrichton/no-arc
Don't store `Arc<VMInterrupts>` in instances
2020-10-21 13:21:51 -07:00
Alex Crichton
461ed42772 Remove the finished_functions field in Instance
Turns out we don't actually need it anywhere any more! This removes an
allocation when instantiating.
2020-10-21 11:43:11 -07:00
Alex Crichton
04e85b044e Don't store Arc<VMInterrupts> in instances
Similar to other data structures owned by the `Store` there's no need
for `Instance` to have a strong `Arc` reference, instead it's sufficient
for `Store` to have the owning reference.
2020-10-21 11:42:57 -07:00
Nick Fitzgerald
76998f0404 Merge pull request #2300 from alexcrichton/no-allocate-isa
Don't allocate a new ISA for each `Func::wrap`
2020-10-18 13:36:29 -07:00
Alex Crichton
b8794448b0 Avoid allocations in trampoline shims
There's no need to name each export since each synthetic instance we're
creating only has one export, so let's use the empty string which
doesn't require any allocations.
2020-10-18 11:54:52 -07:00
Johan Andersson
9820c5c3dd Replace unmaintained directories crate
Fixes RUSTSEC-2020-0054 warning from cargo-audit/cargo-deny, follows the recommendation to switch to the new maintained `directories-next` crate fork

Only affects the cache directory determination for the environment and was a simple search'n'replace to this fork so don't think behavior has changed.

https://rustsec.org/advisories/RUSTSEC-2020-0054
2020-10-17 13:08:59 +02:00
Alex Crichton
4a82f17d91 Don't allocate a new ISA for each Func::wrap
Instead we can reuse the existing one in `Store`.
2020-10-16 08:21:32 -07:00
Andrew Brown
f36ceac010 Fix typo 2020-10-15 11:31:04 -07:00
Alex Crichton
e659d5cecd Add initial support for the multi-memory proposal (#2263)
This commit adds initial (gated) support for the multi-memory wasm
proposal. This was actually quite easy since almost all of wasmtime
already expected multi-memory to be implemented one day. The only real
substantive change is the `memory.copy` intrinsic changes, which now
accounts for the source/destination memories possibly being different.
2020-10-13 19:13:52 -05:00
Alex Crichton
cdf158cd50 Fix enabling interrupts in fuzzers
Modifying the `Config` after the gneine has been created has no effect,
so be sure to flag the configuration as interruptible earlier.
2020-10-09 10:09:27 -07:00
Gabor Greif
387afc805e debug: Normalise value prior to right shifts (#2276)
* normalise value prior to right shifts

by first left-aligning (shift left by 32 bits)
then shifting back (respecting signedness)

* Update crates/debug/src/transform/expression.rs

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>

* Update crates/debug/src/transform/expression.rs

* Update crates/debug/src/transform/expression.rs

* update translation of DW_OP_shr in test

* add translation test for DW_OP_shra

* explain normalisation

* optimise the expression by performing only one right shift

We assume that the expression evaluator permits collapsing
two shifts as long as they go in the same direction.

Review feedback.

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-10-07 12:42:20 -05:00
subtly
d91f0c3933 get pc for freebsd (#2270)
* get pc for freebsd

* whitespace :|

* fix; i386 to x86

* remove x86 since uc_mcontext isn't yet in libc

* freebsd build of rust uses libcc/unwind
2020-10-07 06:30:14 -05:00
Alex Crichton
9e87e45745 Update wasmparser, wast, and spec test suite (#2264)
This brings in a number of SIMD opcode renames, various other test suite
updates, as well as some new proposed SIMD opcodes too.
2020-10-05 13:51:16 -05:00
zhiqiangxu
1d1de35ad1 optimize register_jit_code (#2262) 2020-10-05 13:14:44 -05:00
Alex Crichton
2c6841041d Validate modules while translating (#2059)
* Validate modules while translating

This commit is a change to cranelift-wasm to validate each function body
as it is translated. Additionally top-level module translation functions
will perform module validation. This commit builds on changes in
wasmparser to perform module validation interwtwined with parsing and
translation. This will be necessary for future wasm features such as
module linking where the type behind a function index, for example, can
be far away in another module. Additionally this also brings a nice
benefit where parsing the binary only happens once (instead of having an
up-front serial validation step) and validation can happen in parallel
for each function.

Most of the changes in this commit are plumbing to make sure everything
lines up right. The major functional change here is that module
compilation should be faster by validating in parallel (or skipping
function validation entirely in the case of a cache hit). Otherwise from
a user-facing perspective nothing should be that different.

This commit does mean that cranelift's translation now inherently
validates the input wasm module. This means that the Spidermonkey
integration of cranelift-wasm will also be validating the function as
it's being translated with cranelift. The associated PR for wasmparser
(bytecodealliance/wasmparser#62) provides the necessary tools to create
a `FuncValidator` for Gecko, but this is something I'll want careful
review for before landing!

* Read function operators until EOF

This way we can let the validator take care of any issues with
mismatched `end` instructions and/or trailing operators/bytes.
2020-10-05 11:02:01 -05:00
Joshua Warner
eb650f6fe0 filesystem example (#2236) 2020-09-29 13:20:14 -05:00
zhiqiangxu
a8a6e4e69d optimize get_wasmtime_signature (#2243) 2020-09-28 23:49:46 -05:00
zhiqiangxu
0de5f7cf5c rm useless code (#2229) 2020-09-26 00:49:56 -05:00
Pat Hickey
b10beeee01 dep gardening (#2233)
* wasmtime-profiling: latest object dep is 0.21.1

* latest gimli is 0.22

* bump cargo.lock
2020-09-26 00:49:28 -05:00
Joshua Warner
d947010181 Don't implicitly create empty files in VirtualDir::openat (#2235)
* Don't implicitly create empty files in VirtualDir::openat

* Add test

* Add note on how to run test-program tests to the README
2020-09-25 19:52:13 -07:00
Alex Crichton
5e08eb3b83 Bump wasmtime to 0.20.0 (#2222)
At the same time bump cranelift crates to 0.67.0
2020-09-23 13:54:02 -05:00
Benjamin Bouvier
04cf94cea3 runtime: fix nearest for NaN inputs;
According to wasm's spec, nearest must do the following, for NaN inputs:
- when the input is a canonical NaN, return a canonical NaN;
- when the input is a non-canonical NaN, return an arithmetic NaN.

This patch adds checks when the exponent is all ones if the input was a
NaN, and will set the significand's most significant bit in that case.
It works both for canonical inputs (which already had the bit set) and
makes other NaN inputs canonical.
2020-09-23 16:42:03 +02:00
Andrew Brown
31165d0e9b Print more information about types that cannot be generated by wiggle 2020-09-21 10:26:26 -07:00
Andrew Brown
97e0f4864c Fix typo 2020-09-21 10:26:26 -07:00
Pat Hickey
7bfc4597a0 Merge pull request #2201 from bytecodealliance/pch/wasi_common_move_type_imports
wasi-common: code motion around type imports
2020-09-16 14:48:25 -07:00
Joshua Nelson
d28abad441 Upgrade to target-lexicon 0.11
This allows downstream library users to use `CDataModel` without having
to install two different versions of target-lexicon.
2020-09-15 11:40:09 -07:00
Pat Hickey
b72d5de86c virtfs: import types from handle, drop types:: prefix 2020-09-14 16:42:20 -07:00
Pat Hickey
4763678be2 sys: import types from handle or sched, not wasi. drop types:: prefix. 2020-09-14 16:42:20 -07:00
Pat Hickey
e5129b39cb path: import types from handle rather than wasi 2020-09-14 16:42:20 -07:00
Pat Hickey
e47927f0fd fs: only import wasi Fd type in one place 2020-09-14 16:42:20 -07:00
Pat Hickey
83c1fa1b8b entry: import types from handle 2020-09-14 16:42:20 -07:00
Pat Hickey
5639881519 ctx: import Fd without any types:: prefix 2020-09-14 16:42:20 -07:00
Pat Hickey
66ba582bba sched: re-export the wasi types used for times and events 2020-09-14 16:42:20 -07:00
Pat Hickey
6db24fd08f handle: re-export all of the wasi types used by handles 2020-09-14 16:42:20 -07:00
Nick Fitzgerald
89f1e02f1f Remove executable bits from a few Rust source files 2020-09-14 16:27:47 -07:00
Alex Crichton
b189321d61 Actually add instantiate-maybe-invalid fuzz target (#2190)
Forgot to add it to the manifest so it didn't actually get built!
2020-09-09 12:09:04 -05:00
Nick Fitzgerald
3a602994e6 Merge pull request #2185 from alexcrichton/fuzz-maybe-invalid
Expand modules instantiated in instantiate-wasm-smith
2020-09-08 17:05:46 -07:00
Alex Crichton
38428e1fbb Expand modules instantiated in instantiate-wasm-smith
This commit uses the new `MaybeInvalidModule` type in `wasm-smith` to
try to explore more points in the fuzz target space in the
`instantiate-maybe-invalid` fuzz target. The goal here is to use the raw
fuzz input as the body of a function to stress the validator/decoder a
bit more, and try to get inputs we might not otherwise generate.
2020-09-08 14:29:27 -07:00
bjorn3
ba9908dd0f Don't substract 1 from end_addr in line program writing (#2174)
* Don't substract 1 from end_addr in line program writing

Fixes #2173

* add testcase for end_sequence having offset past retq (#1)

* Update tests/all/debug/translate.rs

Co-authored-by: Gabor Greif <ggreif@gmail.com>

Co-authored-by: Gabor Greif <ggreif@gmail.com>
2020-09-07 08:41:44 -05:00
Pat Hickey
776f12ae3c tests: exercise array getters 2020-09-03 16:41:10 -07:00
Pat Hickey
580c236dee wiggle: implement array get/get_range in terms of ptr/add/as_array
hard to get it wrong when you use the safe primitives i already made!
2020-09-03 16:40:45 -07:00
Pat Hickey
1d410d6559 move more constructor stuff into stringarray 2020-09-02 17:16:39 -07:00