Commit Graph

820 Commits

Author SHA1 Message Date
Manos Pitsidianakis
a6173f9746 Remove wasmer-{artifact,engine} and merge it into wasmer-compiler and wasmer-vm 2022-06-16 16:57:45 +03:00
Manos Pitsidianakis
25057c8f63 Move wasmer_artifact errors to wasmer_types error module 2022-06-16 16:57:45 +03:00
Manos Pitsidianakis
feee4e3587 Move wasmer_compiler errors to wasmer_types error module 2022-06-16 16:57:45 +03:00
Manos Pitsidianakis
8be0089893 Remove engine-staticlib 2022-06-16 16:57:45 +03:00
Manos Pitsidianakis
e9d54e130c Remove engine-dylib 2022-06-16 16:57:45 +03:00
ptitSeb
0cd9dfe3e0 Fixed linter warnings/errors 2022-06-15 19:26:57 +03:00
ptitSeb
68e98e216d Put back uint8view as hidden public instead of private 2022-06-15 19:26:57 +03:00
ptitSeb
3e9de243a5 Fix lint warnings/errors 2022-06-15 19:26:57 +03:00
Johnathan Sharratt
62de9c5aad Implemented functionality needed for WASIX and Networking within Web Assembly
- Introduced the virtual BUS interface used for RPC between web assembly apps
- Introduced the virtual networking interface used to implement networking
  for web assembly apps
- Implemented a local implementation of the virtual networking
  (available behind the feature toggle 'host-net' on the 'wasi' package)
- Fixed up some of the examples from the wasmer3 branch
- Refactored the WASI implementations so they support wasm64-wasi
- WASIX is behind its own namespaces for both 32bit and 64bit implementations
- Fixed the wasi_pipes unit test which was using internals that are no longer exposed - instead made the pipes clonable
2022-06-15 19:24:40 +03:00
Johnathan Sharratt
7c532813e7 Multiple changes required to implement the wasmer terminal on the browser
- Split functionality out of WasiEnv so that it can support multi-threading
- Added methods to the VFS File Trait that supporting polling
- Implemented basic time functionality for WASI
- Incorported a yield callback for when WASI processes idle
- Improved the error handling on WASI IO calls
- Reduce the verbose logging on some critical WASI calls (write/read)
- Implemented the missing poll functionality for WASI processes
- Moved the syspoll functionality behind a feature flag to default to WASI method
- Refactored the thread sleeping functionality for WASI processes
- Fixed the files system benchmark which was not compiling
- Modified the file system trait so that it is SYNC and thus can handle multiple threads
- Removed the large mutex around filesystem state and implemented granular locks instead
  (this is needed to fix a deadlock scenario on the terminal)
- Split the inodes object apart from the state to fix the deadlock scenario.
- Few minor fixes to some warnings when not using certain features
- Sleeping will now call a callback that can be used by the runtime operator when
  a WASI thread goes to sleep (for instance to do other work)
- Fixed a bug where paths that exist on the real file system are leaking into VFS
- Timing functions now properly return a time precision on WASI
- Some improved macros for error handling within syscalls (wasi_try_ok!)
- Refactored the remove_directory WASI function which was not working properly
- Refactored the unlink WASI function which was not working properly
- Refactored the poll WASI function which was not working properly
- Updates some of the tests to make them compile again
- Rewrote the OutputCapturer so that it does leak into the internals
2022-06-15 12:00:24 +02:00
Wolfgang Silbermayr
5339f7cdae Fix clippy lints
Fixes: #2926
2022-06-09 16:05:53 +02:00
Wolfgang Silbermayr
da4e9fe617 Rename NativeFunc to TypedFunction
Closes: #2915
2022-06-08 14:12:51 +03:00
Manos Pitsidianakis
00f9a3c8d7 Remove loupe dependency
Closes #2731
Closes #2744
2022-06-08 14:12:49 +03:00
Manos Pitsidianakis
92b7cb01b5 api/js: Replace ImportObject with new type Imports 2022-06-08 14:09:40 +03:00
Manos Pitsidianakis
8aa225a192 api/sys: Replace ImportObject with new type Imports 2022-06-08 14:09:40 +03:00
Amanieu d'Antras
dd7808b534 Use thiserror for MemoryAccessError 2022-06-08 14:09:40 +03:00
Amanieu d'Antras
d94745c9fc Cache the JS memory view 2022-06-08 14:09:40 +03:00
Amanieu d'Antras
714bac5650 Redesign the API for accessing the contents of a Wasm memory 2022-06-08 14:09:38 +03:00
Manos Pitsidianakis
33654c1a1d Release version 2.3.0 2022-06-06 22:27:57 +03:00
ptitSeb
63538477f2 Moved is_wasm function from api to types crate 2022-05-03 09:32:34 +02:00
ptitSeb
1f3613c881 Split Artifact to have ArtifactCreate that handles only the creation part, not the run part 2022-05-03 09:32:34 +02:00
Manos Pitsidianakis
77af8ba634 Fix some clippy lints
Before:
```
% make lint 2>&1 | grep warnings | sort | uniq
error: could not compile `wasmer-cli` due to previous error; 25 warnings emitted
warning: `compiler-test-derive` (lib) generated 8 warnings
warning: `test-generator` (lib) generated 4 warnings
warning: `wasi-test-generator` (bin "wasi-test-generator") generated 8 warnings
warning: `wasmer-cache` (lib) generated 4 warnings
warning: `wasmer-cli` (lib) generated 25 warnings
warning: `wasmer-compiler-cranelift` (lib) generated 50 warnings
warning: `wasmer-compiler-singlepass` (lib) generated 228 warnings
warning: `wasmer-compiler` (lib) generated 3 warnings
warning: `wasmer-emscripten` (lib) generated 182 warnings
warning: `wasmer-engine-dummy` (lib) generated 6 warnings
warning: `wasmer-engine-dylib` (lib) generated 37 warnings
warning: `wasmer-engine-staticlib` (lib) generated 16 warnings
warning: `wasmer-engine-staticlib` (lib) generated 7 warnings
warning: `wasmer-engine-universal` (lib) generated 11 warnings
warning: `wasmer-engine` (lib) generated 15 warnings
warning: `wasmer-object` (lib) generated 5 warnings
warning: `wasmer-types` (lib) generated 31 warnings
warning: `wasmer-vfs` (lib) generated 4 warnings
warning: `wasmer-vm` (lib) generated 40 warnings
warning: `wasmer-wasi-experimental-io-devices` (lib) generated 11 warnings
warning: `wasmer-wasi-types` (lib) generated 3 warnings
warning: `wasmer-wasi` (lib) generated 13 warnings
warning: `wasmer-wast` (lib) generated 11 warnings
warning: `wasmer` (lib) generated 54 warnings
```

After:
```
warning: `wasmer-cli` (lib) generated 16 warnings
warning: `wasmer-compiler-cranelift` (lib) generated 48 warnings
warning: `wasmer-compiler-singlepass` (lib) generated 213 warnings
warning: `wasmer-emscripten` (lib) generated 170 warnings
warning: `wasmer-engine-dummy` (lib) generated 6 warnings
warning: `wasmer-engine-dylib` (lib) generated 4 warnings
warning: `wasmer-engine-staticlib` (lib) generated 14 warnings
warning: `wasmer-engine-staticlib` (lib) generated 5 warnings
warning: `wasmer-engine-universal` (lib) generated 9 warnings
warning: `wasmer-engine` (lib) generated 12 warnings
warning: `wasmer-object` (lib) generated 3 warnings
warning: `wasmer-types` (lib) generated 7 warnings
warning: `wasmer-vm` (lib) generated 36 warnings
warning: `wasmer-wasi-experimental-io-devices` (lib) generated 6 warnings
warning: `wasmer-wasi-types` (lib) generated 3 warnings
warning: `wasmer-wasi` (lib) generated 9 warnings
warning: `wasmer-wast` (lib) generated 9 warnings
warning: `wasmer` (lib) generated 42 warnings
```
2022-04-20 18:25:04 +03:00
Amanieu d'Antras
3ad9552e2e Update wasmparser to 0.83 2022-04-06 16:23:32 +01:00
Syrus Akbary
a446f4c8ad Merge branch 'master' into katei/improve-js-error-message 2022-03-27 17:54:43 -07:00
Yuta Saito
e09cf07176 Fix JsImportObject resolver 2022-03-27 16:34:40 +00:00
Yuta Saito
7adcfef4e7 Improve error message oriented from JS object
`JsValue.as_string` converts the value to String iff the value is a
String itself, so the error message always failovers to empty string.
`JsValue` impls `Debug` using `JSON.stringify`, and it gives better
description of the error.
2022-03-27 16:33:40 +00:00
OJ Kwon
5de43d557e refactor(wasmer): apply fmt 2022-03-18 14:33:23 -07:00
OJ Kwon
160d4ad008 feat(wasmer/js): preliminary de/serialize support 2022-03-17 13:14:36 -07:00
bors[bot]
fc794ab4e3 Merge #2807
2807: Run Wasm code on a separate stack r=Amanieu a=Amanieu

This uses the [corosensei](https://crates.io/crates/corosensei) crate to
run Wasm code on a separate stack from the main thread stack.

In trap handlers for stack overflows and memory out of bounds accesses,
we can now check whether we are executing on the Wasm stack and reset
execution back to the main thread stack when returning from the trap
handler.

When Wasm code needs to perform an operation which may modify internal
data structures (e.g. growing a memory) then execution must switch back
to the main thread stack using on_host_stack. This is necessary to avoid
leaving internal data structure in an inconsistent state when a stack
overflow happens.

In the future, this can also be used to suspend execution of a Wasm
module (#1127) by modeling it as an async function call.

Fixes #2757
Fixes #2562


Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-03-16 13:24:50 +00:00
Amanieu d'Antras
fe9d2d8d22 Release version 2.2.1 2022-03-15 11:02:31 +00:00
Amanieu d'Antras
ca6f83c7d2 Run Wasm code on a separate stack
This uses the [corosensei](https://crates.io/crates/corosensei) crate to
run Wasm code on a separate stack from the main thread stack.

In trap handlers for stack overflows and memory out of bounds accesses,
we can now check whether we are executing on the Wasm stack and reset
execution back to the main thread stack when returning from the trap
handler.

When Wasm code needs to perform an operation which may modify internal
data structures (e.g. growing a memory) then execution must switch back
to the main thread stack using on_host_stack. This is necessary to avoid
leaving internal data structure in an inconsistent state when a stack
overflow happens.

In the future, this can also be used to suspend execution of a Wasm
module (#1127) by modeling it as an async function call.

Fixes #2757
Fixes #2562
2022-03-14 22:14:22 +00:00
yys
646a40580d Merge branch 'master' into bugfix/instantiate-drop-order 2022-03-04 10:16:53 +09:00
Yun Yeo
2f10460925 move drop responsibility to the module itself 2022-03-04 10:15:27 +09:00
Yun Yeo
c6be22e1b4 change host_state drop order to drop artifact first 2022-03-03 11:00:39 +09:00
Amanieu d'Antras
4dd1634218 Release version 2.2.0 2022-02-28 17:19:14 +00:00
Amanieu d'Antras
feaf483ac9 Fix drop order for Module fields
The field ordering here is actually significant because of the drop
order: we want to drop the artifact before dropping the engine.

The reason for this is that dropping the Artifact will de-register the
trap handling metadata from the global registry. This must be done before
the code memory for the artifact is freed (which happens when the store
is dropped) since there is a chance that this memory could be reused by
another module which will try to register its own trap information.

Note that in Rust, the drop order for struct fields is from top to
bottom: the opposite of C++.

In the future, this code should be refactored to properly describe the
ownership of the code and its metadata.

Fixes #2434
2022-02-24 22:14:30 +00:00
Amanieu d'Antras
15f9d2646f Release version 2.2.0-rc1 2022-02-15 19:10:24 +00:00
Amanieu d'Antras
fe025cdd3c Fix potential integer overflows in WasmPtr memory access methods 2022-02-10 15:57:08 +00:00
Amanieu d'Antras
4e27e1164c Release version 2.2.0-rc1 2022-01-27 23:59:27 +00:00
Amanieu d'Antras
fb7a572415 Use exact version for Wasmer crate dependencies
We don't guarantee API compatibility between internal Wasmer crates when
making minor version bumps.
2022-01-19 21:35:09 +00:00
Julius Michaelis
2704b5be45 Remove llvm from docs.rs feature set (trouble with building) 2021-12-27 00:21:35 +09:00
bors[bot]
a66226594f Merge #2730
2730: Release 2.1.1 r=Amanieu a=Amanieu



Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-12-21 11:20:29 +00:00
Amanieu d'Antras
ebcea4a5c4 Release v2.1.1 2021-12-21 12:19:50 +01:00
Amanieu d'Antras
3a67783fd1 Rename RuntimeError::custom to RuntimeError::user 2021-12-20 17:16:31 +01:00
Amanieu d'Antras
4924a7c22a Update examples that use RuntimeError::custom to use return a custom
error type directly.
2021-12-20 16:27:24 +01:00
bors[bot]
c68393abbd Merge #2728
2728: Replace RuntimeError::raise with RuntimeError::custom r=syrusakbary a=Amanieu

`RuntimeError::raise` should not be exposed to user code since it perfoms a `longjmp` internally which is unsound if there are any destructors on the stack. Instead a custom error type should be returned using `RuntimeError::custom` which can be passed through WASM code and later retrieved using `RuntimeError::downcast`.

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-12-18 13:07:45 +00:00
Amanieu d'Antras
17c0834abf Replace RuntimeError::raise with RuntimeError::custom 2021-12-18 00:34:44 +01:00
Amanieu d'Antras
d110bd3700 Improve comment 2021-12-17 18:18:49 +01:00
Syrus Akbary
2a2d44d127 Added externs_vec method to the ImportObject 2021-12-15 12:58:49 +01:00
Syrus Akbary
dcb2490d91 Added access to the raw Wasm instance 2021-12-14 12:25:52 +01:00