Commit graph

14 commits

Author SHA1 Message Date
Aske Simon Christensen 9814b569ba [dart2wasm] Remove support for not using non-nullable locals.
With the decision to support non-nullable locals in WasmGC as per
https://github.com/WebAssembly/function-references/issues/44 the
support in dart2wasm for forcing all locals to be nullable is no
longer needed.

This CL removes that support and cleans up some related nullability
issues. Specifically:

- Remove the `--local-nullability` and `--parameter-nullability`
  commandline options. These are now always enabled.
- Clean out special cases around forced nullable locals throughout the
  compiler.
- Make `thisLocal` and `preciseThisLocal` always non-nullable.
- Make `returnValueLocal` (for storing the return value of `return`
  statements inside `try` blocks with `finally`) always defaultable,
  since its initialization flow crosses control constructs.
- Make type argument parameters non-nullable.
- Make non-nullable `FutureOr` translate to a non-nullable Wasm type.
- Implement the "initialized until end of block" validation scheme
  in the Wasm instruction validator.
- Run tests with the `--experimental-wasm-nn-locals` option. This
  is likely going away soon, but for now we need it.

Change-Id: I05873dd70510af5944d86d37cb5765c7bdef73a9
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252600
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2022-07-27 22:47:30 +00:00
Aske Simon Christensen d8d9e06804 [dart2wasm] Support defining, exporting and accessing Wasm tables
Tested: Added tests/web/wasm/table_test.dart
Change-Id: I3971f4432a7a59bd6bc9874fc96202a7a9f2283d
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248586
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-07-19 13:06:54 +00:00
Devon Carew bc0bb9e257 [pkg/wasm_builder] analyze with package:lints
Change-Id: Ie067adab896b9b73a7eb76a04d813b8acd7ac478
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250763
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-07-07 21:31:28 +00:00
Aske Simon Christensen 90a45668d5 [dart2wasm] Support all import and export kinds in wasm_builder
Also makes table type explicit and fixes a bug in element serialization
for tables beyond index 0.

Change-Id: I7c27071e00331c41010da771ae0075e798e457a9
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247545
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-06-10 12:41:45 +00:00
Aske Simon Christensen b6e912d9f0 [dart2wasm] Use super parameters in wasm_builder
Change-Id: Idfcec5f78aaba230758e06682326af0755dfaa87
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247388
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-10 12:41:45 +00:00
Devon Carew f7c46f145c [pkg] prefer 'any' deps for package dev dependencies
Tested: CI validation
Change-Id: If65cc156130a65ffe00c6f1660ac320e2921afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246053
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-27 01:34:59 +00:00
Aske Simon Christensen 34bfee7ada [dart2wasm] Remove externref and use the new value for anyref.
This matches the spec after anyref and externref were merged, and it's
necessary in order to use the latest Binaryen, which has removed support
for the old value.

Change-Id: I7f1bb5cb08637dd79fe975603d8e236d73ca4fdc
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245375
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-05-23 10:08:00 +00:00
Aske Simon Christensen 7b1675f1a5 [dart2wasm] Abbreviate high stacks in textual instruction trace.
This avoids a pathological case in some tests.

Change-Id: Ib713ad08eb613a709949bee07fa1e583e15cad9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245163
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-05-20 12:15:32 +00:00
Jackson Gardner 6466bac7cd Add support for importing shared memory as per wasm threading proposal.
Change-Id: I077b8d3a60f543c3e54cd3e6d024260adcb8ed83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241420
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2022-04-22 22:40:29 +00:00
Aske Simon Christensen fec466e3fe [dart2wasm] Add Wasm function references and more Wasm ref conversions
Having first-class Wasm function references makes it possible to call
JS function objects directly from Dart, and to call some Dart functions
(static functions with no optional parameters and no type parameters)
from JS as function objects.

Change-Id: I1c788338d418c8857493ec76560d74fdd17d5dd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241001
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-04-19 09:40:17 +00:00
Aske Simon Christensen c2339ee782 [dart2wasm] Basic FFI support
Implements memory access through the `Pointer`, `Struct` and `Union` FFI
types. `Pointer` supports `fromAddress`, `address`, `elementAt`, `cast`,
`value`, `ref` (only getter), `[]`, `[]=` (not for structs and unions),
`==` and `hashCode`. Structs and unions support getters and setters for
their members.

`Pointer`, `Struct` and `Union` are all represented as `i32`, both
internally and in imports and exports. They currently don't have any
boxed representation, which means they can't be nullable (a `Pointer`
can still contain `nullptr` - the C null) and can't be assigned to
supertypes (i.e. `Object`, `dynamic`, type variables), stored in
containers nor passed as arguments or return values of local functions
or function expressions. To pass an FFI value in these situations, box
it manually by storing it in a field.

For the FFI integer types, only the explicitly sized versions (e.g.
`Int8`, `Uint32`) are supported.

Whenever the feature is used, the module will import a memory by the
name "ffi.memory", which will be accessed by the operations.

This also adds an optional commandline argument to `run_wasm.js` to
specify the module containing the FFI code. When such a module is
specified, it will be instantiated first, and its exports will appear as
imports to the Dart module under the "ffi" module name.

Change-Id: Ie55b072056f972b42db6b75e0c676944bbe88c1a
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237686
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-22 14:05:28 +00:00
Joshua Litt 1b8eb6b213 [dart2wasm] Add basic support for exceptions.
This CL adds support for try, catch, throw, and rethrow. In addition, it
adds stack trace support. If functions have names then these will print
in the stack trace.

This CL flips an additional 53 tests to passing(5241 -> 5294). 1 test
which was passing on TOT now crashes at compile time due to
a missing language feature which is now reachable through compilation of
a catch block. A number of other tests flip from runtime errors to
compile time crashes due to similar issues.

Note: TryFinally is implemented in the follow on.

Change-Id: I740dd25c4e062e1be2f50bbd18d1302575dff6f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226808
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-25 19:16:32 +00:00
Aske Simon Christensen 34c0296f6d OWNERS files for dart2wasm
Change-Id: I7d74013b27625d0a5d3e4d3d8f83aa4859fb4892
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233303
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-17 09:26:23 +00:00
Aske Simon Christensen 6faa5f3bd0 [dart2wasm] Initial commit for the Dart-to-WasmGC compiler.
This is work in progress. Several language features are still
unimplemented or only partially implemented.

Instructions for running the compiler and its output can be found in
pkg/dart2wasm/dart2wasm.md. These procedures are preliminary and
expected to change.

The best version of d8 to use for this version of dart2wasm is 10.0.40,
as explained here: https://dart-review.googlesource.com/c/sdk/+/232097

This commit also adds a dart2wasm-hostasserts-linux-x64-d8 testing
configuration to run the compiler over the test suite.

The history of the prototype that this is based on can be seen here:

https://github.com/askeksa-google/sdk/tree/wasm_prototype

Issue: https://github.com/dart-lang/sdk/issues/32894

Change-Id: I910b6ff239ef9c5f66863e4ca97b39b8202cce85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175728
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-16 11:11:14 +00:00