787: feat(interface-types) Implement Interface Types (WIT) r=Hywan a=Hywan
So far, this PR implements a new crate named `wasmer-interface-types`. The goal is to implement the WebAssembly Interface Types (WIT) proposal, https://github.com/WebAssembly/interface-types. Keep in mind the proposal is highly unstable and experimental.
The `wasmer-interface-types` is designed to be _runtime agnostic_, which means that there is no connection between this crate and `wasmer-runtime-core` or `wasmer-runtime` (or any backend crates). The hope is that other runtimes could use `wasmer-interface-types` according to their needs.
The `wasmer-interface-types` is composed of 4 parts:
* AST: [The WIT language, represented as an AST](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/ast.rs) (it's not really abstract though),
* Decoders: So far, it contains only [one parser that reads the WIT binary language](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/decoders/binary.rs) and produces an AST,
* Encoders: So far, it contains only [one compiler that transforms the AST into "WIT.wat”](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/encoders/wat.rs), i.e. the textual representation of an Interface Types AST
* Instructions: WIT defines a new concept called Adapters. An adapter contains a set of instructions. Those instructions are executed when data are bound. So, in more details, this module contains:
* [`interpreter.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/mod.rs), a stack-based interpreter, defined by:
* A compiler that transforms a set of instructions into a set of _executable_ instructions,
* A stack,
* A runtime that holds the “invocation inputs” (arguments of the interpreter), the stack, and the Wasm instance (which holds the exports, the imports, the memories, the tables etc.),
* [`stack.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/stack.rs), a very light and generic stack implementation, exposing only the API required by the interpreter,
* [`wasm/*.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/wasm/structures.rs), a set of enums, types, and traits to represent a Wasm runtime —basically this is the part a runtime should take a look to support the `wasmer-interface-types` crate—.
Progression:
* [x] WIT binary parser,
* [x] WIT.wat compiler,
* [ ] Interpreter:
* [ ] Wasm runtime traits to represent:
* [x] Instance,
* [x] Export,
* [x] Memory,
* [x] Import,
* [ ] Table,
* [x] Generic stack implementation,
* [ ] Implemented instructions:
* [x] `arg.get`,
* [x] `call`,
* [x] `call-export`,
* [x] `read-utf8`,
* [x] `write-utf8`,
* [ ] `as-wasm`,
* [ ] `as-interface`
* [ ] `table-ref-add`
* [ ] `table-ref-get`
* [ ] `call-method`
* [ ] `make-record`
* [ ] `get-field`
* [ ] `const`
* [ ] `fold-seq`
* [ ] `add`
* [ ] `mem-to-seq`
* [ ] `load`
* [ ] `seq.new`
* [ ] `list.push`
* [ ] `repeat-until`
* [ ] `seq-to-mem`
* [ ] `store`
* [ ] Plug `wasmer-interface-types` into `wasmer-runtime-core`
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
The LEB parser is renamed `uleb`. It now checks for overflow, and
badly-formed bits, resp. `TooLarge` or `Eof`. More test cases are
added, whose from the DWARF 4 standard.
As @MarkMcCaskey noted, `Type` can be corrupted because `field_names`
and `field_types` must have the same length. This patch removes the
public visibility, and adds methods like `new`, `add_field`,
`field_names` and `field_types` to encapsulate `Type` internal data.
1208: Fix trap handling bug on Windows and add test r=MarkMcCaskey a=MarkMcCaskey
Resolves#1204
# Review
- [ ] Add a short description of the the change to the CHANGELOG.md file
Co-authored-by: Mark McCaskey <mark@wasmer.io>
1191: Fix singlepass miscompilation on `Operator::CallIndirect`. r=losfair a=losfair
This fixes the 3 failing tests mentioned in https://00f.net/2019/10/22/updated-webassembly-benchmark/ .
(TODO: Add test cases?)
Co-authored-by: losfair <zhy20000919@hotmail.com>
1207: Update Rust version used to build docs to be consistent r=syrusakbary a=MarkMcCaskey
In response to #1196
Co-authored-by: Mark McCaskey <mark@wasmer.io>
1192: Use `ExceptionCode` for error representation. r=losfair a=losfair
Extends https://github.com/wasmerio/wasmer/pull/1129 to all backends.
Co-authored-by: losfair <zhy20000919@hotmail.com>
1202: doc(runtime-c-api) Improve documentation of the `memory` module r=syrusakbary a=Hywan
Address https://github.com/wasmerio/wasmer/issues/1203.
As part of the daily doc routine, this patch improves the documentation of `memory` module.
This patch also handles more null pointers.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>