Commit Graph

3132 Commits

Author SHA1 Message Date
07b5991080 No need to emit add of constant zero. 2019-09-23 15:01:19 -07:00
8c5ccdb497 Merge #807
807: Implement Send for Instance r=MarkMcCaskey a=MarkMcCaskey

# Review

- [x] Create a short description of the the change in the CHANGELOG.md file

Resolves #748 

WIP

## List of changes
### Commit 1
- `Global`s use Arc instead of RC
- Export `Context` and `FuncPointer` manually implement Send
- `ImportObject` uses `Arc<Mutex<HashMap<...>>>` Instead of `Rc<RefCell<HashMap<...>>>`; removed `get_namespace` method in favor of continuation style to deal with locking the Mutex
- `Func` manually implements `Send` (TODO: this change needs to be checked in depth)
### Commit 2
- `unsafe impl Send for Export {}` (temporary to allow Memory to be not Send)
- RefCell -> Mutex in Global and Table
- Rc -> Arc in Table
- Namespace's `IsExport`s must be `Send` (Done to avoid touching much more of the code (i.e. `trait IsExport: Send` requires a lot -- maybe this is what we should do though)
- Make `Host` and `Wasm` `Func`s Send (manual implementation)
- Manual implementation for `LocalTable` and `AnyFunc`
### Commit 3
- rm placeholder `unsafe impl Send for Export {}`
- Manual implementation for `LocalBacking` and `ImportBacking` (both seemed to be not Send due to direct ownership of mutable pointers in their containers)
- ImportObject's state creator Fn trait object is now ` + Send + Sync + 'static` (required because it's in an Arc)
- Manually implement Send for `InstanceInner` because it holds a raw pointer, `LocalBacking` and `ImportBacking` are marked Send separately 
- Memory: All Rc -> Arc (including unshared memory); All RefCell -> Mutex (including unshared memory)
- Manual implementation of Send and Sync on `UnsharedMemoryInternal`
- Manual implementation of Send and Sync on `SharedMemoryInternal`
- Change `runtime-core::unix::memory::Memory.fd` from `Option<Rc<Rawfd>>` to `Option<Arc<Rawfd>>` (not strictly required for this change because Memory has manual implementations of Send and Sync, but Arc seems more correct here and there's no comment justifying the use of Rc)
- Manual implementation of Send for `ImportedFunc`

Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
2019-09-23 21:20:01 +00:00
9cab6d721f Merge branch 'feature/make-instance-send' of github.com:wasmerio/wasmer into feature/make-instance-send 2019-09-23 13:43:48 -07:00
c4818f12dc Update spectests to work with new Instance; use Arc<Mutex<>> 2019-09-23 13:43:01 -07:00
eed033021b Merge pull request #825 from Hywan/doc-runtime-core-memory-view
doc(runtime-core) Replace `map(|cell| cell.get())` by `map(Cell::get)`.
2019-09-23 11:34:00 -07:00
705287c317 Merge branch 'master' into feature/make-instance-send 2019-09-23 11:06:00 -07:00
1e637badc4 Merge remote-tracking branch 'origin/master' into feature/make-instance-send 2019-09-23 11:05:00 -07:00
05ad1aaea4 Add test for Instance, fix tests for ImportObject 2019-09-23 11:04:31 -07:00
3dadbc15c9 Integer subset done. 2019-09-23 22:30:08 +08:00
be5624e28b feat(interface-types) Implement the read-utf8 instruction.
It implies to create the `wasm::Memory` trait.

Also, the patch updates `wasm::Type` and `wasm::Value` to
`wasm::InterfaceType` and `wasm::InterfaceValue`. It enforces a new
rule that is: All values in the stack must be owned by the stack. Any
value going in or out must be cloned.
2019-09-23 16:29:01 +02:00
f289cb2ba9 doc(runtime-core) Replace map(|cell| cell.get()) by map(Cell::get).
Because it's simpler :-p.
2019-09-23 15:15:06 +02:00
5ace7a0af3 fix failing test 2019-09-23 11:17:02 +02:00
9942d3ae98 Improved Emscripten / WASI autodetection 2019-09-22 18:23:22 -07:00
8e2f526f73 Added cpp example 2019-09-22 17:42:19 -07:00
009c123332 Fixed emscripten main functions 2019-09-22 17:29:12 -07:00
a1a88c6eb8 Use the default features for wasmparser 2019-09-21 13:59:08 -05:00
f48d6f6690 Cranelift backend update to fork of clif version 0.43.1 2019-09-21 13:06:54 -05:00
7d9e6d8caa Merge #821
821: Remove patch version in deps when not necessary r=MarkMcCaskey a=MarkMcCaskey

This allows wasmer library users to have more control over the exact versions of deps that Wasmer uses.

# Review

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


Co-authored-by: Mark McCaskey <mark@wasmer.io>
2019-09-20 23:44:37 +00:00
862a4c5448 Merge pull request #814 from confio/fix-linux-image-link-error
Fix issues with testing/linking singlepass in runtime-c-api
2019-09-20 16:33:30 -07:00
bf396ec76d Remove patch version in deps when not necessary 2019-09-20 16:11:09 -07:00
7f2c532594 Allow dead code in emscripten WasmPtr 2019-09-20 13:19:31 -07:00
882a77ccf9 Remove null pointer checks generally, re-add them in Emscripten 2019-09-20 12:02:12 -07:00
7deed3160b cargo fmt 2019-09-20 18:59:36 +02:00
ca409f78c5 fix spectest 2019-09-20 18:54:05 +02:00
aea18f6250 test(interface-types) Test calling a void exported function. 2019-09-20 14:59:18 +02:00
8557e83ce6 feat(interface-types) Better error message when calling an exported function failed. 2019-09-20 14:55:37 +02:00
56afb4da63 feat(interface-types) Check signature of the exported function to call. 2019-09-20 14:31:15 +02:00
b7b37d2e99 feat(interface-types) The interpreter stack contains Wasm values. 2019-09-20 14:07:56 +02:00
2237e628ab chore(interface-types) Fix clippy warnings. 2019-09-20 12:02:11 +02:00
39a817817b feat(interface-types) Stack supports Default. 2019-09-20 11:55:19 +02:00
9d4c983206 feat(interface-types) Implement CallExport executable instruction.
It requires to create the `wasm::Export` trait, plus the `wasm::Type`
and the `wasm::Value` enums.
2019-09-20 11:37:38 +02:00
62e1f7867b feat(interface-types) Add an abstract Wasm instance and a runtime to the interpreter. 2019-09-20 00:06:15 +02:00
c63345029e feat(interface-types) Continue. 2019-09-19 23:05:17 +02:00
0790ebff0c Merge #803
803: Add method to call function at index on Ctx r=MarkMcCaskey a=MarkMcCaskey

For #638 and #670

```Rust
fn call_guest_fn(ctx: &mut Ctx, guest_fn: u32) -> u32 {
    println!("{}", guest_fn);

    let guest_fn_typed = unsafe { std::mem::transmute(guest_fn) };

    let result = ctx.call_with_table_index(guest_fn_typed, &[]).unwrap();
    println!("  -> {:?}", result);

    0
}
```
is what this looks like from the Host side

See `examples/callback.rs` for an example that doesn't require `transmute`


# Review

- [x] Create a short description of the the change in the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
2019-09-19 20:55:09 +00:00
9a49fb59e0 Merge branch 'master' into fix-test-typo 2019-09-19 22:15:32 +02:00
dd1a4a6c10 Merge #805
805: Replace panic! & unimplemented! in runtime-code and llvm-backend r=nlewycky a=pventuzelo

# Description

Replace `unimplemented!` by already used `CodegenError` in `lib/llvm-backend/src/code.rs`
Replace `unimplemented!` by `Err` in `lib/llvm-backend/src/trampolines.rs`
Replace `panic!` by already used `BinaryReaderError` in `lib/runtime-core/src/parse.rs`

# Review

- [ ] Create a short description of the the change in the CHANGELOG.md file


Co-authored-by: Patrick Ventuzelo <ventuzelo.patrick@gmail.com>
2019-09-19 19:20:04 +00:00
8d0edc61df Merge master 2019-09-19 11:16:14 +02:00
a9d8b22fe7 Merge branch 'master' into feature/call-function-at-index-on-just-ctx 2019-09-18 16:46:08 -07:00
ccd369ff0c Add example, rename Ctx fn, make things pub(crate), misc changes 2019-09-18 16:43:47 -07:00
5741a2cf70 Implement function lookups using the table 2019-09-18 16:06:46 -07:00
2f3c37fbd5 feat(interface-types) Continue. 2019-09-19 00:25:28 +02:00
8ae255b51a Fix issues with testing/linking singlepass in runtime-c-api 2019-09-19 00:19:17 +02:00
dc3c72ea19 feat(interface-types) Draft instruction interpreter. 2019-09-19 00:18:36 +02:00
e8a918e2e5 %lld -> %ld fixes cargo test compile error 2019-09-18 23:25:35 +02:00
a124d87d0f Fix Operator::MemorySize. 2019-09-19 01:10:23 +08:00
5f8b289751 movzx/movsx 2019-09-19 01:04:20 +08:00
fc9389d932 feat(interface-types) Encode Interfaces to WAT. 2019-09-18 18:02:05 +02:00
6ec35c8bdc chore(interface-types) Bump to 0.7.0. 2019-09-18 17:14:57 +02:00
480fe0fb9b chore(interface-types) Update to Wasmer 0.7.0. 2019-09-18 17:14:12 +02:00
bd3a888452 feat(interface-types) Add new instructions. 2019-09-18 17:12:42 +02:00