1
0
mirror of https://github.com/fluencelabs/wasmer synced 2025-03-17 00:30:49 +00:00

474 Commits

Author SHA1 Message Date
Mark McCaskey
4c29cd4af3 Merge branch 'master' into feature/reorganized-tests 2020-04-06 12:04:36 -07:00
bors[bot]
4d33020b35
Merge
1331: feat(interface-types) Implement the `record` instructions r=Hywan a=Hywan

### Description

This PR implements the `record` WIT type, along with the `record.lift` and `record.lower` instructions.

With my current understanding of the draft/specification, here is how it works. Let's say we want to represent a Rust struct like the following:

```rust
struct S {
    x: String,
    y: i32
}
```

First declare a WIT type, such as:

```wat
(@interface type (record (field string) (field i32)))
```

The `record` type is supported by the binary encoder, the WAT encoder, the binary decoder, and the WAT decoder. A new `TypeKind` node has been introduced in the AST to differentiate a function type (`(@interface type (func (param …) (result …)))`) of a record type (see above).

Second, the `record.lower` transforms a host value (here Rust value, `S`) into a WIT value. In our implementation, a record value is defined as:

```rust
InterfaceValue::Record(Vec<InterfaceValue>)
```

Multiple mechanisms are used to type check a record value based on a record type. The code of the `record.lower` is pretty straightforward.

Because transforming a host value into a WIT value isn't obvious, a `Serializer` has been implemented, based on [`serde`](https://serde.rs/). This feature is behind the `serde` flag, which is turned on by default.

Serde is only used to cross the host/Wasm boundary, but it's not used to represent the value in memory or anything. It's only a shortcut to transform a host value into a WIT value, and vice versa.

Use the following code to transform `S` into a WIT value:

```rust
#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct S {
    x: String,
    y: i32,
}

let host_value = S { x: "hello".to_string(), y: 42 };
let wit_value = to_interface_value(&host_value).unwrap();

assert_eq!(
    wit_value,
    InterfaceValue::Record(vec![
        InterfaceValue::String("hello".to_string()),
        InterfaceValue::I32(42),
    ])
);
```

Third, the `record.lift`  instruction does the opposite of `record.lower`: It transforms WIT values into a host value. To also facilitate the user experience, this PR contains a `Deserializer` implementation, still based on `serde`, with the `from_interface_values` function. It looks like this:

```rust
let wit_values = vec![
    InterfaceValue::Record(vec![
        InterfaceValue::String("hello".to_string()),
        InterfaceValue::I32(42),
    ])
];
let host_value = from_interface_values::<S>(&wit_values).unwrap();

assert_eq!(
    host_value,
    S { x: "hello".to_string(), y: 42 },
);
```

With the `Serializer` and `Deserializer`, it's super easy for the user to send or receive values from WIT.

The `record.lift` and `record.lower` instructions are kind of basic. The `record.lift` instruction has a little trick to reduce vector allocations, but there is a documentation for that.

#### Opened questions

Records of dimension 1 do not raise any issue. With `record.lift`, all values on the stack (the WIT interpreter stack) are popped, and are used as record field values. Something like:

```
[stack]
i32(1)
i64(2),
string("hello")
record.lift <record_type>
```

generates

```
[stack]
record { i32(1), i64(2), string("hello") }
```

But it's not clear what happens with record of dimension > 1, for instance for a type like `record (field i32) (record (field i32) (field i32)) (field string)`, it is assumed (in this PR) that the stack must be like this:

```
[stack]
i32(1)
i32(2)
i32(3)
string("hello")
record.lift <record_type>
```

to generate:

```
[stack]
record { i32(1), record { i32(2), i32(3) }, string("hello") }
```

If we want the stack to contain an intermediate record, we should have something like this:

```
[stack]
i32(1)
i32(2)
i32(3)
record.lift <record_type_2>
string("hello")
record.lift <record_type_1>
```

But it would imply that `record_type_1` is defined as `record (field i32) (record (type record_type_2)) (field i32)`.

A sub-record defined by another record type isn't support, as it is not specified in the draft. I believe my assumption is fine enough for a first implementation of records in WIT.

### To do

- [x] Encode and decode record type (`(@interface type (record string i32))`):
  - [x] Binary encoder/decoder
  - [x] WAT encoder/decoder
- [x] Implement the `record.lift` instruction
- [x] Implement the `record.lower` instruction
- [x] Test
- [x] Documentation
- [x] Surprise!
  - [x] Serialize a Rust value to WIT values (useful for `record`s)
  - [x] Deserialize WIT values to a Rust value (useful for `record`s)

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
2020-04-06 06:17:45 +00:00
Mark McCaskey
dfa6247075 Move spectests, wrap up test restructure 2020-04-03 14:24:40 -07:00
Mark McCaskey
513e6acbc1 Move emscripten-tests to tests dir + misc fixes 2020-04-02 16:51:58 -07:00
bors[bot]
1833af7eba
Merge
1350: update blake3 to 0.3.1 r=syrusakbary a=oconnor663

Version 0.3.0 caused problems because it required a C compiler with
AVX-512 support, which broke Android x86 cross-compilation. Version
0.3.1 automatically falls back to a pure Rust build when the C compiler
either doesn't exist or doesn't support the flags we need.

Co-authored-by: Jack O'Connor <oconnor663@gmail.com>
2020-04-02 15:11:41 +00:00
Jack O'Connor
aca0bd11c0 update blake3 to 0.3.1
Version 0.3.0 caused problems because it required a C compiler with
AVX-512 support, which broke Android x86 cross-compilation. Version
0.3.1 automatically falls back to a pure Rust build when the C compiler
either doesn't exist or doesn't support the flags we need.
2020-04-02 11:02:49 -04:00
Ivan Enderlin
010b10d7b0 chore(cargo) Update Cargo.lock. 2020-04-02 16:39:40 +02:00
Mark McCaskey
976bf9b6a3 Move integration tests to tests dir in workspace root 2020-04-01 17:09:51 -07:00
bors[bot]
ecafa7564d
Merge
1313: Add types and methods to provide updated API r=MarkMcCaskey a=MarkMcCaskey

Improving the API in a number of ways.

<details><summary>Current status </summary>

- [x] Get exports from Instance
  - [x] Func
     - [x] Documented
     - [x] Tested
  - [x] DynFunc
    - [x] Documented
    - [x] Tested
  - [x] Memory
    - [x] Documented
    - [x] Tested
  - [x] Table
    - [x] Documented
    - [ ] Tested ; fully testing this now will be difficult, blocked on Table API being completed
  - [x] Global
    - [x] Documented
    - [x] Tested
  - [x] Field syntax (fairly non-trivial)
- [x] Get imports from Module
  - [ ] Maybe update this to be an iterator instead of a Vec (side note, we may want to have a way to access specific types of imports too)
  - [x] Documented
  - [x] Tested
- [x] Get exports from Module
  - [x] Documented
  - [x] Tested
- [x] Get custom section from Module
  - [x] Figure out correct solution
  - [x] Ship separate PR that updates custom section code
  - [x] Documented
  - [x] Tested
- [ ] Updated Memory API
  - [x] Added conversion methods to bytes/pages with From
  - [ ] Documented
  - [ ] Tested
- [ ] Table APIs ; blocked on `wrap` being not linear time update (this update should also make it possible to retrieve a `Func` from `vm::Anyfunc`)
  - [ ] Table set (implemented needs to be checked)
    - [ ] Documented with examples
    - [x] Implemented
  - [ ] Table grow (implemented needs to be checked)
    - [ ] Documented with examples
    - [x] Implemented
  - [ ] Table get
    - [x] Structure implemented
    - [ ] Documented
    - [ ] Tested
- [ ] Module APIs (probably separate)
- [x] Update import object macro to handle a lack of trailing commas as well
  - [x] Add line in changelog about it
  - [x] Tested

</details>

# 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-03-31 23:25:28 +00:00
Syrus Akbary
0623fa0549
Merge pull request from wasmerio/dependabot/cargo/structopt-0.3.12
Bump structopt from 0.3.11 to 0.3.12
2020-03-30 17:58:03 -07:00
Syrus Akbary
5e05ea26c6
Merge pull request from wasmerio/dependabot/cargo/serde-1.0.105
Bump serde from 1.0.104 to 1.0.105
2020-03-30 17:57:49 -07:00
Syrus Akbary
7dc26cf867
Merge pull request from wasmerio/dependabot/cargo/regex-1.3.6
Bump regex from 1.3.4 to 1.3.6
2020-03-30 17:57:39 -07:00
Mark McCaskey
403d4b4c8b
Merge branch 'master' into feature/update-api 2020-03-30 17:40:18 -07:00
dependabot-preview[bot]
778b686e82
Bump structopt from 0.3.11 to 0.3.12
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.11 to 0.3.12.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.11...v0.3.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-31 00:16:44 +00:00
dependabot-preview[bot]
959a1937a0
Bump errno from 0.2.4 to 0.2.5
Bumps [errno](https://github.com/lambda-fairy/rust-errno) from 0.2.4 to 0.2.5.
- [Release notes](https://github.com/lambda-fairy/rust-errno/releases)
- [Commits](https://github.com/lambda-fairy/rust-errno/compare/v0.2.4...v0.2.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-31 00:16:43 +00:00
dependabot-preview[bot]
b5b5232a2b
Bump serde from 1.0.104 to 1.0.105
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.104 to 1.0.105.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.104...v1.0.105)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-31 00:16:42 +00:00
dependabot-preview[bot]
5d87810892
Bump regex from 1.3.4 to 1.3.6
Bumps [regex](https://github.com/rust-lang/regex) from 1.3.4 to 1.3.6.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.3.4...1.3.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-31 00:16:41 +00:00
Nick Lewycky
5b7a06c07b Use the inkwell package on crates.io!! 2020-03-27 15:47:50 -07:00
Nick Lewycky
5bd6b161d5 Create a valid target triple in the LLVM Module. 2020-03-27 13:54:18 -07:00
Mark McCaskey
cc13e45215 Add skeleton of external API and tests 2020-03-24 18:59:09 -07:00
Mark McCaskey
d8bd258ef2 Add skeleton of exported api 2020-03-23 17:53:01 -07:00
Mark McCaskey
9cdb49d22c
Merge branch 'master' into android 2020-03-23 13:29:18 -07:00
bors[bot]
e695ecbfd8
Merge
1288: Update some dependencies manually, removing duplicate deps r=MarkMcCaskey a=MarkMcCaskey

Removes all duplicate deps (as seen by `cargo +stable tree -d`).  Primarily by updating `wasm-debug` but also by through updating some other dependencies.

Co-authored-by: Mark McCaskey <mark@wasmer.io>
2020-03-23 18:58:51 +00:00
YAMAMOTO Yuji
93f6a9b91b
enable testing on Android x86_64
Currently, at the time of 2020/03/11, testing on AArch64 is not supported in the upstream repository
2020-03-23 11:55:32 +09:00
YAMAMOTO Yuji
96a0f851c2
Update libc
The new version of libc contains changes necessary to build
wasmer-runtime-core for Android.

See https://github.com/rust-lang/libc/pull/1622 for details.
2020-03-23 11:55:32 +09:00
Jake Shadle
4de7deb568 Replace cmake with cc 2020-03-18 20:05:05 +01:00
bors[bot]
c177c44aa2
Merge
1310: upgrade the blake3 dependency to 0.2 r=MarkMcCaskey a=oconnor663

Version 0.2 makes assembly implementations available. They're off by default, and I haven't enabled them here, because they require the build machine to have a C toolchain installed. But if that's already a requirement for Wasmer, we could enable them with the `"c"` feature, for both better runtime performance and faster build times.

Co-authored-by: Jack O'Connor <oconnor663@gmail.com>
2020-03-16 21:49:54 +00:00
Jack O'Connor
1cbafeb315 upgrade blake3 to version 0.2 2020-03-16 17:12:26 -04:00
Mark McCaskey
6a5efcda98 Update wasi-tests to test multiple versions of WASI
This change also cleans up the `wasi-test` generation a bit.  It's
actually still really, really messy, but at least now it's split up
into easier to understand chunks.

There's still a lot of low-hanging fruit in terms of improving the
readibilty and maintainability of the code.
2020-03-13 15:41:50 -07:00
Mark McCaskey
fffdba395d Prepare for 0.16.2 release 2020-03-11 19:15:31 -07:00
Mark McCaskey
dc9cc3292c Prepare for 0.16.1 release 2020-03-11 16:00:21 -07:00
Mark McCaskey
aaab59f69c Update deps in llvm and singlepass too 2020-03-11 12:00:36 -07:00
Mark McCaskey
ac3d9a37ae Update some dependencies manually, removing duplicate deps 2020-03-11 11:52:43 -07:00
Mark McCaskey
d7d5f5b894 Prepare for 0.16.0 release 2020-03-11 11:15:07 -07:00
bors[bot]
b292292267
Merge
1262: Update to latest inkwell which adds context lifetime to basic blocks. r=nlewycky a=nlewycky

The latest inkwell adds lifetimes to basic blocks and also changes most APIs to pass them without reference.

Co-authored-by: Nick Lewycky <nick@wasmer.io>
2020-03-06 22:51:22 +00:00
Mark McCaskey
c295adbaa8 Prepare for 0.15.0 release 2020-03-04 12:26:19 -08:00
Nick Lewycky
3e0d299227 Update to latest inkwell which adds context lifetime to basic blocks. 2020-03-02 14:25:30 -08:00
Nick Lewycky
d5581331a2 Fix our side of wasmparser typo. 2020-03-02 11:16:21 -08:00
Mark McCaskey
cb20cd9b2d Merge branch 'master' into feature/debug-prototype2 2020-02-26 14:39:02 -08:00
Mark McCaskey
21fd95d760 Update wasmparser to 0.51.3 and clif forks to 0.59 2020-02-26 12:51:56 -08:00
dependabot-preview[bot]
1bc6565935
chore(deps): bump smallvec from 0.6.13 to 1.2.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 0.6.13 to 1.2.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v0.6.13...v1.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-24 21:45:50 +00:00
Mark McCaskey
ce21910077 Prepare for 0.14.1 release
0.14.1 differs from 0.14.0 primarily in that the GNU/Linux build is
built on Ubuntu 16.04 instead of 18.04, meaning we'll use an earlier
version of GLIBC.
2020-02-24 13:20:12 -08:00
Syrus Akbary
ad04e07c67
Merge pull request from wasmerio/dependabot/cargo/hex-0.4.2
Bump hex from 0.4.1 to 0.4.2
2020-02-24 00:33:32 -08:00
dependabot-preview[bot]
eaeb17e2c9
Bump hex from 0.4.1 to 0.4.2
Bumps [hex](https://github.com/KokaKiwi/rust-hex) from 0.4.1 to 0.4.2.
- [Release notes](https://github.com/KokaKiwi/rust-hex/releases)
- [Commits](https://github.com/KokaKiwi/rust-hex/compare/v0.4.1...v0.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-24 08:06:51 +00:00
dependabot-preview[bot]
a145a75758
Bump libc from 0.2.66 to 0.2.67
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.66 to 0.2.67.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.66...0.2.67)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-24 08:06:17 +00:00
Ivan Enderlin
4acd4becaf chore(cargo) Update Cargo.lock. 2020-02-21 12:25:27 +01:00
Mark McCaskey
3d6e915108
Merge branch 'master' into feature/debug-prototype2 2020-02-20 17:48:02 -08:00
Mark McCaskey
1374bf0806 Prepare for 0.14.0 release 2020-02-20 13:15:29 -08:00
Mark McCaskey
3bca20d3d3 Add changelog entry, clean up 2020-02-19 16:37:43 -08:00
Mark McCaskey
64cc59179a
Merge branch 'master' into feature/debug-prototype2 2020-02-19 16:13:35 -08:00