Commit Graph

93 Commits

Author SHA1 Message Date
Pat Hickey
0faf3b248e wasmtime-wasi: keep exporting sync at the top level 2021-05-05 11:00:59 -07:00
Pat Hickey
2f0c7e59e7 wasmtime-wasi: all funcs are async now 2021-04-14 16:04:41 -07:00
Pat Hickey
0127676621 wasi-cap-std-async is better named wasi-tokio 2021-04-14 14:06:36 -07:00
Pat Hickey
2b7a93c403 wasmtime-wasi: two distinct definitions of the Wasi struct, when sync vs async 2021-04-13 17:51:18 -07:00
Pat Hickey
8f9fb1f4e2 make wasi-cap-std-async work with wasmtime-wasi 2021-04-13 17:51:18 -07:00
Chris Fallin
6bec13da04 Bump versions: Wasmtime to 0.26.0, Cranelift to 0.73.0. 2021-04-05 10:48:42 -07:00
Pat Hickey
19a802549f wasmtime-wasi: re-export wasi-cap-std-sync 2021-03-25 17:04:10 -07:00
Nick Fitzgerald
d081ef9c2e Bump Wasmtime to 0.25.0; Cranelift to 0.72.0 2021-03-16 11:02:56 -07:00
Peter Huene
54c07d8f16 Implement shared host functions. (#2625)
* Implement defining host functions at the Config level.

This commit introduces defining host functions at the `Config` rather than with
`Func` tied to a `Store`.

The intention here is to enable a host to define all of the functions once
with a `Config` and then use a `Linker` (or directly with
`Store::get_host_func`) to use the functions when instantiating a module.

This should help improve the performance of use cases where a `Store` is
short-lived and redefining the functions at every module instantiation is a
noticeable performance hit.

This commit adds `add_to_config` to the code generation for Wasmtime's `Wasi`
type.

The new method adds the WASI functions to the given config as host functions.

This commit adds context functions to `Store`: `get` to get a context of a
particular type and `set` to set the context on the store.

For safety, `set` cannot replace an existing context value of the same type.

`Wasi::set_context` was added to set the WASI context for a `Store` when using
`Wasi::add_to_config`.

* Add `Config::define_host_func_async`.

* Make config "async" rather than store.

This commit moves the concept of "async-ness" to `Config` rather than `Store`.

Note: this is a breaking API change for anyone that's already adopted the new
async support in Wasmtime.

Now `Config::new_async` is used to create an "async" config and any `Store`
associated with that config is inherently "async".

This is needed for async shared host functions to have some sanity check during their
execution (async host functions, like "async" `Func`, need to be called with
the "async" variants).

* Update async function tests to smoke async shared host functions.

This commit updates the async function tests to also smoke the shared host
functions, plus `Func::wrap0_async`.

This also changes the "wrap async" method names on `Config` to
`wrap$N_host_func_async` to slightly better match what is on `Func`.

* Move the instance allocator into `Engine`.

This commit moves the instantiated instance allocator from `Config` into
`Engine`.

This makes certain settings in `Config` no longer order-dependent, which is how
`Config` should ideally be.

This also removes the confusing concept of the "default" instance allocator,
instead opting to construct the on-demand instance allocator when needed.

This does alter the semantics of the instance allocator as now each `Engine`
gets its own instance allocator rather than sharing a single one between all
engines created from a configuration.

* Make `Engine::new` return `Result`.

This is a breaking API change for anyone using `Engine::new`.

As creating the pooling instance allocator may fail (likely cause is not enough
memory for the provided limits), instead of panicking when creating an
`Engine`, `Engine::new` now returns a `Result`.

* Remove `Config::new_async`.

This commit removes `Config::new_async` in favor of treating "async support" as
any other setting on `Config`.

The setting is `Config::async_support`.

* Remove order dependency when defining async host functions in `Config`.

This commit removes the order dependency where async support must be enabled on
the `Config` prior to defining async host functions.

The check is now delayed to when an `Engine` is created from the config.

* Update WASI example to use shared `Wasi::add_to_config`.

This commit updates the WASI example to use `Wasi::add_to_config`.

As only a single store and instance are used in the example, it has no semantic
difference from the previous example, but the intention is to steer users
towards defining WASI on the config and only using `Wasi::add_to_linker` when
more explicit scoping of the WASI context is required.
2021-03-11 10:14:03 -06:00
Dan Gohman
8854dec01d Bump version to 0.24.0
I used a specially modified version of the publish script to avoid
bumping the `witx` version.
2021-03-04 18:17:03 -08:00
Dan Gohman
10dbee0c17 Add a minimal README.md for wasmtime-wasi. 2021-03-01 09:58:57 -08:00
Max de Danschutter
445e539ae0 Disable wasmtime default-features in wasi crate (#2664) 2021-02-18 11:29:52 -06:00
Dan Gohman
8d90ea0390 Bump version to 0.23.0
I used a specially modified version of the publish script to avoid
bumping the `witx` version.
2021-02-17 15:35:43 -08:00
Pat Hickey
1a45096ee6 wasi-common, wasi-cap-std-sync, wasmtime-wasi should all be published now 2021-02-03 15:52:26 -08:00
Pat Hickey
b59160c3da docs! 2021-02-01 18:14:26 -08:00
Pat Hickey
037c5e398c remove re-exports 2021-02-01 17:44:11 -08:00
Pat Hickey
6a5d4b9993 docs 2021-01-29 13:31:30 -08:00
Pat Hickey
8b285ec2e7 make wasmtime_wasi::Wasi a struct which does both snapshots! 2021-01-29 13:23:04 -08:00
Pat Hickey
c8e76b11ba wasmtime-wasi: support both snapshots 2021-01-29 12:11:38 -08:00
Pat Hickey
9bd89abc0c rename everything c2 related to the "real" names 2021-01-28 15:34:03 -08:00
Nick Fitzgerald
5de5bf1565 Merge pull request #2550 from bytecodealliance/pch/wiggle_trapping
wiggle: introduce Trap enum
2021-01-07 16:23:21 -08:00
Nick Fitzgerald
5ad82de3c5 Bump Wasmtime to 0.22.0; Cranelift to 0.69.0 2021-01-07 14:51:12 -08:00
Pat Hickey
4a574c14eb wasi-common: port to use wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
bf2371c8af wasi: get rid of missing_memory config 2021-01-05 17:29:34 -08:00
Alex Crichton
efe7f37542 Remove duplication in wasi-common for snapshot_0 (#2444)
This commit deletes the old `snapshot_0` implementation of wasi-common,
along with the `wig` crate that was used to generate bindings for it.
This then reimplements `snapshot_0` in terms of
`wasi_snapshot_preview1`. There were very few changes between the two
snapshots:

* The `nlink` field of `FileStat` was increased from 32 to 64 bits.
* The `set` field of `whence` was reordered.
* Clock subscriptions in polling dropped their redundant userdata field.

This makes all of the syscalls relatively straightforward to simply
delegate to the next snapshot's implementation. Some trickery happens to
avoid extra cost when dealing with iovecs, but since the memory layout
of iovecs remained the same this should still work.

Now that `snapshot_0` is using wiggle we simply have a trait to
implement, and that's implemented for the same `WasiCtx` that has the
`wasi_snapshot_preview1` trait implemented for it as well. While this
theoretically means that you could share the file descriptor table
between the two snapshots that's not supported in the generated bindings
just yet. A separate `WasiCtx` will be created for each WASI module.
2020-11-30 12:27:49 -06:00
Alex Crichton
ab1958434a Bump to 0.21.0 (#2359) 2020-11-05 09:39:53 -06:00
Joshua Warner
eb650f6fe0 filesystem example (#2236) 2020-09-29 13:20:14 -05: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
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
22b427baa0 use WASI_ROOT env var to specify witx paths to wiggle macros 2020-08-28 15:42:51 -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
02aba548e1 Merge remote-tracking branch 'origin/main' into pch/wasi_error_handling 2020-08-25 15:22:51 -07:00
Pat Hickey
80b884780b wasmtime-wasi: fix path to errno type 2020-08-18 10:57:43 -07:00
Pat Hickey
8d39d9b1b5 wasmtime-wasi: switch dep from log to tracing 2020-08-18 10:46:14 -07:00
Alex Crichton
2f368ed5d6 Fixes needed for 0.19.0 (#2035)
* Add some more wiggle crates to publish

* Fix build of wasi-common on crates.io

* Bump crates to 0.19.1 to fix crates.io build
2020-07-16 17:27:21 -05:00
Alex Crichton
63d5b91930 Wasmtime 0.19.0 and Cranelift 0.66.0 (#2027)
This commit updates Wasmtime's version to 0.19.0, Cranelift's version to
0.66.0, and updates the release notes as well.
2020-07-16 12:46:21 -05:00
Pat Hickey
82c4132700 simpler name, add rustdocs 2020-06-24 14:34:35 -07:00
Pat Hickey
f66c1fbde9 reorganize configuration into modules 2020-06-23 17:42:12 -07:00
Pat Hickey
69f81397a8 add func overrides, to get rid of proc exit special case 2020-06-23 16:29:11 -07:00
Pat Hickey
49c62ee828 make the missing memory error value configurable 2020-06-23 15:28:01 -07:00
Pat Hickey
bb339aaba0 rename macro. add comments to invocation. 2020-06-23 14:16:53 -07:00
Pat Hickey
abc3982234 add target to config 2020-06-23 14:13:27 -07:00
Pat Hickey
cde32070fc factor the docs out as well 2020-06-22 19:27:31 -07:00
Pat Hickey
6adbae3007 paramaterize the instance type name as well 2020-06-22 19:01:29 -07:00
Pat Hickey
1050c6d99c wasmtime-wiggle-macro: re-use Names functionality
rather than try to duplicate it in utils
2020-06-22 18:47:59 -07:00
Pat Hickey
185701df1b wasmtime-wiggle-macro: adopt config system from wiggle-generate 2020-06-22 18:39:33 -07:00
Pat Hickey
303f7172a1 wasi: switch to use wasmtime-wiggle for wiggle integration 2020-06-22 17:23:11 -07:00
Dan Gohman
caa87048ab Wasmtime 0.18.0 and Cranelift 0.65.0. 2020-06-11 17:49:56 -07:00
Dan Gohman
a76639c6fb Wasmtime 0.17.0 and Cranelift 0.64.0. (#1805) 2020-06-02 18:51:59 -07:00
Dan Gohman
fb0b9e3ae6 Change proc_exit to unwind the stack rather than exiting the host process. (#1646)
* Remove Cranelift's OutOfBounds trap, which is no longer used.

* Change proc_exit to unwind instead of exit the host process.

This implements the semantics in https://github.com/WebAssembly/WASI/pull/235.

Fixes #783.
Fixes #993.

* Fix exit-status tests on Windows.

* Revert the wiggle changes and re-introduce the wasi-common implementations.

* Move `wasi_proc_exit` into the wasmtime-wasi crate.

* Revert the spec_testsuite change.

* Remove the old proc_exit implementations.

* Make `TrapReason` an implementation detail.

* Allow exit status 2 on Windows too.

* Fix a documentation link.

* Really fix a documentation link.
2020-05-13 15:59:43 -07:00