Commit Graph

127 Commits

Author SHA1 Message Date
Patrick Ventuzelo
0e2f7600b2 bump wasmparser to 0.44.0 + fix error due to change wasmparser operator names 2019-12-10 11:57:21 +01:00
Patrick Ventuzelo
63b69a8e6c Merge remote-tracking branch 'upstream/master' into refactoring_error_handling_lightbeam 2019-12-10 11:24:46 +01:00
Alex Crichton
e13fabb276 Start to update the wasi crate in wasi tests (#675)
* Move `wasi` to `wasi_old` in wasi-tests

Leave space for the new `wasi` crate but allow us to incrementally
update tests.

* Update the big_random_buf test

* Update clock_time_get test

* Update close_preopen test

* Review comments

* Update to latest Wasmtime API
2019-12-09 13:08:47 +01:00
Jakub Konka
51f880f625 Add yanix crate and replace nix with yanix in wasi-common (#649)
* Add yanix crate

This commit adds `yanix` crate as a Unix dependency for `wasi-common`.
`yanix` stands for Yet Another Nix crate and is exactly what the name
suggests: a crate in the spirit of the `nix` crate, but which takes a different
approach, using lower-level interfaces with less abstraction, so that it fits
better with its main use case, implementation of WASI syscalls.

* Replace nix with yanix crate

Having introduced `yanix` crate as an in-house replacement for the
`nix` crate, this commit makes the necessary changes to `wasi-common`
to depend _only_ on `yanix` crate.

* Address review comments

* make `fd_dup` unsafe
* rename `get_fd` to `get_fd_flags`, etc.
* reuse `io::Error::last_os_error()` to get the last errno value

* Address more comments

* make all `fcntl` fns unsafe
* adjust `wasi-common` impl appropriately

* Make all fns operating on RawFd unsafe

* Fix linux build

* Address more comments
2019-12-08 16:40:05 -08:00
Andrew Brown
ec8144b87d Add support for SIMD NaN directives (#686)
* Add support for SIMD NaN directives

* Use is_*_nan helper methods for scalar NaN directives
2019-12-06 21:47:29 -06:00
Alex Crichton
e134505b90 Refactor the types.rs types and structures (#681)
* Refactor the `types.rs` types and structures

A few changes applied along the way:

* Documentation added to most methods and types.
* Limits are now stored with the maximum as optional rather than a
  sentinel u32 value for `None`.
* The `Name` type was removed in favor of just using a bare `String`.
* The `Extern` prefix in the varaints of `ExternType` has been removed
  since it was redundant.
* Accessors of `ExternType` variants no longer panic, and unwrapping
  versions were added with "unwrap" in the name.
* Fields and methods named `r#type` were renamed to `ty` to avoid
  requiring a raw identifier to use them.

* Remove `fail-fast: false`

This was left around since the development of GitHub Actions for
wasmtime, but they're no longer needed!

* Fix compilation of the test-programs code

* Fix compilation of wasmtime-py package

* Run rustfmt
2019-12-06 16:19:55 -06:00
Alex Crichton
3d69e04659 Tweak the API of the Val type (#679)
* Tweak the API of the `Val` type

A few updates to the API of the `Val` type:

* Added a payload for `V128`.
* Replace existing accessor methods with `Option`-returning versions.
* Add `unwrap_xxx` family of methods to extract a value and panic.
* Remove `Into` conversions which panic, since panicking in `From` or
  `Into` isn't idiomatic in Rust
* Add documentation to all methods/values/enums/etc.
* Rename `Val::default` to `Val::null`

* Run rustfmt

* Review comments
2019-12-06 16:19:37 -06:00
Austin Wise
1d01779b2e Root bindings so the delegate in FunctionBinding is not GCed. 2019-12-05 18:58:09 -08:00
Pat Hickey
7d415df209 Merge pull request #668 from pchickey/pch/wig_latest_witx
[wasi-common] wig: update to latest witx
2019-12-05 17:24:38 -05:00
Yury Delendik
cc6e8e1af2 Move cranelift dependencies to wasmtime-environ (#669)
Groups all CL data structures into single dependency to be used accross wasmtime project.
2019-12-05 16:07:34 -06:00
Dan Gohman
8a1b7965d8 Move command function invocation out of wasmtime-instance. (#585)
Previously, "_start" was run as part of module instantiation, which
meant it was always run, even for wasm modules that weren't being
loaded as commands. Now, just invoke it from the wasmtime driver,
which for now is the only place that runs wasm modules as actual
commands.

Also, stop recognizing the old "main" entry point, which tools have
stopped using a while ago, and switch to start recognizing the ""
entrypoint.
2019-12-05 14:03:17 -08:00
Pat Hickey
5793b14dd6 wig: update comments per code review 2019-12-05 13:54:39 -08:00
Peter Huene
b7c8408978 Merge pull request #676 from peterhuene/fix-dotnet-interop
Fix .NET interop issue for Windows release builds.
2019-12-05 13:32:46 -08:00
Peter Huene
cc02214084 Fix .NET interop issue for Windows release builds.
For Windows release builds, the `wasm_valtype_kind` C API return value
is being returned as a single byte.

The .NET interop signature for this function was expecting an
integer-sized return, resulting in three extra bytes being used on
Windows.

The fix is to limit the corresponding C# enum to a byte representation,
which will properly mask the return value from `wasm_valtype_kind`.

CI has also been updated to test both debug and release configurations
(previously it was only testing debug, hence why this was missed).

Also fixed a cast bug in the `declare_vec!` macro in the C API when the
element types were pointers to values.  The `as_slice` implementation
was incorrectly casting away a level of pointer indirection, resulting
in corrupted data when accessing the slice's elements.
2019-12-05 12:44:47 -08:00
Nick Fitzgerald
0fce2ac288 deps: Update wasmparser in most places (#670)
Doesn't update it in lightbeam.
2019-12-05 13:51:47 -06:00
Patrick Ventuzelo
e4d60d23ed fix one bug + refactor Option handling in some func 2019-12-05 19:50:41 +01:00
Patrick Ventuzelo
414d4bb4f5 add detail br_if error 2019-12-05 15:19:58 +01:00
Patrick Ventuzelo
e968b9313b improve format 2019-12-05 15:18:53 +01:00
Patrick Ventuzelo
2b24d17425 replace assert by if/error in function_body 2019-12-05 15:17:20 +01:00
Patrick Ventuzelo
b664428da7 cargo fmt 2019-12-05 15:16:32 +01:00
Patrick Ventuzelo
3d6b1876ac replace assert with if - Err 2019-12-05 14:53:21 +01:00
Patrick Ventuzelo
f212d9ce6a replace expect by Error for backend code 2019-12-05 13:47:59 +01:00
Patrick Ventuzelo
362469e5a9 remove unreachable! + cargo fmt 2019-12-05 13:24:33 +01:00
Patrick Ventuzelo
07c850051d fix all warning, cargo test OK 2019-12-05 13:16:02 +01:00
Patrick Ventuzelo
b8f33c3c94 remove expect from pop func and add return value other wasm opcode functions 2019-12-05 10:41:10 +01:00
Patrick Ventuzelo
dcc68dfafc use Result for a lot of lightbeam func, refactoring error handling 2019-12-05 10:22:36 +01:00
Pat Hickey
dbc4eebbfe wig: update to latest witx 2019-12-04 17:16:29 -08:00
Andrew Brown
3558d41cea Fix wast error line numbers; previously off by one (#666) 2019-12-04 17:46:05 -06:00
Jakub Konka
45f41b3c8e Deny warnings in the CI by default (#616)
* Deny warnings in the CI by default

This commit passes `-D warnings` flag to `rustc` in the Test stage
of the CI in order to deny warnings on _all_ tested platforms.

* Fix warnings

* Fix warnings
2019-12-04 17:43:36 +01:00
Yury Delendik
991592c4ba [wasmtime-api] Record original Trap from API callback. (#657)
* Record original Trap from API callback.

Fixes #645

* use TrapRegistry

* comment about magic number
2019-12-04 07:57:24 -06:00
Nick Fitzgerald
f8e26f14bf Merge pull request #660 from fitzgen/dummy-imports-for-fuzzing
fuzzing: Provide dummy imports for instantion oracle
2019-12-03 12:17:33 -08:00
Patrick Ventuzelo
027f6117d6 remove panic, expect and unimplemented from microwasm + use Result as return value for some functions (#652) 2019-12-03 11:58:29 -08:00
Nick Fitzgerald
5429a9391d fuzzing: Provide dummy imports for instantion oracle 2019-12-03 11:39:46 -08:00
XAMPPRocky
2109935fef Remove custom TryInto (#646) 2019-12-02 17:36:13 -08:00
Josh Triplett
4b001912ce Update rayon dependencies to avoid duplicate crossbeam dependencies (#651)
rayon 1.2.1 avoids introducing two different versions of crossbeam
crates into the dependency tree (one through rayon, the other through
rayon-core).
2019-12-02 17:32:00 -08:00
Jakub Konka
d733ebf3ab Fast-forward snapshot_0 to match wasi-common upstream
While we are waiting for the Rust toolchain to use the new ABI,
I thought it might be useful to sync `snapshot_0` with the latest
code in `wasi-common` "upstream". This mainly includes the latest
refactoring effort to unify the machinery for `fd_readdir` between
Linux, Windows and BSD.
2019-11-28 17:53:42 +01:00
Dan Gohman
1f9d764d5d Support fd_fdstat_get and fd_renumber on stdin/stdout/stderr (#631)
* Support fd_fdstat_get on stdin/stdout/stderr.

Add a routine for obtaining an `OsFile` containing a file descriptor for
stdin/stdout/stderr so that we can do fd_fdstat_get on them.

* Add a testcase for fd_fdstat_get etc. on stdin etc.

* Don't dup file descriptors in fd_renumber.

* Fix compilation on macOS

* Rename OsFile to OsHandle

This commits renames `OsFile` to `OsHandle` which seems to make
more sense semantically as it is permitted to hold a valid OS handle
to OS entities other than simply file/dir (e.g., socket, stream, etc.).
As such, this commit also renames methods on `Descriptor` struct
from `as_actual_file` to `as_file` as this in reality does pertain
ops on FS entities such as files/dirs, and `as_file` to `as_os_handle`
as in this case it can be anything, from file, through a socket, to
a stream.

* Fix compilation on Linux

* Introduce `OsHandleRef` for borrowing OS resources.

To prevent a `ManuallyDrop<OsHandleRef>` from outliving the resource it
holds on to, create an `OsHandleRef` class parameterized on the lifetime
of the `Descriptor`.

* Fix scoping to pub-priv and backport to snapshot_0
2019-11-28 14:36:18 +01:00
Marcin Mielniczuk
b69758f672 Correctly handle possibly misaligned pointers in readdir (#615) 2019-11-27 19:11:32 -08:00
Dan Gohman
16b8b3e58d Make Module::new perform validation. (#621)
* Make `Module::new` perform validation.

As noticed in #602, `Module::new` did not perform validation, which
turns out to be error-prone in practice. Rename it to
`Module::new_unchecked`, and add a new `Module::new` which does
perform validation.

Preserve wasm-c-api's `wasm_module_new`'s behavior by using
`Module::new_unchecked`, and implement `wasm_module_validate`.

* Change `validate`'s store argument to `&HostRef<Store>`.

* Enable multi-value in validation.
2019-11-27 10:58:38 -06:00
Yury Delendik
e71ab6b846 Fix build dependency for make run-hello-c (#622) 2019-11-27 10:56:31 -06:00
Nick Fitzgerald
f931243cee Remove allow pragma now that it is unnecessary 2019-11-26 15:58:34 -08:00
data-pup
0c4a44db70 pr review 2019-11-26 17:40:36 -05:00
data-pup
2011eab7b2 unit test doesn't run if placed in tests/regressions 2019-11-26 17:13:19 -05:00
data-pup
8a53e76c71 move regression test 2019-11-26 17:07:52 -05:00
data-pup
d3f3aa04d7 misc. cleanup 2019-11-26 17:02:15 -05:00
data-pup
4f47a4f607 only collect functions if defined memories exist 2019-11-26 17:02:15 -05:00
data-pup
bbea2855be wip - fix #636, check memory before calculating offset 2019-11-26 17:02:15 -05:00
Peter Huene
0cf54ffeba Implement __wasi_fd_fdstat_get for Windows.
This commit fully implements `__wasi_fd_fdstat_get` on Windows so that
the descriptor flags can be determined.

It does this by calling into `NtQueryInformationFile` (safe to call from
user mode) to get the open mode and access of the underlying OS handle.

`NtQueryInformationFile` isn't included in the `winapi` crate, so it is
manually being linked against.

This commit also fixes several bugs on Windows:

* Ignore `__WASI_FDFLAG_NONBLOCK` by not setting `FILE_FLAG_OVERLAPPED`
  on file handles (the POSIX behavior for `O_NONBLOCK` on files).
* Use `FILE_FLAG_WRITE_THROUGH` for the `__WASI_FDFLAG_?SYNC` flags.
* `__WASI_FDFLAG_APPEND` should disallow `FILE_WRITE_DATA` access to
  force append-only on write operations.
* Use `GENERIC_READ` and `GENERIC_WRITE` access flags.  The
  latter is required when opening a file for truncation.
2019-11-26 22:24:12 +01:00
Peter Huene
3e7bc745a2 Merge pull request #624 from peterhuene/wasmtime-for-dotnet
Move Wasmtime for .NET to the Wasmtime repo.
2019-11-26 12:47:04 -08:00
Nick Fitzgerald
4659f791ff Merge pull request #637 from fitzgen/print-test-cases-when-fuzzing
Fuzzing: Add test case logging and regression test template
2019-11-26 11:40:00 -08:00