Commit Graph

983 Commits

Author SHA1 Message Date
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
Pat Hickey
39f1c9716c restructure StringArrayWriter trait into StringArray struct 2020-09-02 14:11:32 -07:00
Pat Hickey
b63e974014 code review fixes 2020-09-02 13:39:32 -07:00
Pat Hickey
ddd50f7443 fix error report 2020-09-02 13:13:13 -07:00
Pat Hickey
7eb607b076 bugfix! 2020-09-02 10:55:27 -07:00
Pat Hickey
51d88f7899 wasi-common: move implementation of args, env methods into StringArrayWriter 2020-09-01 13:50:31 -07:00
Pat Hickey
6213a05c85 wiggle: add array indexing methods to GuestPtr<[T]> 2020-09-01 13:50:31 -07:00
Pat Hickey
87222d6db0 wasi-common: move GuestPtr deref out of path::get 2020-09-01 13:50:30 -07:00
Pat Hickey
20ccc11564 Merge pull request #2140 from bytecodealliance/pch/wasi_error_handling
wasi-common: refactor error types
2020-09-01 13:01:26 -07:00
Pat Hickey
c9ec60dcce Merge pull request #2169 from bytecodealliance/pch/fix_wasmtime_wiggle
wiggle-wasmtime: witx paths should be relative to CARGO_MANIFEST_DIR,…
2020-08-31 10:05:04 -07:00
MaxGraey
a8f7041296 new implementations for nearest lib calls
use approach with copysign for handling negative zero


format


refactor for better branch prediction


move copysign back to internal branch


format


fix


use abs instead branches


better comments


switch arms for better branch prediction
2020-08-31 09:39:20 -07:00
Pat Hickey
335886134c fix test 2020-08-28 17:11:11 -07:00
Pat Hickey
edefbf7c73 fix tests 2020-08-28 15:58:16 -07:00
Pat Hickey
22b427baa0 use WASI_ROOT env var to specify witx paths to wiggle macros 2020-08-28 15:42:51 -07:00
Pat Hickey
91dac9c7e8 wiggle: witx paths use shell expansion
instead of always being relative to CARGO_MANIFEST_DIR, each use site is
responsible for either putting that variable or another one (set by a
build.rs) at the start of witx paths.
2020-08-28 15:42:48 -07:00
Max de Danschutter
f1a5e55b98 Increase into-func to accept 16 arguments (#2170) 2020-08-28 10:39:48 -05:00
Pat Hickey
5c6ed0c736 wip - didnt have time to finish this before quittin time 2020-08-27 18:19:53 -07:00
Pat Hickey
4dabe3fad6 wasmtime-wasi: fix invocation of wasmtime_integration!
should use path relative to this crates's root
2020-08-27 16:12:20 -07:00
Pat Hickey
82d2a48896 wiggle-wasmtime: witx paths should be relative to CARGO_MANIFEST_DIR, not WASI_ROOT
the WASI_ROOT was leftover from when this code was part of `wig`.
2020-08-27 16:03:05 -07:00
Pat Hickey
393581b2ae Merge branch 'main' into pch/wasi_error_handling 2020-08-26 17:26:03 -07:00
Gabor Greif
2632848491 Relocation of DW_OP_{bra, skip} instructions (#2143)
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening DW_OP_deref will expand to about 10 bytes, for example.

So the jumps must be relocated. We approach this task by inserting artificial LandingPad markers (new CompiledExpressionParts constructors) into the parsed vector at actual Jump targets.

LandingPads are identified by JumpTargetMarker tokens which are generated on the fly.

Additionally we now parse the Jump instructions. These also get their corresponding JumpTargetMarker token.

We bail in two situations:

    frame_base is too complicated (i.e. itself contains Jump)
    some jump distance in the original expression is fishy.
2020-08-26 17:19:03 -05:00
Pat Hickey
7e750845cd Remove unnecessary check - fixed in std since Rust 1.38
issue now closed: https://github.com/rust-lang/rust/issues/63326
fix landed in a rollup: https://github.com/rust-lang/rust/pull/63380 merged aug 8, 2019
rust 1.38 beta cut on aug 15, 2019: https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html
minimum supported rust version for this repo is currently 1.41.
2020-08-25 17:27:47 -07:00
Pat Hickey
02aba548e1 Merge remote-tracking branch 'origin/main' into pch/wasi_error_handling 2020-08-25 15:22:51 -07:00