Commit graph

114 commits

Author SHA1 Message Date
Aske Simon Christensen 1a3ae1e44b [dart2wasm] Emit nominal types and don't use RTTs by default.
This enables us to upgrade our testing to use a newer version of d8.

Change-Id: I79a8879a325b9996b9923304439a3ee8fa5fa02a
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238345
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-24 10:10:11 +00:00
Joshua Litt 4abac88110 [dart2wasm] Add support for null checks.
Change-Id: Ibaa40bb79232f521376f96900ed64cb88643304e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237769
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-22 19:37:30 +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
Aske Simon Christensen 58cad00468 [dart2wasm] Initialize the function class early.
Subclasses of the _Function class are generated on the fly as fields
with function types are encountered. Therefore, this class must be early
in the initialization order.

Change-Id: Ia0b998c443af9f6bdb4af512f6da99e6e3767c1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237681
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-18 17:44:57 +00:00
Aske Simon Christensen a8f8d96a27 [dart2wasm] Implement map constants without lowering.
Change-Id: I9c467ff0e5176c1400794f2008f41eaaaf91bea3
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237142
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-16 10:05:43 +00:00
Aske Simon Christensen d24354ea09 [vm/dart2wasm] Brush up mixin structure of hash implementation classes
This changes all mixins in the VM's hash map/set implementation to be
declared as mixins and introduces appropriate interfaces needed to
concisely express the prerequisites of the various mixins in the stack.

It also separates most of the implementation of immutable maps and sets
into mixins to enable sharing the implementation with dart2wasm.

Tested: ci + manual testing of dart2wasm
Change-Id: Ife1e7195aba35741629aa4dffedb929b1028a85a
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236180
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-03-16 10:05:43 +00:00
Joshua Litt e672c7e6e2 [dart2wasm] Implement TryFinally.
This CL flips another 7 TryFinally tests to passing without introducing
any new failures.

Change-Id: I3064161f33db2fd16ae4f8d7eae4a904339d707b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234220
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-07 19:27:23 +00:00
Aske Simon Christensen 1be4ae09f2 [dart2wasm] Set nominal supertype of exception tag function type
WasmGC type definitions must all agree on whether they specify a
supertype or not.

This changes the exception tag function type to specify a supertype in
nominal mode to comply with this requirement.

Change-Id: I7bab0ceaa94c3b9098c2d517c0f91c6a19541dc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234920
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-07 17:53:32 +00:00
Alexander Markov d0e8ef9816 [vm,kernel] Move transformations maintained by the VM team from pkg/kernel to pkg/vm
These transformations are maintained by the VM team and keeping them
in pkg/kernel would put a burden on the CFE team after code reviews
are tightened to require OWNERS approval.

TEST=ci

Change-Id: I931033ba987d17a2c9c6d80a16dad09bfbaa0572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234905
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-03-03 15:04:10 +00:00
Aske Simon Christensen 1be8de3ea4 [dart2wasm] Conversion functions for native int and float types
This adds constructors and conversion methods to the native Wasm int and
float types WasmI32, WasmI64, WasmF32 and WasmF64 to convert between
these and Dart int/double. This enables imports and exports to use the
native Wasm types to specify the Wasm function signature concisely.

Change-Id: I3ff459ad9c16574ac6186f753036acc17fa6814d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234400
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-28 14:03:24 +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
Michael Thomsen 2f263c2769 Add experimental warning to dart2wasm
Change-Id: I81f562e9a003e7530120fec608baf5984f3a224f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233783
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2022-02-21 12:36:21 +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