Commit graph

7 commits

Author SHA1 Message Date
Nate Biggs 04f3e7a740 [dart2wasm] Use brand types for wasm minimal recursion groups.
Brand types encode an integer as a struct type and allow us to break the equivalence relation between similar types in different rec groups.

We now compute equivalence classes at the rec group level reducing the number of brand types we have to assign.

We also improves the equivalence class computation by exiting earlier when a group/type is found to be part of an equivalence class. This is enough information to tell us which brand type it needs so we can exit the inner loop early.

Change-Id: I8c5e1cfc679f1fcb6b7f0e79bd71719f345784d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-08-28 23:44:04 +00:00
Nate Biggs d9b5eec829 [dart2wasm] Modify wasm_builder to support multi-module deferred loading (2/2).
Golem results verifying no regressions from this change:
https://golem.corp.goog/Revision?repository=dart&revision=111273&patch=19368

This modifies the wasm_builder to emit types in minimally sized recursive groups.

The main motivation of these changes is to minimize the size of the type section when dart2wasm produces multiple modules. If we included every type in every module, for small modules the type section would be a very significant % of the total file size (in a small example it was ~98% for a deferred module).

The two main changes are:
1) Type tree-shaking for each module.

We detect which types are actually used in that module (via instructions, function signatures, etc.) and only include the detected types in the module's type section. This simplifies the compilation pipeline as we don't need to worry about assigning types to modules, we can just build the module as before and post-process the IR to collect the set of used types.

2) Create minimally-sized recursive groups.

In order for wasm type-checking to work across modules, equal types have to be in equal recursive groups. Tree-shaking therefore has to occur at the rec group level as opposed to the individual type level. So to make tree-shaking effective, we need the smallest possible rec groups.

We achieve this by creating a graph of the wasm types' dependencies and then calculating the set of strongly connected components for that graph. Each component represents a minimally-sized recursive group. The DAG formed by the components is the order to emit them so that definitions come before usages.

Importantly, by separating types into different rec groups, we are also changing the equivalence relationship between them. This can have a meaningful impact on binaryen's ability to optimize the module, two types that were distinguishable might not be anymore. To avoid this regression we group together any types that are structurally equivalent. This way binaryen will differentiate them as separate types as they were in the original Dart source.


Change-Id: I67acdd21a89ff2718e8bbd6360f342c150494a9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378764
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-08-07 17:27:38 +00:00
Devon Carew e2fe203adc [deps] roll package:lints to the latest
Change-Id: I582f956cd4b712203c2f6dd630b4e1384040446d
Tested: analysis clean (this is a lint only related change)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329400
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-10-05 03:36:59 +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 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 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