Commit Graph

795 Commits

Author SHA1 Message Date
Yuta Saito
e09cf07176 Fix JsImportObject resolver 2022-03-27 16:34: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
Amanieu d'Antras
7b8d4b1c8e Remove internal Arc from Exports
This is useless and prevents cloned Exports from being modified.
2021-12-09 18:18:12 +00:00
Amanieu d'Antras
c650ffea33 Version 2.1.0 2021-11-30 23:46:54 +00:00
Syrus Akbary
d848a430cf Fixed linting 2021-11-25 13:02:57 +01:00
Syrus Akbary
c6d2a08d0d Improved docs and fixed comments 2021-11-25 10:35:26 +01:00
Syrus Akbary
c0bcef9feb Improved naming 2021-11-25 00:11:44 +01:00
Syrus Akbary
d09553fc1b Merge branch 'master' into js-api-improvement 2021-11-24 23:58:00 +01:00
Syrus Akbary
c0913fa913 Added jsobjectresolver 2021-11-24 23:57:43 +01:00
bors[bot]
8f2e49d528 Merge #2693
2693: Add extra validation to compilers & engines r=ptitSeb a=Amanieu

- Cranelift and singlepass now properly cross-compile with no dependency on the host target.
- Staticlib engine now panics if you try to run a freshly compiled module.
- CPU features used when a module was compiled are now checked against the host CPU features during instantiation.

Fixes #1567
Fixes #2590 

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-11-23 19:48:25 +00:00
Amanieu d'Antras
a603c33def Validate that CPU features are supported when instantiating a module 2021-11-23 15:21:34 +00:00
Amanieu d'Antras
54b4495b3f Fix build 2021-11-22 19:33:02 +00:00
bors[bot]
2b104a8ecc Merge #2677
2677: Support 32-bit memories with 65536 pages r=ptitSeb a=Amanieu

Fixes #2187

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-11-10 15:49:43 +00:00
Amanieu d'Antras
6a0b381763 Support 32-bit memories with 65536 pages
Fixes #2187
2021-11-10 14:49:32 +00:00
ptitSeb
3af8b12152 fix(windows) Fix slow memory grow handling (fix #2260) 2021-11-08 16:08:01 +01:00
ptitSeb
8f035d8a07 fix(windows) Fix slow memory grow handling (fix #2260) 2021-11-08 15:41:20 +01:00
Julius Michaelis
265a8708d0 Make sure docs.rs enables features like singlepass and llvm 2021-10-15 20:25:35 +09:00
Syrus Akbary
cff5ad94ab Merge branch 'master' into get_namespace_exports 2021-10-12 12:48:42 +02:00
Syrus
0d68e3e73b Fixed wasmer-js send+sync 2021-10-11 17:48:49 +02:00
Benjamin Coenen
b215e03ca0 refactor(api): add Send + Sync trait when creating an instance
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-10-06 10:39:59 +02:00
Syrus Akbary
42c77b94f0 Merge branch 'master' into get_namespace_exports 2021-10-04 12:39:36 +02:00
Syrus Akbary
f9ff574e10 Merge pull request #2583 from wasmerio/js-wasi
Improved wasmer-js api
2021-10-01 20:26:14 +02:00
Amanieu d'Antras
35d6c0229c Add ImportObject::get_namespace_exports
This allows the contents of an existing namespace to be added to by
extracting an `Exports` from it, adding to that `Exports` and then
replacing the existing namespace with the modified `Exports`.
2021-10-01 16:15:55 +01:00
Syrus Akbary
e2d1c3679c Improved wasmer-js api 2021-09-14 14:57:39 +02:00
audioXD
f6fe638fbf Fix default-native into default-dylib
This should be default-dylib because the feature default-native doesn't exist/ has been renamed.
2021-09-12 15:02:13 +02:00
ptitSeb
bb416b905d fix(vm) Fixed a typo in a comment 2021-09-03 15:26:51 +02:00
ptitSeb
b0c7bd0f47 fix(vm) Fix the memory_grow test on Windows (with a bigger page guard) 2021-09-03 12:11:35 +02:00