Commit Graph

6542 Commits

Author SHA1 Message Date
dependabot-preview[bot]
2eea366530 Update goblin requirement from 0.0.24 to 0.1.0
Updates the requirements on [goblin](https://github.com/m4b/goblin) to permit the latest version.
- [Release notes](https://github.com/m4b/goblin/releases)
- [Changelog](https://github.com/m4b/goblin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/m4b/goblin/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-05 10:48:37 +01:00
Josh Triplett
c0c7851cb6 Fix fuzz build (#458)
Update to binaryen 0.8.1, as 0.5.0 doesn't build on current systems.

Update to match API changes in wasmtime and wasmparser.
2019-11-04 20:45:42 -08:00
Josh Triplett
bd60aa8b5e wasmtime-wast: Fix copy-pasted doc comment (#453)
wasmtime-wast's main module had the same comment as wasmtime-jit's main
module; fix it to have its own doc comment.
2019-11-04 20:44:38 -08:00
Josh Triplett
56ce6e9c9f Migrate from failure to thiserror and anyhow (#436)
* Migrate from failure to thiserror and anyhow

The failure crate invents its own traits that don't use
std::error::Error (because failure predates certain features added to
Error); this prevents using ? on an error from failure in a function
using Error. The thiserror and anyhow crates integrate with the standard
Error trait instead.

This change does not attempt to semantically change or refactor the
approach to error-handling in any portion of the code, to ensure that
the change remains straightforward to review. Modules using specific
differentiated error types move from failure_derive and derive(Fail) to
thiserror and derive(Error). Modules boxing all errors opaquely move
from failure::Error to anyhow. Modules using String as an error type
continue to do so. Code using unwrap or expect continues to do so.

Drop Display implementations when thiserror can easily derive an
identical instance.

Drop manual traversal of iter_causes; anyhow's Debug instance prints the
chain of causes by default.

Use anyhow's type alias anyhow::Result<T> in place of
std::result::Result<T, anyhow::Error> whenever possible.

* wasm2obj: Simplify error handling using existing messages

handle_module in wasm2obj manually maps
cranelift_codegen::isa::LookupError values to strings, but LookupError
values already have strings that say almost exactly the same thing.
Rely on the strings from cranelift.

* wasmtime: Rely on question-mark-in-main

The main() wrapper around rmain() completely matches the behavior of
question-mark-in-main (print error to stderr and return 1), so switch to
question-mark-in-main.

* Update to walrus 0.13 and wasm-webidl-bindings 0.6

Both crates switched from failure to anyhow; updating lets us avoid a
translation from failure to anyhow within wasmtime-interface-types.
2019-11-04 20:43:25 -08:00
Josh Triplett
0108622c7d Remove incorrect executable bits (#454)
A few .rs files and a .wasm file have the executable bit set; unset it.
2019-11-04 20:42:16 -08:00
Dan Gohman
a9868de3d8 Bump version to 0.47.0 2019-11-04 15:43:27 -08:00
Jakub Konka
f4ac1299b2 Fix path_rename_trailing_slashes test case on Win
This commit adds a utility routine
`strip_trailing_slashes_and_concatenate` which is common for
`path_rename` and `path_symlink` on Windows, and checks if the resolved
`PathGet` indeed contains a trailing slash(es) before striping them
off. Secondly, this commit fixes `path_rename_trailing_slashes` test
case by adding two additional checks for potentially erroneous
conditions, and raising `ENOTDIR` if any happens to be true.
2019-11-04 22:35:51 +01:00
dependabot-preview[bot]
811b5e0a7b Update smallvec requirement from 0.6.10 to 1.0.0
Updates the requirements on [smallvec](https://github.com/servo/rust-smallvec) to permit the latest version.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v0.6.10...v1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-04 15:08:27 +01:00
dependabot-preview[bot]
b4d92f0978 Update indicatif requirement from 0.12.0 to 0.13.0
Updates the requirements on [indicatif](https://github.com/mitsuhiko/indicatif) to permit the latest version.
- [Release notes](https://github.com/mitsuhiko/indicatif/releases)
- [Commits](https://github.com/mitsuhiko/indicatif/compare/0.12.0...0.13.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-04 14:53:09 +01:00
Oliver Scherer
e1b0f1f990 Use less vague language 2019-11-04 12:46:58 +01:00
Oliver Scherer @ Cosmian
9903c75f82 Update variable.rs 2019-11-04 12:46:58 +01:00
Oliver Scherer @ Cosmian
d8fa5dcb29 Update outdated documentation 2019-11-04 12:46:58 +01:00
Jakub Konka
74757fdd65 Sync wasmtime and remove wasm32 deprecated module (#165)
Since `wasmtime` now uses `wasi` and `wasi32` modules, we can now
safely remove the `wasm32` module. This commit also updates `wasmtime`
to the latest upstream.
2019-11-02 06:33:54 -07:00
Dan Gohman
95578a42ce Remove RIGHTS_SHARED_MEMORY_BASE.
This came from CloudABI, but WASI doesn't include POSIX-style
shared-memory objects.
2019-11-02 09:10:33 +01:00
Dan Gohman
86829d2447 Handle overflow in Linux's dirent_from_host. 2019-11-02 08:53:30 +01:00
Jakub Konka
b42e550d5a Replace wasm32 with wasi and wasi32
This commit syncs `wasmtime-wasi` crate with the latest refactoring
applied to `wasi-common` crate. Namely, `wasm32` is replaced with
two modules: `wasi` and `wasi32`. This change can be tracked via
CraneStation/wasi-common#151.
2019-11-02 08:49:08 +01:00
Jakub Konka
37ce4ba2ad Fix rights in fd_pwrite; cleanup redundant borrows
This commit fixes incorrect rights check in `fd_pwrite`. Until now,
we were erroneously checking whether the `Descriptor` has
`__WASI_RIGHT_FD_READ` rights instead of `__WASI_RIGHT_FD_WRITE`.

Additionally, this commit removes redundant borrows from
`wasi_ctx.get_fd_entry(..)` calls.
2019-11-01 22:56:32 +01:00
Dan Gohman
a9e3487566 Reorganize host.rs and wasm32.rs. (#151)
* Reorganize host.rs and wasm32.rs.

Reorganize host.rs and wasm32.rs into host.rs, wasi.rs, and wasi32.rs.

Most of the contents of host.rs was not actually host-specific, as most
of the types are fixed-size types like u32 or i64. These types are now
in wasi.rs.

The few types which do have pointer or usize-sized values now remain,
in two versions: host.rs has versions which use actual raw pointers and
usize, and wasi32.rs has versions which use u32 to represent them.

* Fix compilation on BSD

* Fix compilation on Windows

* Fully encapsulate endianness in memory.rs.

This refactors memory.rs to fully encapsulte endianness concerns, so
that outside that file, all values are in host-endian order.

This adds a dependency on the `num` crate, though it's only used for
the `PrimInt` trait, for handling endianness in a generic way.

* Use pub(crate).
2019-11-01 14:21:32 -07:00
Nick Fitzgerald
d1c53a18df Document the test run filetest mode (#1189)
* Document the `test run` filetest mode

* Clarify that `test run` functions can return any boolean
2019-10-31 10:05:10 -07:00
Andrew Brown
8307ad3f3b Build documentation with private items in cranelift-codegen/meta 2019-10-31 09:35:08 -07:00
Andrew Brown
96f5a6b561 Fix documentation link issues 2019-10-31 09:35:08 -07:00
Andrew Brown
f19456640c Add documentation for top-level items in cranelift-codegen/meta 2019-10-31 09:35:08 -07:00
Andrew Brown
e45c283194 Enable documentation of private items in cranelift-codegen/meta; fixes #832 2019-10-31 09:35:08 -07:00
Benjamin Bouvier
8c2d9fd32f Tweak comments in regalloc code. 2019-10-31 16:54:30 +01:00
Jakub Konka
5f5f31beab Treat all warnings as errors by default (#161)
* Treat all warnings as errors in the CI

* Build only in release mode
2019-10-31 11:45:42 +01:00
Josh Triplett
d6b3ca28b4 Add and use a From impl from CodegenError to ModuleError
This will also improve reporting of the chain of errors.
2019-10-30 17:15:09 -07:00
Josh Triplett
7e725cf880 Migrate from failure to thiserror
The failure crate invents its own traits that don't use
std::error::Error (because failure predates certain features added to
Error); this prevents using ? on an error from failure in a function
using Error. The thiserror crate integrates with the standard Error
trait instead.
2019-10-30 17:15:09 -07:00
Peter Huene
3b7a00f474 Fix unused function warnings on Windows.
Unfortunately the helpers added in #154 were only used from non-Windows
implementations, which caused compiler warnings on Windows.

This commit moves the helper to be unix-specific and removes the tiny wrapper
around calling `str_to_cstring` on `PathGet.path`.
2019-10-30 23:04:27 +01:00
Jakub Konka
f4d3f08fc6 Fix path_get returning ENOTDIR when base not dir (#159)
* Fix path_get returning ENOTDIR when base not dir

This commit makes certain adjustments to `WasiCtx` and `FdEntry`
by introducing methods `get_nonvalidated_fd_entry` and
`get_nonvalidated_fd_entry_mut` which only check if the `FdEntry`
corresponding to the specified raw WASI fd exists in the context
object but **without** automatically validating the rights. Thanks
to postponing the validation until after the `FdEntry` object is
extracted from the context, it is possible to check if the extracted
`FdEntry` object is indeed a valid dir descriptor when processing
paths in `path_get` helper fn. In essence then, this commit closes
 #158.

* Remove potentially useless FdObject struct

This commit removes `FdObject` struct which wasn't really used
in our codebase, and flattens its contents into `FdEntry`. IMHO,
this cleans up a fair amount of code and generally unclutters it.

* Refactor and document `WasiCtx` and `FdEntry`

This commit refactors `WasiCtx` struct by making the collection
of `FdEntry`s stored within private, and only allowing it to be
accessed via the provided set of modifier methods (push, insert,
remove, etc.).

Additionally, this commit documents the methods of `WasiCtx` and
`FdEntry` structs for easier debugging and maintenance in the future.
2019-10-30 14:41:43 -07:00
Benjamin Bouvier
6de45ff8fc Update publish-all so it commits on a different branch.
This allows to open a PR for the changes to be submitted on the
repository, instead of silently pushing to master.
2019-10-30 12:55:21 -07:00
dependabot-preview[bot]
52fb94d24c Update object requirement from 0.14.0 to 0.15.0
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Commits](https://github.com/gimli-rs/object/compare/0.14.0...0.15.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-30 12:18:46 -07:00
Benjamin Bouvier
d8b840d2f5 [meta] Remove the OperandKindBuilder;
And replace it by constructors in OperandKind. There's a single optional
parameter function `set_doc` that remains, and didn't justify the whole
OperandKindBuilder concept to exist.
2019-10-30 18:39:20 +01:00
Benjamin Bouvier
d5e990220e [meta] Remove OperandKind::name field and explicitly pass rust_field_name/rust_type; (fixes #1177) 2019-10-30 18:39:20 +01:00
Benjamin Bouvier
0eb2dfc4a3 [meta] Rename OperandKind::default_member to format_field_name; 2019-10-30 18:39:20 +01:00
Benjamin Bouvier
4f5b0689f3 [meta] Remove OperandKind::imm_name method; 2019-10-30 18:39:20 +01:00
Benjamin Bouvier
ae3ea47dbd [meta] Delegate finding the default value to OperandKind instead of its builder.
This applies both to the default_member value (which is now determined at
runtime, instead of pre-computed) and the rust_type value (which is
determined in the Operand's ctor, instead of the builder).
2019-10-30 18:39:20 +01:00
Benjamin Bouvier
4632d35196 [meta] Remove the OperandBuilder, replace it with Operand ctors; 2019-10-30 18:39:20 +01:00
Benjamin Bouvier
2bebc40c16 [meta] Move the doc() default values in the Operand/OperandKind; 2019-10-30 18:39:20 +01:00
Benjamin Bouvier
0b8a579943 Fixes #851: Document instructions' input operands in InstBuilder; 2019-10-30 18:39:20 +01:00
Josh Triplett
fcf0ad1d5d Log function definition unconditionally
Don't log inside the `.map_err` call, which resulted in only logging
function definitions on codegen errors.
2019-10-30 15:55:26 +01:00
bjorn3
689771caf3 Don't force enable basic-blocks feature
Fixes #1179
2019-10-30 11:22:05 +01:00
Dan Gohman
0302f1a164 Make path_get return ENOTDIR when the base isn't a directory.
Return `ENOTDIR` instead of `ENOTCAPABLE` when `*at` functions are
given a non-directory as their base. This is in accordance with POSIX:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

Currently wasi-libc contains some code to detect such cases and rewrite
`ENOTCAPABLE` to `ENOTDIR`, however it's better for WASI implementations
to just do the right thing in the first place.
2019-10-30 10:20:42 +01:00
Jakub Konka
f3a5186230 Refactor poll_oneoff on *nix (#137)
* Fixes CraneStation/wasmtime#440

This commit introduces a couple of changes/fixes:
* it annotates `log::debug!` messages with "host" to differentiate
  between file descriptors stored on the WASI side (aka the wrappers)
  and those managed by the host (aka the wrapped)
* it fixes CraneStation/wasmtime#440, i.e., incorrect passing of
  file descriptor to `poll_oneoff` where currently errenously we
  pass in the wrapper instead of the wrapped value
* it adds a couple more `log::debug!` macros calls for easier future
  debugging

* Add partial refactorting to poll_oneoff

This commit lays the groundwork for more clean up to come in
subsequent commits.

* Finalise refactoring of `poll_oneoff`

* Fix compilation error on Windows

* Address majority of suggestions and refactor

Co-authored-by: Marcin Mielniczuk <marmistrz.dev@zoho.eu>

* Add poll_oneoff test case

* Leave timeout in nanoseconds in ClockEventData

Instead of converting the timeout value from nanoseconds to
milliseconds in the host-independent impl, move the conversion
to *nix-specific impl as the conversion is currently only warranted
by the POSIX `poll` syscall.

* Don't fail immediately on bad descriptor

If the user specifies an invalid descriptor inside a subscription,
don't fail immediately but rather generate an event with the thrown
WASI error code, and continue with the remaining, potentially
correct subscriptions.
2019-10-30 09:57:59 +01:00
lzutao
7e5c33a29e Use array::iter 2019-10-30 09:47:25 +01:00
Dan Gohman
aecec187d7 Check for overflow when incrementing the preopen_fd counter. (#157)
If someone somehow defines more preopens than can fit in the
`__wasi_fd_t` index space, we should detect it instead of silently
wrapping around.
2019-10-29 17:11:43 -07:00
Peter Huene
de71dbec0d Implement a helper for converting &str to CString. (#154)
This commit implements a simple helper for converting `&str` to `CString` and
mapping to the appropriate WASI error.

It also adds a `path_cstring` helper method in `PathGet` where the conversion was
used the most.

Fixes #104.
2019-10-29 16:30:22 -07:00
Dan Gohman
9a5c53b3ed Make wasi-common's Error messages prettier. (#156)
Instead of returning the debug formatting, which includes the enum
names, like `Io(...)`, just run the formatting function of the inner
error objects, which is nicer for command-line use.
2019-10-29 15:46:11 -07:00
Yury Delendik
c2ba74b118 [wasmtime-api] run examples as tests (#466)
* [wasmtime-api] run example as tests

* Update wasmtime-api/tests/examples.rs

Co-Authored-By: Nick Fitzgerald <fitzgen@gmail.com>

* disable multi example test on windows
2019-10-29 17:25:54 -05:00
Alex Crichton
bf526b62d3 Add book documentation skeleton and auto-publish from CI (#435)
This commit adds the skeleton of a new set of documentation for
`wasmtime` in the existing `docs` directory. This documentation is
organized and compiled with [mdbook] which the Rust project uses for
most of its own documentation as well. At a previous meeting we
brainstormed a rough skeleton of what the documentation in this book
would look like, and I've transcribed that here for an example of how
this is rendered and how it can be laid out. No actual documentation is
written yet.

This commit also additionally adds necessary support to auto-publish
both this book documentation and API documentation every time a commit
is pushed to the `master` branch. All HTML will be automatically pushed
to the `gh-pages` branch so long as the CI passes, and this should get
deployed to https://cranestation.github.io/wasmtime.

I've done a few dry-runs and I think this'll all work, but we'll likely
tweak a few things here and there after running this through CI to make
sure everything looks just as we'd like. My hope though is that after
this lands we can start actually filling out all the documentation and
being able to review it as well.

[mdbook]: https://crates.io/crates/mdbook
2019-10-29 15:55:51 +01:00
Josh Triplett
06e9170f30 wasmtime-py: Don't use "main.rs" for a wasm example so cargo doesn't test it (#464)
cargo test will test examples that have a "main.rs", but in this case,
the example requires manual compilation as a wasm module, and doesn't
build as a standalone program. Rename it to "demo.rs".
2019-10-29 15:47:49 +01:00