Commit Graph

1407 Commits

Author SHA1 Message Date
Pat Hickey
86d369c72a inline poll from yanix 2021-01-21 18:17:49 -08:00
Pat Hickey
9e0d295f8c use unsafe to mark reopen_with_fdflags as having special safety features 2021-01-21 18:08:15 -08:00
Pat Hickey
69b7352332 various stdio fixes 2021-01-21 17:57:12 -08:00
Pat Hickey
f1a5dce716 change set_fdflags to reopen_with_fdflags 2021-01-21 17:56:03 -08:00
Pat Hickey
a46c2ad0aa split poll tests up, only one requires "real" stdio 2021-01-21 16:54:40 -08:00
Pat Hickey
12056885eb fix preopen dir to work on windows 2021-01-21 16:08:49 -08:00
Chris Fallin
c84d6be6f4 Detailed debug-info (DWARF) support in new backends (initially x64).
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:

- Translate value-label metadata on the input into "value_label"
  pseudo-instructions when lowering into VCode. These
  pseudo-instructions take a register as input, denote a value label,
  and semantically are like a "move into value label" -- i.e., they
  update the current value (as seen by debugging tools) of the given
  local. These pseudo-instructions emit no machine code.

- Perform a dataflow analysis *at the machine-code level*, tracking
  value-labels that propagate into registers and into [SP+constant]
  stack storage. This is a forward dataflow fixpoint analysis where each
  storage location can contain a *set* of value labels, and each value
  label can reside in a *set* of storage locations. (Meet function is
  pairwise intersection by storage location.)

  This analysis traces value labels symbolically through loads and
  stores and reg-to-reg moves, so it will naturally handle spills and
  reloads without knowing anything special about them.

- When this analysis converges, we have, at each machine-code offset, a
  mapping from value labels to some number of storage locations; for
  each offset for each label, we choose the best location (prefer
  registers). Note that we can choose any location, as the symbolic
  dataflow analysis is sound and guarantees that the value at the
  value_label instruction propagates to all of the named locations.

- Then we can convert this mapping into a format that the DWARF
  generation code (wasmtime's debug crate) can use.

This PR also adds the new-backend variant to the gdb tests on CI.
2021-01-21 15:59:49 -08:00
Pat Hickey
16b42a5707 fix 2021-01-21 14:14:05 -08:00
Pat Hickey
85c3b73b4e stdio compiles on windows! 2021-01-21 13:51:18 -08:00
Alex Crichton
4a351ab7fe Update a number of dependencies (#2594)
This commit goes through the dependencies that wasmtime has and updates
versions where possible. This notably brings in a wasmparser/wast update
which has some simd spec changes with new instructions. Otherwise most
of these are just routine updates.
2021-01-21 15:49:13 -06:00
Alex Crichton
57c686d49d Refactor instantiation to be more async-friendly (#2596)
Instantiation right now uses a recursive `instantiate` function since it
was relatively easy to write that way, but this is unfortunately not
factored in a way friendly to the async implementation in #2434. This
commit refactors the function to instead use an iterative loop and
refactors code in such a way that it should be easy to rebase #2434 on
top of this change. The main goal is to make the body of `Instance::new`
as small as possible since it needs to be duplicated with
`Instance::new_async`.
2021-01-21 15:04:17 -06:00
Pat Hickey
fcd00f5de1 move more deps to cap-std-sync, define own SystemTimeSpec 2021-01-21 12:35:55 -08:00
Alex Crichton
8748cf5bd3 Add an instance limit to Config (#2593)
* Add an instance limit to `Config`

This commit adds a new parameter to `Config` which limits the number of
instances that can be created within a store connected to that `Config`.
The intention here is to provide a default safeguard against
module-linking modules that recursively create too many instances.

* Update crates/c-api/include/wasmtime.h

Co-authored-by: Peter Huene <peter@huene.dev>

Co-authored-by: Peter Huene <peter@huene.dev>
2021-01-21 11:59:30 -06:00
Andronik Ordian
2d5037d84c cache: update zstd to 0.6, disable legacy feature (#2592) 2021-01-21 10:16:07 -06:00
Alex Crichton
207f60a18e module-linking: Implement outer module aliases (#2590)
This commit fully implements outer aliases of the module linking
proposal. Outer aliases can now handle multiple-level-up aliases and now
properly also handle closed-over-values of modules that are either
imported or defined.

The structure of `wasmtime::Module` was altered as part of this commit.
It is now a compiled module plus two lists of "upvars", or closed over
values used when instantiating the module. One list of upvars is
compiled artifacts which are submodules that could be used. Another is
module values that are injected via outer aliases. Serialization and
such have been updated as appropriate to handle this.
2021-01-21 09:21:30 -06:00
Pat Hickey
61885b7071 stub in windows scheduler, get to some interesting errors 2021-01-20 21:03:33 -08:00
Pat Hickey
7ec03631da inline only what we need of cap-std/system-interface traits 2021-01-20 20:53:44 -08:00
Pat Hickey
f3e40e2fc4 restructure cap-std impls into their own crate 2021-01-20 19:09:15 -08:00
Pat Hickey
016ed8966a poll now handles monotonic clocks, not system clocks
I initially had it backwards. It is not sensible to poll on a system
clock timeout because the system clock is not necessarily monotonic!
only a monotonic clock makes sense for a timeout.
2021-01-19 15:11:54 -08:00
Pat Hickey
21713d3468 Revert "TEMPORARY: poll_oneoff test uses CLOCKID_REALTIME instead of MONOTONIC"
This reverts commit f667263d9c.
2021-01-19 14:57:10 -08:00
Pat Hickey
657024bd0d latest system-interface provides ReadReady::num_ready_bytes 2021-01-19 14:39:20 -08:00
Han Zhao
d37e2d53c7 Updated libc version to 0.2.82 in dependencies 2021-01-19 19:11:32 +01:00
Han Zhao
f8268b2139 Bugfix of issue #2575
Bugfix of issue #2575.

Use libc 0.2.82 on aarch64-apple-darwin Apple Silicon, and local test passes.
2021-01-19 17:08:11 +01:00
Pat Hickey
7f7a0be938 wasi-c2: implement a synchronous poll_oneoff in terms of yanix
doesnt work on unix yet! also breaks all the rules about using the
cap-std family instead of rawfds! but this is cool and im happy with it
2021-01-14 17:43:53 -08:00
Pat Hickey
b84c4d7488 poll_oneoff test: if you subscribe to a badf, the whole call fails with badf
rather than the results telling you an individual file was a badf.

why? i think the old behavior was too clever, and makes it harder to
write a scheduler.

* what should the call do when you pass it some badf and some not-badf?
i don't think anything besides exiting early is the correct answer.
* the results vector tells you something that the scheduler had to say
about the file, not about your inputs. the errno of the function
always says what the validity of the inputs was
2021-01-14 17:41:27 -08:00
Pat Hickey
f667263d9c TEMPORARY: poll_oneoff test uses CLOCKID_REALTIME instead of MONOTONIC
the scheduler does not support the monotonic clock yet, i will fix this
soon
2021-01-14 17:40:56 -08:00
Pat Hickey
7d7acc4614 poll_oneoff test: outline assertions
this makes the panic message have the line number, which
is handy
2021-01-14 17:40:04 -08:00
Pat Hickey
9a1ce1a272 TEMPORARY: inherit stdio for the wasi ctx
this is unfortunate but the poll_oneoff test insists on polling on stdio
handles. to undo this temporary fix later, lets rewrite the test to open
some regular files from the scratch directory and poll on them instead.
2021-01-14 17:38:43 -08:00
Alex Crichton
d66db16d00 Fix a doc link 2021-01-14 14:38:05 -08:00
Alex Crichton
bc9f10115d Fix a typo 2021-01-14 14:37:44 -08:00
Pat Hickey
4b39a14163 fix tests in pipe 2021-01-14 14:14:41 -08:00
Pat Hickey
5c8efe868e need Any on WasiFile to upcast for AsRawFd 2021-01-14 13:39:01 -08:00
Alex Crichton
703762c49e Update support for the module linking proposal
This commit updates the various tooling used by wasmtime which has new
updates to the module linking proposal. This is done primarily to sync
with WebAssembly/module-linking#26. The main change implemented here is
that wasmtime now supports creating instances from a set of values, nott
just from instantiating a module. Additionally subtyping handling of
modules with respect to imports is now properly handled by desugaring
two-level imports to imports of instances.

A number of small refactorings are included here as well, but most of
them are in accordance with the changes to `wasmparser` and the updated
binary format for module linking.
2021-01-14 10:37:39 -08:00
Alex Crichton
55c5424e0e Adjust wasmtime_func_callback_* type signature
This aligns the C header with what we have in the crate itself, in
addition to matching what's in `wasm.h`.
2021-01-14 08:57:15 -08:00
Peter Huene
f94db6556c Update WebAssembly C API submodule to latest commit. (#2579)
* Update WebAssembly C API submodule to latest commit.

This commit updates the WebAssembly C API submodule (for `wasm.h`) to the
latest commit out of master.

This fixes the behavior of `wasm_name_new_from_string` such that it no longer
copies the null character into the name, which caused unexpected failures when
using the Wasmtime linker as imports wouldn't resolve when the null was
present.

Along with this change were breaking changes to `wasm_func_call`, the host
callback signatures, and `wasm_instance_new` to take a vector type instead of a
pointer to an unsized array.

As a result, Wasmtime language bindings based on the C API will need to be
updated once this change is pulled in.

Fixes #2211.
Fixes #2131.

* Update Doxygen comments for wasm.h changes.
2021-01-14 09:36:12 -06:00
Pat Hickey
ea94d6f79d this is indeed a nice way to do refs! 2021-01-13 15:11:11 -08:00
Pat Hickey
7beb52a2bc i guess this is a way to do refs 2021-01-13 14:23:59 -08:00
Pat Hickey
8298ce9e4d clock sub, start with the read sub 2021-01-13 11:57:42 -08:00
Pat Hickey
e0e205f8d2 ctx builder: fix warnings, test harness 2021-01-13 11:07:06 -08:00
Léo Gaspard
932378eb7b reexport all the things required to implement WasiDir 2021-01-13 05:18:36 +01:00
Léo Gaspard
20bb4b211e Also reexport Error from wasmtime_wasi 2021-01-13 05:10:28 +01:00
Léo Gaspard
5d85216329 also reexport WasiDir from wasmtime_wasi 2021-01-13 05:05:37 +01:00
Léo Gaspard
2e035be60a make WasiCtxBuilder be an actual builder, allowing to call .build() at the end of a call chain 2021-01-13 04:57:16 +01:00
Léo Gaspard
f3156114c4 reserve keys 0, 1 and 2 for stdio 2021-01-13 04:24:02 +01:00
Léo Gaspard
7303793fa0 also expose WasiCtxBuilder 2021-01-13 04:10:12 +01:00
Pat Hickey
81065eba38 more scheduler 2021-01-12 17:42:59 -08:00
Pat Hickey
b79bdcee84 port subscriptions in from old branch 2021-01-12 15:55:25 -08:00
Nick Fitzgerald
bc6dc083f0 wasmtime-bench-api: Randomize the locations of heap objects
This helps us avoid measurement bias due to accidental locality of unrelated
heap objects. See *Stabilizer: Statistically Sound Performance Evaluation* by
Curtsinger and Berger for details (although Stabilizer deals with much more than
just the location of heap allocations):
https://people.cs.umass.edu/~emery/pubs/stabilizer-asplos13.pdf
2021-01-12 15:43:26 -08:00
Pat Hickey
0e42c2e1d9 scaffold a scheduler 2021-01-12 12:07:00 -08:00
Pat Hickey
32f162aa78 fix windows flags 2021-01-12 09:51:09 -08:00