4932 Commits

Author SHA1 Message Date
Ivan Enderlin
c97122899d feat(interface-types) Start implementing the WAT decoder. 2020-02-19 16:12:06 +01:00
Syrus Akbary
a21cf6d4c3
Added link to a custom ABI example repo
https://github.com/wasmerio/wasmer-rust-customabi-example
2020-02-16 12:48:20 -08:00
bors[bot]
32991e676e
Merge #1218
1218: Enable clif verifier in debug mode, fix issue with verifier r=MarkMcCaskey a=MarkMcCaskey

Ensures we're using I32s to index into things that are indexed by I32s

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
2020-02-14 19:47:20 +00:00
Mark McCaskey
23275d07f6 Improve clif verifier error message 2020-02-14 11:45:11 -08:00
Mark McCaskey
5e3147db08 Enable clif verifier in debug mode, fix issue with verifier 2020-02-14 11:32:49 -08:00
Syrus Akbary
8faac62bc0
Merge pull request #1215 from Hywan/fix-interface-types-dbg
fix(interface-types) Remove a `dbg!` macro
2020-02-14 08:37:49 -08:00
Ivan Enderlin
0c4c9107d5 fix(interface-types) Remove a dbg! macro. 2020-02-14 12:19:29 +01:00
Syrus Akbary
07c8eff47f
Use wapm packages last after $PATH 2020-02-14 00:16:32 -08:00
bors[bot]
f4829c7fe5
Merge #1209
1209: Maybe improve safety of MemoryView Deref r=MarkMcCaskey a=MarkMcCaskey

Possibly slightly better... (effectively does exactly the same thing the same way):

Notably this code still violates the safety rules of its unsafe functions:

It violates rule 2 from https://doc.rust-lang.org/std/slice/fn.from_raw_parts_mut.html :

> The memory referenced by the returned slice must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime ’a. Both read and write accesses are forbidden.


Some comments in the stdlib indicate that casting between `Cell<T>` and `T` isn't something that's safe to do outside of the stdlib 🤷‍♂ .

Fundamentally, `MemoryView` is unsound.  Our docs say that it does not have undefined behavior, but we don't properly justify that.   I believe it relies very heavily on undefined behavior.

Looking for feedback here about what we can do.  It seems like we'll have to break the public API to make a sound API... if we can decide on a sufficiently good one, we can deprecate the old one and roll out the new one to prevent user breakage.

We may need to use something like https://docs.rs/crossbeam/0.7.3/crossbeam/atomic/struct.AtomicCell.html or implement something like it.

Where I'm at in regards to memory access from the host is that it's not possible to make any kind of efficient API that is not entirely `unsafe`.  Even given that, we need to figure out the bounds with which the `unsafe` functions can be used relatively safely.  I think even if we marked our existing functions as `unsafe`, it's too complex to figure out whether or not you're using it correctly...

Bonus points if your solution works across multiple threads properly...

# Review

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
2020-02-14 00:13:48 +00:00
Mark McCaskey
c8e3a0925b
Merge branch 'master' into feature/changed-memory-view 2020-02-13 16:04:43 -08:00
bors[bot]
7dbe357e89
Merge #1214
1214: test(interface-types) Add `wasmer-interface-types` to `make check` r=MarkMcCaskey a=Hywan

Sequel of #787. Forgot to update the changelog, and to add `wasmer-interface-types` to `make check`.

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
2020-02-13 19:02:21 +00:00
Mark McCaskey
344bf0716c
Merge branch 'master' into test-interface-types 2020-02-13 11:01:57 -08:00
bors[bot]
1d3ae6a00e
Merge #1213
1213: Fixed WASI isatty r=syrusakbary a=syrusakbary

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description

Current WASI implementation returns a wrong response when libc `isatty` is used for `stdin`, `stdout` or `stderr`.

This PR fixes it.

<!-- 
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Syrus <me@syrusakbary.com>
Co-authored-by: Syrus Akbary <me@syrusakbary.com>
2020-02-13 18:42:30 +00:00
Syrus Akbary
7a45bd8a39
Merge branch 'master' into fix/isatty 2020-02-13 10:42:09 -08:00
Syrus
60e686ff76 Added change into changelog 2020-02-13 10:37:27 -08:00
Syrus
61c85b3fbf Improved fd_write debugging 2020-02-13 10:35:48 -08:00
Syrus
c287170166 Fixed wasi isatty tests when being generated 2020-02-13 10:33:27 -08:00
Ivan Enderlin
07ba2c82b9 test(interface-types) Add wasmer-interface-types to make check. 2020-02-13 15:38:35 +01:00
Ivan Enderlin
2e2c5ab9c1 doc(changelog) Add #787. 2020-02-13 15:38:21 +01:00
bors[bot]
16245c6bd2
Merge #787
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>
2020-02-13 13:41:32 +00:00
Ivan Enderlin
c697e6812f Merge branch 'master' into feat-interface-types 2020-02-13 14:40:46 +01:00
Ivan Enderlin
7f8d9165d4 fix(interface-types) Clean up cargo features. 2020-02-13 14:38:05 +01:00
Ivan Enderlin
eb2f9db230 feat(interface-types) Forbids unsafe code. 2020-02-13 14:36:17 +01:00
Ivan Enderlin
9559747394 doc(interface-types) Add #[deny(missing_docs)]. 2020-02-13 14:34:45 +01:00
Ivan Enderlin
ae6e26158f chore(interface-types) Simplify code. 2020-02-13 14:26:50 +01:00
Ivan Enderlin
6891517c8b chore(encoders) Changing unimplemented!() to todo!(). 2020-02-13 14:24:07 +01:00
Ivan Enderlin
13cee90d17 feat(encoders) Implement ToString instead of From<…> for String. 2020-02-13 14:19:31 +01:00
Ivan Enderlin
722727bd56 chore(decoders) Simplify code. 2020-02-13 13:56:30 +01:00
Ivan Enderlin
d8f923091f chore(decoders) Simplify code. 2020-02-13 13:54:26 +01:00
Ivan Enderlin
3f0c32bf44 fix(decoders) Remove the unsafe block in the string parser.
Instead of using `str::from_utf8_unchecked`, this patch updates the
code to use `str::from_utf8` and handles the error appropriately.
2020-02-13 13:52:23 +01:00
Ivan Enderlin
370fd6d866 feat(decoders) Improve LEB parser in the binary module.
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.
2020-02-13 13:36:18 +01:00
Ivan Enderlin
1ad42d81cb doc(interface-types) Improve documentation of decoders::binary::leb. 2020-02-13 11:41:02 +01:00
Ivan Enderlin
b7941f4019 feat(interface-types) Ensure ast::Type is always well-formed.
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.
2020-02-13 11:24:29 +01:00
Syrus
62e1526037 Fixed WASI isatty 2020-02-12 23:00:30 -08:00
Ivan Enderlin
13b9cb3995 doc(interface-types) Improve the documentation of the interpreter module. 2020-02-12 17:37:06 +01:00
Ivan Enderlin
6b0e43b7c4 doc(interface-types) Improve the documentation of the instruction module. 2020-02-12 16:01:33 +01:00
Ivan Enderlin
b3c102da37 doc(interface-types) Improve documentation of the instruction module.
Also, rename `RepeatWhile` to `RepeatUntil`.
2020-02-12 15:59:41 +01:00
Ivan Enderlin
98c73099c3 doc(interface-types) Improve documentation of the macros module. 2020-02-12 15:52:15 +01:00
Mark McCaskey
93dcb63348 Maybe improve safety of MemoryView Deref 2020-02-11 14:13:25 -08:00
bors[bot]
f2d9a49e3f
Merge #1208
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>
2020-02-11 21:54:49 +00:00
Mark McCaskey
132645e0d0 Fix trap handling bug on Windows and add test 2020-02-11 13:24:26 -08:00
bors[bot]
3fb5f548ab
Merge #1191
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>
2020-02-11 19:00:08 +00:00
losfair
2f4e9b1fe3 Update changelog. 2020-02-12 02:56:12 +08:00
losfair
c6861d1827 Merge remote-tracking branch 'origin/master' into fix/singlepass-indirect-call 2020-02-12 02:55:48 +08:00
losfair
01e570d60a Add test for PR 1191. 2020-02-12 02:54:27 +08:00
bors[bot]
df268cff0e
Merge #1207
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>
2020-02-11 18:43:12 +00:00
Mark McCaskey
491ba27528 Update Rust version used to build docs to be consistent 2020-02-11 10:41:17 -08:00
losfair
5ca6c22cbf Merge remote-tracking branch 'origin/master' into fix/singlepass-indirect-call 2020-02-12 02:28:25 +08:00
bors[bot]
eaa081e359
Merge #1192
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>
2020-02-11 18:15:50 +00:00
losfair
3999728e39 Merge remote-tracking branch 'origin/master' into feature/remove-wasm-trap-info 2020-02-12 02:14:30 +08:00