Commit Graph

49 Commits

Author SHA1 Message Date
Jakub Konka
73f85f5c4b Merge branch 'master' into wasi-common 2019-11-08 06:53:18 +01:00
Dan Gohman
43b761ef5f Update the top-level README.md and embedding documentation. (#508)
* Update the top-level README.md and embedding documentation.

wasmtime-api is now the primary external API crate, so recommend that
instead of wasmtime-jit.

Also, enable wasmtime-api's C API by default, so that it shows up on
docs.rs, and to make it easier to use.

And, add basic embedding documentation and link to it from the
README.md. Credit to @yurydelendik for the content.

* Use the new wasm-c-api URL.

* Don't pass --features wasm-c-api, as it is now on by default.
2019-11-07 16:47:54 -08:00
Peter Huene
a6b150c9d1 Merge pull request #462 from peterhuene/windows-unwind
Implement registering JIT unwind information on Windows.
2019-11-07 10:35:25 -08:00
Yury Delendik
6632a7da37 [wasmtime-api] reduce examples complexity: hostref for store/engine (#489)
* reduce amount of store.clone()

* use HostRef Engine as ref / use Engine::default()
2019-11-07 11:39:23 -06:00
Jakub Konka
cd1e54487c Merge wasi-common into wasmtime
This commit merges [CraneStation/wasi-common] repo as a subdir of
this repo while preserving **all** of git history. There is an
initiative to pull `wasi-common` into [CraneStation/wasmtime], and
[CraneStation/wasmtime] becoming a monorepo. This came about for
several reasons with a common theme of convenience, namely,
having a monorepo:
1. cleans up the problem of dependencies (as we have seen first
   hand with dependabot enabled, it can cause some grief)
2. completely removes the problem of syncing the closely dependent
   repos (e.g., updating `wasi-common` with say a bugfix generally
   implies creating a "sync" commit for pulling in the changes into
   the "parent" repo, in this case, `wasmtime`)
3. mainly for the two reasons above, makes publishing to crates.io
   easier
4. hopefully streamlines the process of getting the community
   involved in contributing to `wasi-common` as now everything
   is one place

[CraneStation/wasi-common]: https://github.com/CraneStation/wasi-common
[CraneStation/wasmtime]: https://github.com/CraneStation/wasmtime
2019-11-07 15:45:58 +01:00
Adam C. Foltzer
ab3cd945bc Use new WasiCtxBuilder types from wasi-common (#490)
* use new `WasiCtxBuilder` types from wasi-common

* Update wasi-common deps
2019-11-07 12:25:43 +01:00
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
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
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
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
Josh Triplett
faee3b4bc3 wasmtime-api: reserve_exact on the correct vector (#452)
Fix what looks like a copy-paste issue in wasmtime-api/src/module.rs,
which led to calling reserve_exact on one vector before pushing that
many elements into another.
2019-10-28 12:57:51 -05:00
Jim Posen
71dd73d672 Expose some more internals publicly (#340) 2019-10-28 18:12:11 +01:00
Jakub Konka
875eea6052 Update poll_oneoff's signature
This PR updates `wasmtime_wasi` crate by adjusting `poll_oneoff`'s
signature to that introduced in `wasi_common` in
CraneStation/wasi-common#137. This change is required in order to
fix #440.
2019-10-24 11:47:35 +02:00
Yury Delendik
876d5e1075 [wasmtime-api] Multi value api support (#448) 2019-10-23 14:09:27 -05:00
Alex Crichton
9947bc5209 Switch from wabt crate to wast (#434)
* Switch lightbeam from `wabt` to `wast`

Switch from a C++-based `*.wat` parser to a Rust-based parser

* Remove unneeded `wabt` dev-dependency from wasmtime-api

* Rewrite `wasmtime-wast` crate with `wast-parser`

This commit moves the `wasmtime-wast` crate off the `wabt` crate on to
the `wast-parser` crate which is a Rust implementation of a `*.wast` and
`*.wat` parser. The intention here is to continue to reduce the amount
of C++ required to build wasmtime!

* Use new `wat` and `wast` crate names
2019-10-18 13:25:48 -07:00
Alex Crichton
50beb21b63 Add a missing api to the wasm C API (#433)
This was used when [prototyping] but I found it wasn't implemented yet!

[prototyping]: https://github.com/dtolnay/watt/issues/2#issuecomment-543007365
2019-10-17 17:14:15 -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
Jakub Konka
9d54f84a32 Fast-forward wasi-common to latest git rev 2019-10-17 12:02:58 +02: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
Dan Gohman
36756613b8 Merge remote-tracking branch 'origin/master' into integrate-lightbeam 2019-10-04 16:11:12 -07:00
Jakub Konka
daa3c3aeef Update wasi-common version 2019-10-03 23:59:18 +02:00
Dan Gohman
8d89c3b479 Add options to wasmtime and wasm2obj to pick compilation strategy. 2019-10-02 13:59:49 -07:00
Dan Gohman
65b8afabe6 Make use of Lightbeam configurable.
This adds a `--always-lightbeam` option as well as an `--always-cranelift`
option, to allow the compilation strategy to be selected via the
command-line. This also enables regular testing for Lightbeam.
2019-10-02 11:54:06 -07:00
Peter Huene
cb38b48156 Fix memory leaks in extern conversion functions in C API. (#395)
This fixes the memory leaks in the following functions which should not be
returning "owned" pointers:

* `wasm_extern_as_func`
* `wasm_func_as_extern`
* `wasm_extern_as_global`
* `wasm_global_as_extern`
* `wasm_extern_as_memory`
* `wasm_extern_as_table`

Additionally, this commit implements the `wasm_memory_as_extern` and
`wasm_table_as_extern` functions.

Fixes #394.
2019-10-02 05:54:36 -07:00
Peter Huene
406bc7895a Implement reading module table imports in API. (#387)
This commit implements populating the table imports of a module from the API.

It also allows for `anyref` in table types as per the reference types proposal.
2019-09-27 05:50:54 -07:00
Andrew Brown
68de2247bc Avoid errors when converting V128 for the wasm-c-api
For this to work the wasm-c-api must add support for the V128 type (e.g. through __uint128_t)
2019-09-26 15:46:18 -07:00
Andrew Brown
5bd422b429 Add V128 type 2019-09-26 15:46:18 -07:00
Andrew Brown
290b51a5f6 Update wabt and spec test suite
Update wabt (see issue in https://github.com/pepyakin/wabt-rs/pull/56). Due to changes in wabt, the spec tests are updated as well.
2019-09-26 15:46:18 -07:00
Peter Huene
4288f33440 Fix borrow scope for store in WrappedCallable impl for WasmtimeFn.
This PR fixes the borrow scope of store in the `WrappedCallable` impl of
`WasmTimeFn` such that it does not remain borrowed across the call to
`wasmtime_call_trampoline`. By limiting the scope of the borrow, the
implementation can be reentered if an exported function calls an imported
function, which in turn calls another exported function.

Fixes #365.
2019-09-26 12:55:58 -07:00
Dan Gohman
10845134f7 Update to latest walrus, wasmparser, and wasm-webidl-bindings. 2019-09-26 12:34:58 -07:00
Peter Huene
622a630acd Implement wasm_module_imports. (#384)
This commit implements `wasm_module_imports` and a few related APIs so that
import information can be read about a module.
2019-09-26 13:57:33 -05:00
Yury Delendik
b0fe01397b Use HOST call convension in Func signature (#383) 2019-09-26 13:10:41 -05:00
Yury Delendik
b41e918ec3 [wasmtime-api] Fixes wasm_exporttype_type leak 2019-09-25 21:19:34 -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
Yury Delendik
9c747db429 Make data() unsafe 2019-09-18 09:15:14 -07:00
Yury Delendik
6a41417b52 Add examples; refactor HostRef 2019-09-18 09:15:14 -07:00
Yury Delendik
042c87763e add invariant checks 2019-09-12 17:11:34 -07:00
Yury Delendik
805fbb4d2a rm private SignatureRegistry trait 2019-09-12 17:11:34 -07:00
Yury Delendik
ee26b9ead7 few comments. 2019-09-12 17:11:34 -07:00
Yury Delendik
263fa098a1 rm "callable" warning 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
Yury Delendik
33e282c93f Provide pre-compiled shared libraries for C-API (#311) 2019-08-30 15:59:58 +02:00
Yury Delendik
c94c383a7c [wasmtime-api] Implementation of classes for run-{reflect,start,global,memory}-c (#295)
Implements apis for reflect-c, start-c, run-global-c and run-memory-c
2019-08-26 10:07:02 -05:00
Yury Delendik
f88e92a57c Better Wasmtime API for embedder (#287)
* Migrate wasm-rust-api code to wasmtime.
2019-08-21 00:35:26 -07:00