Commit Graph

258 Commits

Author SHA1 Message Date
Pat Hickey
b450094dad debug 2021-05-07 15:19:17 -07:00
Pat Hickey
ee8a8a2a90 poll_oneoff_stdio test: loosen up contract
permit both readable events to be delivered in very short interval,
rather than simultaneously.
2021-05-07 14:27:23 -07:00
Pat Hickey
b19d86268c fix test harness stdio 2021-05-06 16:19:33 -07:00
Pat Hickey
add115ba00 fix 2021-05-06 15:53:23 -07:00
Pat Hickey
208013e34e de-duplicate code 2021-05-06 11:12:53 -07:00
Pat Hickey
f4d851126d tests dont need fuel 2021-05-06 10:53:25 -07:00
Pat Hickey
9e04c5333c poll oneoff tests: what if we read a non-empty file? 2021-05-05 13:08:33 -07:00
Pat Hickey
3e8ea090c6 ci debugging 2021-05-05 11:24:27 -07:00
Pat Hickey
686d8c22f9 fix test harness 2021-05-04 11:18:20 -07:00
Pat Hickey
b7efcbe80f jump through enough hoops for the poll lifetime to work out
you program rust for a few years and you think you're done tearing your
hair out over lifetimes, well, you'll find yourself wrong
2021-04-29 16:50:22 -07:00
Pat Hickey
02581ddda0 poll_oneoff test: don't try to poll same fd for read and write 2021-04-27 17:41:07 -07:00
Pat Hickey
8667d8c244 test-programs: test wasi-tokio 2021-04-19 16:00:27 -07:00
Pat Hickey
b883bda022 fix test-programs for sync wasi 2021-04-14 16:06:50 -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
Peter Huene
4ad0099da4 Update wat crate.
Update the `wat` crate to latest version and use `Error::set_path` in
`Module::from_file` to properly record the path associated with errors.
2021-04-01 20:11:26 -07:00
Dan Gohman
dd7e16762c Arrange for the new test to be called. 2021-03-22 12:50:16 -07:00
Dan Gohman
6b40724d18 Support "sleep" forms of poll_oneoff.
Add support for `poll_oneoff` calls which just sleep on a relative
timeout. This fixes a bug handling code compiled with WASI libc's `sleep`
family of functions, which call `poll_oneoff` with a `CLOCK_REALTIME`
timer, which wasn't previously implemented.
2021-03-22 12:50:16 -07:00
Benjamin Bouvier
6e6713ae0b cranelift: add support for the Mac aarch64 calling convention
This bumps target-lexicon and adds support for the AppleAarch64 calling
convention. Specifically for WebAssembly support, we only have to worry
about the new stack slots convention. Stack slots don't need to be at
least 8-bytes, they can be as small as the data type's size. For
instance, if we need stack slots for (i32, i32), they can be located at
offsets (+0, +4). Note that they still need to be properly aligned on
the data type they're containing, though, so if we need stack slots for
(i32, i64), we can't start the i64 slot at the +4 offset (it must start
at the +8 offset).

Added one test that was failing on the Mac M1, as well as other tests
stressing different yet similar situations.
2021-03-22 10:06:13 +01:00
Nick Fitzgerald
d081ef9c2e Bump Wasmtime to 0.25.0; Cranelift to 0.72.0 2021-03-16 11:02:56 -07:00
Dan Gohman
2d3f2adf04 Fix nondeterministic failures in poll_oneoff_stdio.
Adjust this test so that it tolerates poll_oneoff returning that both a
timeout occurred and an input is ready for reading, at the same time.
2021-03-15 11:48:19 -07:00
Alex Crichton
2697a18d2f Redo the statically typed Func API (#2719)
* Redo the statically typed `Func` API

This commit reimplements the `Func` API with respect to statically typed
dispatch. Previously `Func` had a `getN` and `getN_async` family of
methods which were implemented for 0 to 16 parameters. The return value
of these functions was an `impl Fn(..)` closure with the appropriate
parameters and return values.

There are a number of downsides with this approach that have become
apparent over time:

* The addition of `*_async` doubled the API surface area (which is quite
  large here due to one-method-per-number-of-parameters).
* The [documentation of `Func`][old-docs] are quite verbose and feel
  "polluted" with all these getters, making it harder to understand the
  other methods that can be used to interact with a `Func`.
* These methods unconditionally pay the cost of returning an owned `impl
  Fn` with a `'static` lifetime. While cheap, this is still paying the
  cost for cloning the `Store` effectively and moving data into the
  closed-over environment.
* Storage of the return value into a struct, for example, always
  requires `Box`-ing the returned closure since it otherwise cannot be
  named.
* Recently I had the desire to implement an "unchecked" path for
  invoking wasm where you unsafely assert the type signature of a wasm
  function. Doing this with today's scheme would require doubling
  (again) the API surface area for both async and synchronous calls,
  further polluting the documentation.

The main benefit of the previous scheme is that by returning a `impl Fn`
it was quite easy and ergonomic to actually invoke the function. In
practice, though, examples would often have something akin to
`.get0::<()>()?()?` which is a lot of things to interpret all at once.
Note that `get0` means "0 parameters" yet a type parameter is passed.
There's also a double function invocation which looks like a lot of
characters all lined up in a row.

Overall, I think that the previous design is starting to show too many
cracks and deserves a rewrite. This commit is that rewrite.

The new design in this commit is to delete the `getN{,_async}` family of
functions and instead have a new API:

    impl Func {
        fn typed<P, R>(&self) -> Result<&Typed<P, R>>;
    }

    impl Typed<P, R> {
        fn call(&self, params: P) -> Result<R, Trap>;
        async fn call_async(&self, params: P) -> Result<R, Trap>;
    }

This should entirely replace the current scheme, albeit by slightly
losing ergonomics use cases. The idea behind the API is that the
existence of `Typed<P, R>` is a "proof" that the underlying function
takes `P` and returns `R`. The `Func::typed` method peforms a runtime
type-check to ensure that types all match up, and if successful you get
a `Typed` value. Otherwise an error is returned.

Once you have a `Typed` then, like `Func`, you can either `call` or
`call_async`. The difference with a `Typed`, however, is that the
params/results are statically known and hence these calls can be much
more efficient.

This is a much smaller API surface area from before and should greatly
simplify the `Func` documentation. There's still a problem where
`Func::wrapN_async` produces a lot of functions to document, but that's
now the sole offender. It's a nice benefit that the
statically-typed-async verisons are now expressed with an `async`
function rather than a function-returning-a-future which makes it both
more efficient and easier to understand.

The type `P` and `R` are intended to either be bare types (e.g. `i32`)
or tuples of any length (including 0). At this time `R` is only allowed
to be `()` or a bare `i32`-style type because multi-value is not
supported with a native ABI (yet). The `P`, however, can be any size of
tuples of parameters. This is also where some ergonomics are lost
because instead of `f(1, 2)` you now have to write `f.call((1, 2))`
(note the double-parens). Similarly `f()` becomes `f.call(())`.

Overall I feel that this is a better tradeoff than before. While not
universally better due to the loss in ergonomics I feel that this design
is much more flexible in terms of what you can do with the return value
and also understanding the API surface area (just less to take in).

[old-docs]: https://docs.rs/wasmtime/0.24.0/wasmtime/struct.Func.html#method.get0

* Rename Typed to TypedFunc

* Implement multi-value returns through `Func::typed`

* Fix examples in docs

* Fix some more errors

* More test fixes

* Rebasing and adding `get_typed_func`

* Updating tests

* Fix typo

* More doc tweaks

* Tweak visibility on `Func::invoke`

* Fix tests again
2021-03-11 14:43:34 -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
Andrew Brown
44e76fe9c0 Update spec tests (#2690)
* Update wasm-tools crates

* Update Wasm SIMD spec tests

* Invert 'experimental_x64_should_panic' logic

By doing this, it is easier to see which spec tests currently panic. The new tests correspond to recently-added instructions.

* Fix: ignore new spec tests for all backends
2021-03-01 16:39:20 -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
9abae356e0 fix! 2021-02-10 16:54:14 -08:00
Pat Hickey
bc95864202 wasi-tests: add path_exists test
this *should* reproduce the report at
https://github.com/bytecodealliance/wasmtime/issues/2642 but it does
not, so the problem has something to do with invoking via wasmtime cli?
2021-02-10 16:54:14 -08:00
Pat Hickey
e4ce04bab4 WasiCtx: default to empty/sink stdio files rather than throw
the test harness now uses the empty stdin file. I tested manually that
the sink stdout & stderr files work, but theres no test in tree at the
moment
2021-02-05 17:50:20 -08:00
Pat Hickey
72a8f9235d cap-primitives bump fixes windows bugs 2021-02-03 17:35:07 -08:00
Pat Hickey
c8ca639b93 new cap-std apis fix some windows tests!
fix for fd_readdir test on linux, and symlink_create / nofollow_errors
2021-02-03 16:16:23 -08:00
Pat Hickey
e670c46862 system-interface 0.6 2021-02-03 16:07:05 -08:00
Pat Hickey
bc1992b9a8 cap-std 0.13 2021-02-03 15:46:03 -08:00
Pat Hickey
31145060b2 remove virtfs - it is not suitable for use 2021-02-03 15:04:02 -08:00
Pat Hickey
7a35763d62 collapse two test flags into dangling_filesystem 2021-02-03 14:54:42 -08:00
Pat Hickey
857ef411b5 upstream fixes are pending for symlink_create & nofollow_errors on windows 2021-02-02 16:23:57 -08:00
Pat Hickey
cd02e5a942 path_rename: make more concessions for windows. this shit sucks but oh well 2021-02-02 15:30:02 -08:00
Pat Hickey
80fce7c1c8 unlink behavior on macos... 2021-02-01 19:22:10 -08:00
Pat Hickey
e3850752b2 this windows test should be fixed... 2021-02-01 18:37:42 -08:00
Pat Hickey
c77a11bd5c tests: macos-specific behavior 2021-02-01 18:30:58 -08:00
Pat Hickey
848be8c932 path_rename should work on windows with TESTCONFIG 2021-02-01 15:50:16 -08:00
Pat Hickey
bb3e391a27 accept fdread event as valid behavior of stdin poll 2021-02-01 15:26:06 -08:00
Pat Hickey
0c4aec391e actually empty ready bytes of stdin 2021-02-01 14:43:32 -08:00
Pat Hickey
b9a3f8694d cap-std-sync test runner: read stdin to end before inheriting stdio 2021-02-01 14:32:51 -08:00
Pat Hickey
40e541bfc3 test suite: cap-std-sync test environment does not support fdflags sync 2021-02-01 14:25:42 -08:00
Pat Hickey
5ee093e774 Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2021-02-01 13:21:25 -08:00
Peter Huene
0502cadc62 Stop allowing bufused > BUF_LEN in fd_readdir program.
This commit removes what appears to be a workaround to the bug being fixed by
the change in #2620.
2021-02-01 11:41:29 -08:00
Pat Hickey
bad169dde3 port https://github.com/bytecodealliance/wasmtime/pull/2620 into rewrite 2021-02-01 11:10:26 -08:00
Pat Hickey
92e1949944 doh 2021-02-01 11:01:41 -08:00
Pat Hickey
ac60b034f0 well this much passes 2021-01-30 13:58:30 -08:00
Pat Hickey
321bf27292 check in virtfs backend test harness 2021-01-30 13:45:21 -08:00
Pat Hickey
fcecb3fea6 test-programs: test both cap-std-sync and virtfs backend 2021-01-30 13:39:18 -08:00