Liam Appelbe
f25c50fdcb
[wasm] Use wasm traps to handle exceptions
...
The Dart exception is converted to a string, stored in a trap which
is passed through wasm, then converted back to a Dart exception.
Module instantiation can also throw a trap, because it internally
invokes the initialization function, if the module defines one. So I'm
handling this too.
Also, update to the new version of the wasm C API, which replaces some
foo_t** with foo_vec_t*.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I1e6952a191134734a892c42b2fb8ba3506bb0844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169784
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-11-02 23:32:20 +00:00
Liam Appelbe
e2840ed07a
[wasm] Basic WASI support.
...
Enabling WASI when building an instance sets up the default WASI
imports, and can optionally capture stdout/stderr. I'd like to set up
something similar for stdin, but Wasmer doesn't support that yet.
I also improved error handling in WasmRuntime by adding Wasmer's last
error to the thrown exceptions where appropriate.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I2d8546e878bcb43c7093490eac085aa62d318e96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167904
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-10-20 19:24:05 +00:00
Liam Appelbe
89dbc35fca
[wasm] Wasm function imports.
...
I switched from a WasmImports object to a builder pattern:
module.instantiate().addMemory(...).addFunction(...).build();
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I381aa0f7df1fa006ce8d051cd5b4a1bcc1835e46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167460
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-10-16 23:16:42 +00:00
Liam Appelbe
cff78bed87
Reland "Switch wasmer FFI boilerplate to new API"
...
This reverts commit 0c3d3da6ce .
Un-deleting the LICENSE file, to fix the dart->flutter roller.
Change-Id: Iee44c24e7cdb5c03f4ae131d08451fae2e996f49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167201
Reviewed-by: Siva Annamalai <asiva@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-10-13 19:30:58 +00:00
Alexander Aprelev
0c3d3da6ce
Revert "Switch wasmer FFI boilerplate to new API"
...
This reverts commit 9d0ae7d017 as it broke dart->flutter roller's flutter license script.
Change-Id: If523b9b88631e1eca0fef3612387005921481222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166981
Reviewed-by: Alexander Aprelev <aam@google.com >
Commit-Queue: Alexander Aprelev <aam@google.com >
2020-10-10 05:56:29 +00:00
Liam Appelbe
9d0ae7d017
Switch wasmer FFI boilerplate to new API
...
Broadly speaking, the new API is very similar to the old one. The only
public facing change is that you can't make a memory by itself anymore.
You need to construct if from a store, which is owned by a module.
The new API no longer passes structs by value, so I was able to delete
the wasmer_wrapper.cc, and the files I had copied from the wasmer repo.
The new API is also a lot more verbose, so it made more sense to write
a script to generate the FFI boilerplate, rather that write it all
manually.
All the migrated tests that were passing before this refactor are still
passing.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I52ca54b982a27f1d851c630d3e09833b8810060c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164081
Reviewed-by: Siva Annamalai <asiva@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-10-09 19:43:57 +00:00
Liam Appelbe
cc8fd04924
[wasm] Add WasmMemory class.
...
Also, port the old wasm memory tests, and fix some NNBD issues.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I131ba5836bb0a3dd946cf9b0fa3f2e186b6b132e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162801
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Ryan Macnak <rmacnak@google.com >
2020-09-16 19:24:28 +00:00
Liam Appelbe
56be9a7425
[wasm] Port about half of the old dart:wasm tests to package:wasm
...
The rest of the tests rely of features I haven't implemented yet. I'll
port them as I implement them.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I3465f10055db8d82148004ea975c0ed3b2928178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162780
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2020-09-15 20:48:31 +00:00
Liam Appelbe
26c49d5578
[vm] Wasm memory exports, and emscripten hello world
...
I got the hello world wasm file from the emscripten team and got it
running using a fake implementation of WASI's fd_write function. This
necessitated adding support for memory exports.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I139a4e868d437e2232bf4260e5cc26d8c598ac2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119061
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2019-10-01 18:19:56 +00:00
Liam Appelbe
6da8c39c5a
[vm] Small WasmImports API change, and more WASM error tests
...
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I3044d588398ccb19e3ebcebe6cd506b047a37857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118601
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2019-09-27 23:36:11 +00:00
Liam Appelbe
d2a0900a50
Reland "[vm] Wasm function imports"
...
This reverts commit a7cb8ee88b .
Reason for revert: Fixed the crash
Original change's description:
> Revert "[vm] Wasm function imports"
>
> This reverts commit 7a24aec8f4 .
>
> Reason for revert: debug-mode gen_snapshot crashes on all programs
>
> Original change's description:
> > [vm] Wasm function imports
> >
> > Bug: https://github.com/dart-lang/sdk/issues/37882
> > Change-Id: Ia8aa9a87803d5e8b899ddab5479b8cd93e03fd71
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118204
> > Commit-Queue: Liam Appelbe <liama@google.com >
> > Reviewed-by: Ryan Macnak <rmacnak@google.com >
> > Reviewed-by: Alexander Markov <alexmarkov@google.com >
>
> TBR=rmacnak@google.com ,alexmarkov@google.com ,liama@google.com
>
> Change-Id: Ib5d348e25854af010b1d8a64a87406da443981df
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: https://github.com/dart-lang/sdk/issues/37882
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119143
> Reviewed-by: Samir Jindel <sjindel@google.com >
> Commit-Queue: Samir Jindel <sjindel@google.com >
TBR=rmacnak@google.com ,alexmarkov@google.com ,sjindel@google.com ,liama@google.com
Change-Id: I4fd073a087eae7bb95c75079446d9111e7bc8c40
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/37882
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119168
Reviewed-by: Liam Appelbe <liama@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2019-09-27 21:29:12 +00:00
Samir Jindel
a7cb8ee88b
Revert "[vm] Wasm function imports"
...
This reverts commit 7a24aec8f4 .
Reason for revert: debug-mode gen_snapshot crashes on all programs
Original change's description:
> [vm] Wasm function imports
>
> Bug: https://github.com/dart-lang/sdk/issues/37882
> Change-Id: Ia8aa9a87803d5e8b899ddab5479b8cd93e03fd71
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118204
> Commit-Queue: Liam Appelbe <liama@google.com >
> Reviewed-by: Ryan Macnak <rmacnak@google.com >
> Reviewed-by: Alexander Markov <alexmarkov@google.com >
TBR=rmacnak@google.com ,alexmarkov@google.com ,liama@google.com
Change-Id: Ib5d348e25854af010b1d8a64a87406da443981df
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/37882
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119143
Reviewed-by: Samir Jindel <sjindel@google.com >
Commit-Queue: Samir Jindel <sjindel@google.com >
2019-09-27 12:22:58 +00:00
Liam Appelbe
7a24aec8f4
[vm] Wasm function imports
...
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: Ia8aa9a87803d5e8b899ddab5479b8cd93e03fd71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118204
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2019-09-26 22:08:12 +00:00
Liam Appelbe
fd0a89971c
[vm] More wasm cleanup
...
Fix some VM/native transition issues, and add a describe() function that
prints all the imports and exports of a module.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I68a8860857c3fcb37c49a9e92731629a13fd9449
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118363
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Commit-Queue: Liam Appelbe <liama@google.com >
2019-09-24 21:24:57 +00:00
Liam Appelbe
f234830998
Cut dart:ffi dependency to fix simarm build
...
Change-Id: I4124163000e2990a6037d36a4f87ccfcddf5a933
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117210
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Aart Bik <ajcbik@google.com >
2019-09-13 23:23:34 +00:00
Liam Appelbe
ed9e89ea38
Implement a basic WASM API using wasmer.
...
Currently this only supports functions that take and return numeric
types. Byte arrays, and callbacks will come later, in a separate
wrapper package.
Bug: https://github.com/dart-lang/sdk/issues/37882
Change-Id: I7bb82be83cbbb6062736b3e958f89d021f1af4bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114586
Commit-Queue: Liam Appelbe <liama@google.com >
Reviewed-by: Samir Jindel <sjindel@google.com >
Reviewed-by: Ryan Macnak <rmacnak@google.com >
2019-09-13 18:25:16 +00:00