Commit Graph

1149 Commits

Author SHA1 Message Date
Nick Fitzgerald
e594c43d50 Merge pull request #2606 from fitzgen/memory-stuff
wasmtime: clarify `Memory::{read,write}` behavior with out-of-bounds ranges
2021-01-26 11:57:42 -08:00
Nick Fitzgerald
ee5c6f6265 Merge pull request #2599 from fitzgen/bench-api-files-env-vars
bench-api: Allow access to files in the current directory
2021-01-26 10:35:03 -08:00
Nick Fitzgerald
4f3bc1d5d4 wasmtime: clarify Memory::{read,write} behavior with out-of-bounds ranges
This documents that we will never do partial reads/writes, and expands our
existing tests to assert this.
2021-01-26 10:27:21 -08:00
Nick Fitzgerald
0cdc80fbf8 wasmtime: move Memory to its own module
Purely code motion and fixing up imports.
2021-01-26 10:04:48 -08:00
Nick Fitzgerald
3b7f3e0c23 Remove semicolon to quiet a rustc warning 2021-01-26 09:43:53 -08:00
Nick Fitzgerald
8d84482153 bench-api: Allow access to files in the current directory
And pass through the `WASM_BENCH_USE_SMALL_WORKLOAD` env var.

Part of https://github.com/bytecodealliance/sightglass/issues/70
2021-01-26 09:43:53 -08:00
Nick Fitzgerald
c7c6e76f9b fuzzing: Add tests for dummy import generation (#2604) 2021-01-26 09:11:24 -06:00
theduke
f4faa04dca Safe Memory read/write API (#2528)
This commit introduces two new methods on `Memory` that enable
reading and writing memory contents without requiring `unsafe`.

The methods return a new `MemoryError` if the memory access
fails.
2021-01-26 09:09:20 -06:00
Frank Denis
a0fad6065a Add support for the experimental wasi-crypto APIs (#2597)
* Add support for the experimental wasi-crypto APIs

The sole purpose of the implementation is to allow bindings and
application developers to test the proposed APIs.

Rust and AssemblyScript bindings are also available as examples.

Like `wasi-nn`, it is currently disabled by default, and requires
the `wasi-crypto` feature flag to be compiled in.

* Rename the wasi-crypto/spec submodule

* Add a path dependency into the submodule for wasi-crypto

* Tell the publish script to vendor wasi-crypto
2021-01-25 09:32:58 -06:00
Chris Fallin
95822a54f2 Merge pull request #2565 from cfallin/debug-value-labels
Detailed debug-info (DWARF) support in new backends (initially x64).
2021-01-22 17:22:13 -08:00
Chris Fallin
f54d0d05c7 Address review comments. 2021-01-22 16:02:29 -08:00
Alex Crichton
55b0e8b9e5 Fix C API function name of setting max instances (#2598)
Forgot the trailing `_set` at the end...
2021-01-22 09:55:28 -06: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
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
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
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
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
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
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
32f162aa78 fix windows flags 2021-01-12 09:51:09 -08:00
Pat Hickey
75a9dc7fe2 wasi-common: wiggle flags are now bitflags!
this mostly mechanical change is just getting rid of passing to
`contains` by reference.
2021-01-11 18:27:55 -08:00
Pat Hickey
ed44a19e5e wiggle: use bitflags to generate flags
more consistient with the rest of the ecosystem.
2021-01-11 18:20:57 -08:00
Pat Hickey
e2fb99af86 wiggle: depend on bitflags, and re-export it. 2021-01-11 18:04:43 -08:00
Pat Hickey
94467bcd9a wiggle: bugfix, generated code should use Names::runtime_mod not wiggle
as the crate from which these deps come.

I worked around this in lucet, but I'll be able to revert that
workaround.
2021-01-11 18:03:48 -08:00
Nick Fitzgerald
3068d55fa1 wasi-nn: Fix keyword form in Cargo.toml metadata
Keywords may not have spaces, apparently.
2021-01-11 10:46:00 -08:00
Andrew Brown
2adb0e8964 security: upgrade smallvec to 1.6.1
Fixes advisory https://rustsec.org/advisories/RUSTSEC-2021-0003.
2021-01-08 16:54:54 -08:00
Yury Delendik
3580205f12 [Cranelift][Atomics] Add address folding for atomic notify/wait. (#2556)
* fold address in wasm wait and notify ops

* add atomics addr folding tests
2021-01-08 11:55:21 -06: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
Pat Hickey
539058b329 fix windows 2021-01-07 14:57:18 -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
b149a03d5d wasi-common: instead of panicking, use an Error::Unsupported that Traps 2021-01-07 14:05:49 -08:00
Pat Hickey
07c9b65fa4 fix 2021-01-07 11:45:11 -08:00
Pat Hickey
ec1bfeefb3 fix tests 2021-01-07 11:45:11 -08:00
Pat Hickey
cd3adb1abd Trap::I32Exit is a better name 2021-01-07 11:45:11 -08:00
Pat Hickey
1dab7c8f94 wasi submodule: noreturn annotations are merged into main 2021-01-07 11:45:11 -08:00
Pat Hickey
2483ad4c1c wasi-nn: UserErrorConversion error is now a wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
745c592863 readme: expand wiggle docs 2021-01-07 11:45:11 -08:00
Pat Hickey
4a574c14eb wasi-common: port to use wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
1c7c18b026 WASI submodule: mark proc_exit funcs as noreturn in the witx 2021-01-07 11:45:11 -08:00
Pat Hickey
f8f9b14c6f wiggle: introduce wiggle::Trap, which can be either a String or I32
also, make noreturn functions always return a Trap

wasmtime-wiggle can trivially turn a wiggle::Trap into a wasmtime::Trap.
lucet will have to do the same.
2021-01-07 11:45:11 -08:00
Léo Gaspard
c0c4834c64 wasi-nn: rebuild if the witx files change 2021-01-06 15:56:46 -08:00
Pat Hickey
d4aaae3e86 wasi-nn: remove missing_memory from wasmtime_integration 2021-01-06 10:59:29 -08:00
Pat Hickey
bf2371c8af wasi: get rid of missing_memory config 2021-01-05 17:29:34 -08:00