[L] Change in dart/sdk[main]: [dart2wasm] Make IR tests more stable

0 views
Skip to first unread message

Martin Kustermann (Gerrit)

unread,
Dec 1, 2025, 7:00:21 AM (yesterday) Dec 1
to Ömer Ağacan, Commit Queue, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Ömer Ağacan

Martin Kustermann added 1 comment

File pkg/dart2wasm/test/ir_tests/deferred.constant.wat
Line 9, Patchset 6 (Parent): (type $type234 <...>)
Martin Kustermann . unresolved

These numbers were often changing which made us need to re-generate the expectation files.

Open in Gerrit

Related details

Attention is currently required from:
  • Ömer Ağacan
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Gerrit-Change-Number: 465341
Gerrit-PatchSet: 6
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Ömer Ağacan <ome...@google.com>
Gerrit-Attention: Ömer Ağacan <ome...@google.com>
Gerrit-Comment-Date: Mon, 01 Dec 2025 12:00:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Ömer Ağacan (Gerrit)

unread,
Dec 1, 2025, 7:14:13 AM (yesterday) Dec 1
to Martin Kustermann, Commit Queue, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Martin Kustermann

Ömer Ağacan voted and added 4 comments

Votes added by Ömer Ağacan

Code-Review+1

4 comments

File pkg/dart2wasm/bin/wasm2wat.dart
Line 49, Patchset 6 (Latest): if (output == '-') {
Ömer Ağacan . unresolved

This is different than the documentation which says by default we print to stdout.

One of them should be updated. I suggest we update this line and print to stdout when output is not provided. Because otherwise the default doesn't do anything, and I doubt you ever run this program to do nothing.

Line 72, Patchset 6 (Latest): help: 'Print functions/types/... in sorted order (sort by name).')
Ömer Ağacan . unresolved

Why not print sorted all the time? Is there a case where we don't want to sort?

Line 82, Patchset 6 (Latest): 'The filepath where the output will be written to (default: stdout). '
Ömer Ağacan . unresolved

I don't think the default is right. It doesn't do anything when I don't pass `-o`. I tried this:
```
$ dart pkg/dart2wasm/bin/wasm2wat.dart /usr/local/google/home/omersa/dart/sdk/test/test.wasm
```
Which doesn't print anything.

Line 84, Patchset 6 (Latest): 'If omitted will write `<inpput.wasm>.wat` files.');
Ömer Ağacan . unresolved

inpput -> input

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Gerrit-Change-Number: 465341
Gerrit-PatchSet: 6
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Ömer Ağacan <ome...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Comment-Date: Mon, 01 Dec 2025 12:14:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
Dec 1, 2025, 9:03:24 AM (yesterday) Dec 1
to Ömer Ağacan, Commit Queue, dart2wasm-t...@google.com, rev...@dartlang.org

Martin Kustermann added 6 comments

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Martin Kustermann . resolved

Thanks, Omer!

File pkg/dart2wasm/bin/wasm2wat.dart
Line 49, Patchset 6: if (output == '-') {
Ömer Ağacan . resolved

This is different than the documentation which says by default we print to stdout.

One of them should be updated. I suggest we update this line and print to stdout when output is not provided. Because otherwise the default doesn't do anything, and I doubt you ever run this program to do nothing.

Martin Kustermann

Okay, I've redone this now a bit differently and put my new use case under a `--write` flag.

Line 72, Patchset 6: help: 'Print functions/types/... in sorted order (sort by name).')
Ömer Ağacan . resolved

Why not print sorted all the time? Is there a case where we don't want to sort?

Martin Kustermann

Well, there's advantages to be able to dump the wasm file as text without real loss of information - so one can see e.g. if a new binaryen version reorders things.

In our IR tests specifically we're not interested in this and care more about stability of the text.

Since it's easy to have both options, I thought why not allow both.

Line 82, Patchset 6: 'The filepath where the output will be written to (default: stdout). '
Ömer Ağacan . resolved

I don't think the default is right. It doesn't do anything when I don't pass `-o`. I tried this:
```
$ dart pkg/dart2wasm/bin/wasm2wat.dart /usr/local/google/home/omersa/dart/sdk/test/test.wasm
```
Which doesn't print anything.

Martin Kustermann

It does print something into `test.wasm.wat`.

So the reason I did this change is

  • almost always I use this tool to dump to file (very rarely to stdout)
  • it's annoying to always having to supply `-o outputfile.wat`
  • => with this CL a `dart wasm2wat.dart foo.wasm` will automatically write to `foo.wasm.wat`
  • often I have two wasm files and I want to compare them: I don't want to run this tool twice, so I want `dart -s -f <some-filter> wasm2wat {before,after}.wasm && nvim -d {before,after}.wasm.wat`

I've done it now differently, this is now the supported usage pattern

  • `dart wasm2wat.dart input.wasm` - to stdout
  • `dart wasm2wat.dart input.wasm -o output.wat` - to `output.wat`
  • `dart wasm2wat.dart -w input1.wasm input2.wasm ...` - to `input1.wasm.wat1`, `input2.wasm.wat`, ...
Line 84, Patchset 6: 'If omitted will write `<inpput.wasm>.wat` files.');
Ömer Ağacan . resolved

inpput -> input

Martin Kustermann

Done

File pkg/dart2wasm/test/ir_tests/deferred.constant.wat
Line 9, Patchset 6 (Parent): (type $type234 <...>)
Martin Kustermann . resolved

These numbers were often changing which made us need to re-generate the expectation files.

Martin Kustermann

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Gerrit-Change-Number: 465341
Gerrit-PatchSet: 7
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Ömer Ağacan <ome...@google.com>
Gerrit-Comment-Date: Mon, 01 Dec 2025 14:03:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Ömer Ağacan <ome...@google.com>
Comment-In-Reply-To: Martin Kustermann <kuste...@google.com>
satisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
6:06 AM (5 hours ago) 6:06 AM
to Ömer Ağacan, Commit Queue, dart2wasm-t...@google.com, rev...@dartlang.org

Martin Kustermann voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Gerrit-Change-Number: 465341
Gerrit-PatchSet: 8
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Ömer Ağacan <ome...@google.com>
Gerrit-Comment-Date: Tue, 02 Dec 2025 11:06:36 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
6:06 AM (5 hours ago) 6:06 AM
to Martin Kustermann, Ömer Ağacan, dart2wasm-t...@google.com, rev...@dartlang.org

Commit Queue submitted the change with unreviewed changes

Unreviewed changes

6 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: pkg/dart2wasm/bin/wasm2wat.dart
Insertions: 28, Deletions: 11.

The diff is too large to show. Please review the diff.
```

Change information

Commit message:
[dart2wasm] Make IR tests more stable

To avoid depending on exact ordering binaryen uses in the wasm module,
we start

* enqueue functions/types/... based on sort name instead of index
in wasm module

* only assign increasing ids in `Namer` if we actually want to print
the name

* print functions/types/... in sorted order

for IR tests.

We also update the `pkg/dart2wasm/bin/wasm2wat.dart` tool to be
able to dump wat for multiple wasm modules.
Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Reviewed-by: Ömer Ağacan <ome...@google.com>
Commit-Queue: Martin Kustermann <kuste...@google.com>
Files:
  • M pkg/dart2wasm/bin/wasm2wat.dart
  • M pkg/dart2wasm/test/ir_test.dart
  • M pkg/dart2wasm/test/ir_tests/deferred.constant.multi_module_use.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.constant.multi_module_use_module1.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.constant.multi_module_use_module3.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.constant.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.constant_module1.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.constant_module2.wat
  • M pkg/dart2wasm/test/ir_tests/dyn_closure.wat
  • M pkg/dart2wasm/test/ir_tests/dyn_closure_function_apply.wat
  • M pkg/dart2wasm/test/ir_tests/dyn_closure_function_apply_named.wat
  • M pkg/dart2wasm/test/ir_tests/import_name.wat
  • M pkg/dart2wasm/test/ir_tests/interop.bool.wat
  • M pkg/dart2wasm/test/ir_tests/interop.double.wat
  • M pkg/dart2wasm/test/ir_tests/interop.int.wat
  • M pkg/dart2wasm/test/ir_tests/interop.num.wat
  • M pkg/dart2wasm/test/ir_tests/interop.string.wat
  • M pkg/wasm_builder/lib/src/ir/module.dart
  • M pkg/wasm_builder/lib/src/serialize/printer.dart
Change size: L
Delta: 19 files changed, 403 insertions(+), 373 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Ömer Ağacan
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifbfc9149a629cf5ceacd95b7cb4892e9de3d4d9c
Gerrit-Change-Number: 465341
Gerrit-PatchSet: 9
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages