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>
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>
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>
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>