Commit Graph

44 Commits

Author SHA1 Message Date
Peter Huene
920728d14d Implement registering JIT unwind information on Windows.
This commit implements registering unwind information for JIT functions on
Windows so that the operating system can both walk and unwind stacks containing
JIT frames.

Currently this only works with Cranelift as lightbeam does not emit unwind
information yet.

This commit also resets the stack guard page on Windows for stack overflow
exceptions, allowing reliable stack overflow traps.

With these changes, all previously disabled test suite tests (not including
the multi-value tests) on Windows are now passing.

Fixes #291.
2019-11-06 20:27:32 -08:00
Peter Huene
ab80785c05 Bump Cranelift to 0.49.0 and target-lexicon to 0.9.0. (#499)
This commit bumps Cranelift to 0.49.0 and target-lexicon to 0.9.0 to fix the
failing build to due an updated faerie crate that violated semver with an
updated 0.9.0 target-lexicon dependency.

Fixes #491.
2019-11-06 15:30:54 -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
vms
a34439de42 optimize memory.grow 0 (#443) 2019-10-24 15:56:04 -07:00
Dan Gohman
877152ee5c Use the libstd instead of the errno crate in wasmtime-runtime. (#408)
Rust's standard library now has a way to read the OS errno value, so use
that instead of depending on the errno crate in wasmtime-runtime.
2019-10-17 17:14:57 -07:00
Nick Fitzgerald
842faf5aa6 Support for multi-value wasm (#399)
* deps: bump wasmparser to 0.39.2

This has a bug fix for multi-value Wasm validation that is required for getting
the spec tests passing.

https://github.com/yurydelendik/wasmparser.rs/pull/135

* Update cranelift to 0.46.1 to get multi-value Wasm support

The `cranelift_wasm` APIs had to change a little bit to maintain state necessary
when translating multi-value Wasm blocks. The `translate_module` function now
returns a `ModuleTranslationState` that is borrowed during each function's
translation.

* Enable multi-value proposal's spec tests

This enables all the Wasm multi-value proposal's spec tests other than the ones
that rely on functions having more return values than registers available on the
target. That is not supported by cranelift yet.

* wasmtime-interface-types: always use multi-value Wasm

And remove the return pointer hacks that work around the lack of multi-value.
2019-10-17 17:12:01 -07:00
Dan Gohman
fd3efad781 Various clippy fixes. (#403) 2019-10-09 13:32:52 -07:00
Dan Gohman
8e1b44b29c Make more code work with no_std. (#407)
* Make more code work with no_std.

no_std support is still incomplete, but this patch takes care of the
bulk of the straightforward parts.
2019-10-08 16:53:32 -07:00
Andrew Brown
fb1c473342 Alter invocation of functions to use 16-byte invocation arguments 2019-09-26 15:46:18 -07:00
Andrew Brown
5bd422b429 Add V128 type 2019-09-26 15:46:18 -07:00
Artur Jamro
286d2515f9 Check trap code in test suite assertions 2019-09-26 11:43:41 -07:00
Artur Jamro
fa9175f9e5 Trap registry 2019-09-25 17:56:08 -07:00
Artur Jamro
134bf467e7 Update cranelift to 0.44.0 2019-09-25 13:04:10 -07:00
Nick Fitzgerald
1848cc0868 deps: Update cranelift-* to 0.43.1 2019-09-25 13:04:10 -07:00
Artur Jamro
febb0cb693 Cache worker 2019-09-18 16:43:27 -07:00
Yury Delendik
042c87763e add invariant checks 2019-09-12 17:11:34 -07:00
Yury Delendik
164039f08d Move table_utils into wasmtime_runtime 2019-09-12 17:11:34 -07:00
Yury Delendik
de1c0f63eb Table operation; refactor Callable 2019-09-12 17:11:34 -07:00
Artur Jamro
fad70eb8bb Refactor usage of SecondaryMap impls (serde, PartialEq) 2019-09-05 17:14:32 -07:00
Artur Jamro
364300f6cf Use target triple in cache directory hierarchy (#300) 2019-09-04 13:12:27 -07:00
Dan Gohman
45fd9dadd8 Use winapi::ctypes::c_void on Windows. (#297)
`winapi::ctypes::c_void` is apparently distinct from `core::ffi::c_void`
and `libc::c_void`.
2019-08-24 07:04:31 -07:00
Dan Gohman
d4f27dcc91 Update Cargo.toml metadata for publishing. 2019-08-20 23:28:54 -07:00
Dan Gohman
44367ba99a Bump version to 0.2.0 2019-08-20 16:07:57 -07:00
Artur Jamro
7009c8dd73 Add dyn to traits and bump Rust version 2019-08-16 13:46:09 -07:00
Alex Crichton
6def6de5e0 Remove the LLVM/bindgen/cmake dependencies from wasmtime-runtime (#253)
* Remove cmake/bindgen/llvm from wasmtime-runtime

This commit removes the cmake/bindgen dependency (which removes the need
for `llvm-config`) from the `wasmtime-runtime` crate. The C++ code is
instead compiled with the `cc` crate (it's just one file anyway) and the
interface is handwritten since it's quite small anyway.

Some other changes are:

* The `TrapContext` type in C++ was removed since it was unused, and it
  was moved to Rust with a `Cell` on each field.

* Functions between Rust/C++ now return `int` instead of `bool` to make
  them a bit more FFI compatible portably.

* The `jmp_buf` type has a workaround that will be fixed in the next commit.

* Move setjmp/longjmp to C++

This commit moves the definition of setjmp and longjmp into C++. This is
primarily done because it's [debatable whether it's possible to call
`setjmp` from Rust][rfc]. The semantics of `setjmp` are that it returns
twice but LLVM doesn't actually know about this because rustc isn't
telling LLVM this information, so it's unclear whether it can ever be
safe.

Additionally this removes the need for Rust code to know the definition
of `jmp_buf` which is a pretty hairy type to define in Rust across
platforms.

The solution in this commit is to move all setjmp/longjmp code to C++,
and that way we should be able to guarantee that jumps over wasm JIT
code should always go from C++ to C++, removing Rust from the equation
for now from needing to get any fiddly bits working across platforms.
This should overall help it be a bit more portable and also means Rust
doesn't have to know about `jmp_buf` as a type.

The previous `Vec` of `jmp_buf` is now replaced with one thread-local
pointer where previous values are stored on the stack and restored when
the function returns. This is intended to be functionally the same as
the previous implementation.

[rfc]: https://github.com/rust-lang/rfcs/issues/2625

* rustfmt

* Use volatile loads/stores

* Remove mention of cmake from README
2019-08-09 10:11:13 +02:00
Yury Delendik
5fc2d827b7 Update cranelift requirement from 0.37.0 to 0.38.0 (#254)
closes #248, closes #249, closes #250, closes #251, closes #252
2019-08-06 14:49:28 -05:00
Yury Delendik
0bc9d1fe6f Update cranelift to 0.37.0 (#236)
Closed #228, #227, #226, #225, #224
2019-08-01 20:46:34 -05:00
dependabot-preview[bot]
320ad7d4b3 Update bindgen requirement from 0.50.0 to 0.51.0 (#222)
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.50.0...v0.51.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-31 11:40:10 -05:00
Artur Jamro
165dc4944d Simple module compilation cache (#203)
* Simple module compilation cache

* Fix base64 encoding bug

* Use warn! everywhere in cache system

* Remove unused import

* Temporary workaround for long path on Windows

* Remove unused import for non-windows builds

* Add command line argument to enable cache system + apply minor review feedback
2019-07-25 16:16:10 -07:00
dependabot-preview[bot]
dc39fee390 Update bindgen requirement from 0.49.0 to 0.50.0
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.49.0...v0.50.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-23 11:04:45 -07:00
dependabot-preview[bot]
9fe77cffc6 Update memoffset requirement from 0.2.1 to 0.5.1
Updates the requirements on [memoffset](https://github.com/Gilnaa/memoffset) to permit the latest version.
- [Release notes](https://github.com/Gilnaa/memoffset/releases)
- [Commits](https://github.com/Gilnaa/memoffset/commits/v0.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-23 11:04:06 -07:00
Artur Jamro
c80508c8a9 Make the calls to wasm's memory.grow and memory.size indirect (#194)
* Make the calls to wasm's memory.grow and memory.size indirect
2019-07-18 14:40:03 -07:00
Dan Gohman
1a10f4a002 Update to Cranelift 1.33 and require Rust 1.35.
Cranelift requires Rust 1.35; update accordingly.
2019-07-03 11:16:55 -07:00
Yury Delendik
fb9d6061e4 Update cranelift, faerie, target-lexicon and wasmparser deps 2019-07-02 14:07:30 -07:00
Dan Gohman
e3c021cc59 Downgrade memoffset to 0.2.1.
Version 0.3.0 was yanked from crates.io.
2019-07-02 13:27:03 -07:00
Ari Lotter
8dc1d90352 Use try_from replacing cast in wasmtime-runtime. 2019-06-09 12:27:28 +02:00
Dan Gohman
825f1d764a Fix a compiler warning.
Fix the following warning from Rust 1.35:

warning: cannot borrow `*self` as mutable because it is also borrowed as immutable
   --> wasmtime-runtime/src/instance.rs:473:25
    |
465 |         } else if let Some(start_export) = self.module.exports.get("_start") {
    |                                            ----------- immutable borrow occurs here
...
473 |                         self.invoke_function(*func_index)
    |                         ^^^^                 ----------- immutable borrow later used here
    |                         |
    |                         mutable borrow occurs here
    |
    = note: #[warn(mutable_borrow_reservation_conflict)] on by default
    = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
    = note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
2019-05-30 18:44:38 -07:00
Yury Delendik
6740704b74 Expose Module reference from InstanceHandle 2019-05-14 15:02:06 -07:00
Stefano Buliani
3351befb3b Allow access to memory_index and grow on Instance (#105)
* Changed `memory_grow` and `memory_index` in `Instance` struct to be `pub(crate)` and added the equivalent proxy methods to the `InstanceHandle` struct.
2019-04-16 19:59:54 -07:00
Yury Delendik
07a6ca8f4e Hack to not allow inlining even when Rust wants to do it in release mode. 2019-04-10 11:15:38 -07:00
Henrik Rydgård
f5ebdb8e6a Get wasmtime building on Windows. (#92)
* Get wasmtime building on Windows.

Requires LLVM binaries from http://releases.llvm.org/download.html at
build time (bindgen).
2019-04-03 06:50:38 -07:00
Dan Gohman
b2fefe7714 WASI prototype design, implementation, and documentation.
This adds documents describing the WASI Core API, and an implementation in
Wasmtime.
2019-03-27 10:58:43 -07:00
Yury Delendik
2353be95e6 update cranelift deps to 0.30.0 2019-03-27 02:24:51 -07:00
Dan Gohman
db0abe8431 Move the wasmtime crate directories form lib/* to wasmtime-*.
This follows a similar change to Cranelift made here:

https://github.com/CraneStation/cranelift/pull/660
2019-03-20 11:30:28 -07:00