Files
sdk/pkg/wasm_builder
Martin Kustermann 9fd82be4ff [dart2wasm] Disable type branding by default
This reduces e main module by around 1.5% compressed and 0.7%
uncompressed.

Except for a few special wasm struct types, we don't rely on type
uniqueness as we never use e.g. `ref.test` on normal wasm structs of
dart classes, closures, closure contexts, ...

So for otherwise structurally equivalent types, we can allow merging the
types. This can lead to confusion when reading wasm files because two
unrelated Dart classes may end up being represented with the same wasm
struct. To avoid this confusion when reading .wat files, we make it
clear in the type name and field names that it can be any of the
original dart classes / fields.

One can enforce unique types by passing `--no-unique-types`.

In IR tests we default to `--unique-types` to make the IR tests more
readable, except for 2 newly added tests that test this flag.

In essence this is the follow-up work on [0] which started sharing wasm
structs between classes in a hierarchy.

We enable `--unique-types` in opt>=2 (just like in --minify)

The dart2wasm compiler may now emit two identical recursion groups. We
could avoid that, but that would be a bigger refactoring of the type
building code in `package:wasm_builder` and `wasm-opt` will remove the
duplicate recursion groups anyway.

[0] https://dart-review.googlesource.com/c/sdk/+/472181

Change-Id: I36a5b7cfc3abb5318658fa67dae36e1c0a1e4d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501140
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-08 00:32:15 -07:00
..