[M] Change in dart/sdk[main]: [record_use] Enum const instances wasm

0 views
Skip to first unread message

Daco Harkes (Gerrit)

unread,
Mar 3, 2026, 3:06:20 AM (7 days ago) Mar 3
to Nate Biggs, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Nate Biggs

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Biggs
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 4
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 08:06:15 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Biggs (Gerrit)

unread,
Mar 3, 2026, 3:14:52 AM (7 days ago) Mar 3
to Daco Harkes, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Daco Harkes

Nate Biggs added 2 comments

File pkg/vm/lib/transformations/type_flow/transformer.dart
Line 2289, Patchset 4 (Latest): node.isEnum = false;
Nate Biggs . unresolved

Why do we need to preserve the enum-ness of an unused class?

File sdk/lib/core/enum.dart
Line 108, Patchset 4 (Latest): // TODO(https://github.com/dart-lang/native/issues/3186): Don't record indices.
Nate Biggs . unresolved

If anything I'd lean towards only putting the index and not the name. It's less readable but most of the time the index is considered the "value of truth" for enums.

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 4
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 08:14:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Mar 3, 2026, 6:37:30 AM (7 days ago) Mar 3
to Nate Biggs, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Nate Biggs

Daco Harkes voted and added 2 comments

Votes added by Daco Harkes

Commit-Queue+1

2 comments

File pkg/vm/lib/transformations/type_flow/transformer.dart
Line 2289, Patchset 4: node.isEnum = false;
Nate Biggs . resolved

Why do we need to preserve the enum-ness of an unused class?

Daco Harkes

Oh, we don't. 👍

File sdk/lib/core/enum.dart
Line 108, Patchset 4: // TODO(https://github.com/dart-lang/native/issues/3186): Don't record indices.
Nate Biggs . resolved

If anything I'd lean towards only putting the index and not the name. It's less readable but most of the time the index is considered the "value of truth" for enums.

Daco Harkes
Open in Gerrit

Related details

Attention is currently required from:
  • Nate Biggs
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 6
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 11:37:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Nate Biggs <nate...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Biggs (Gerrit)

unread,
Mar 3, 2026, 11:46:15 AM (7 days ago) Mar 3
to Daco Harkes, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Daco Harkes

Nate Biggs added 1 comment

File pkg/dart2wasm/lib/compile.dart
Line 629, Patchset 6 (Latest): if (options.recordedUsesFile != null) {
Nate Biggs . unresolved

The `Translator` shouldn't be modifying the kernel so I don't really get what moving this before code generation does.

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 6
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 16:46:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Mar 4, 2026, 2:25:00 AM (6 days ago) Mar 4
to Nate Biggs, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Nate Biggs

Daco Harkes added 1 comment

File pkg/dart2wasm/lib/compile.dart
Line 629, Patchset 6: if (options.recordedUsesFile != null) {
Nate Biggs . resolved

The `Translator` shouldn't be modifying the kernel so I don't really get what moving this before code generation does.

Daco Harkes

Right. My reasoning was that if it doesn't modify anything, we should not rely on it either.

I've undone the changes, as they were not necessary.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Biggs
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 9
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Wed, 04 Mar 2026 07:24:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Biggs <nate...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Mar 4, 2026, 2:42:27 AM (6 days ago) Mar 4
to Nate Biggs, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Nate Biggs

Daco Harkes added 1 comment

File pkg/vm/lib/transformations/type_flow/transformer.dart
Line 2289, Patchset 4: node.isEnum = false;
Nate Biggs . resolved

Why do we need to preserve the enum-ness of an unused class?

Daco Harkes

Oh, we don't. 👍

Daco Harkes

Actually, we do 😄

Without this we start reporting the kind as class instead of enum in the record_use file for static methods nested in the enum.

I'll add it again to the CL where I add a test case that uncovered this.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Biggs
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 9
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Wed, 04 Mar 2026 07:42:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Daco Harkes <dacoh...@google.com>
Comment-In-Reply-To: Nate Biggs <nate...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Biggs (Gerrit)

unread,
Mar 4, 2026, 1:34:36 PM (6 days ago) Mar 4
to Daco Harkes, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Daco Harkes

Nate Biggs voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 12
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Wed, 04 Mar 2026 18:34:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Mar 5, 2026, 2:11:37 AM (5 days ago) Mar 5
to Nate Biggs, Commit Queue, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org

Daco Harkes 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 satisfiedCommit-Message-Has-TEST
  • requirement satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 12
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Thu, 05 Mar 2026 07:11:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Mar 5, 2026, 2:12:00 AM (5 days ago) Mar 5
to Daco Harkes, Nate Biggs, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org

Commit Queue submitted the change

Change information

Commit message:
[record_use] Enum const instances wasm

Dart2wasm has a bunch of optmizations/lowerings that the VM doesn't
have for enum instances.

Some metadata that we don't want to lose for enum const instance:

* Don't tree-shake any instance fields of classes and enhanced
enums annotated with `@RecordUse()`. (TFA)
* Don't let the `index` and `_name` fields be tree-shaken away (TFA).
(Achieved by adding pragma.)

Closes: https://github.com/dart-lang/native/issues/2908

TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart
CoreLibraryReviewExempt: Just adding a pragma.
Change-Id: I9c7bccafe9b2032731ed48b74747679f5939de8b
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-by: Nate Biggs <nate...@google.com>
Commit-Queue: Daco Harkes <dacoh...@google.com>
Files:
  • M pkg/dart2wasm/test/ir_tests/deferred.constant.type_use.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/deferred.fine_grained.devirtualized_module1.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.fine_grained_module5.wat
  • M pkg/dart2wasm/test/ir_tests/deferred.type_checks_module1.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/dynamic_call.wat
  • M pkg/dart2wasm/test/ir_tests/hello.wat
  • M pkg/dart2wasm/test/ir_tests/import_name_module1.wat
  • M pkg/dart2wasm/test/ir_tests/memory_use.wat
  • M pkg/dart2wasm/test/ir_tests/pure_function.wat
  • M pkg/dart2wasm/test/ir_tests/try_blocks.wat
  • M pkg/dart2wasm/test/record_use_test.dart
  • M pkg/vm/lib/transformations/type_flow/transformer.dart
  • M sdk/lib/core/enum.dart
Change size: M
Delta: 18 files changed, 56 insertions(+), 60 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Nate Biggs
  • requirement satisfiedCore-Library-Review: Code-Review+1 by Nate Biggs
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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 13
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
open
diffy
satisfied_requirement

Martin Kustermann (Gerrit)

unread,
7:41 AM (3 hours ago) 7:41 AM
to Daco Harkes, Commit Queue, Nate Biggs, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Daco Harkes

Martin Kustermann added 1 comment

File sdk/lib/core/enum.dart
Line 108, Patchset 13 (Latest): @pragma('wasm:entry-point')
Martin Kustermann . unresolved

Could you explain why we would add entrypoints for wasm here?

What may happen is that these fields get tree shaken and they may rightfully be so if they are not used.

Users have to mark fields they want to reflect on with some record use annotation and they should only reflect on those fields. Code they cannot control (like core libs or other packages) they should not reflect on.

This is by design: For example I think it's perfectly fine for us to e.g. rename `_name` to `_enumName` here. It shouldn't impact or break anyone.

If you want link hooks to reflect on these fields, then we have to commit on making those fields always be there, never renamed, etc. In that case those two fields here should have a `@RecordUse` annotation and not a `@pragma('wasm:entry-point')`.

In any case, I don't see why handling of these fields should have any wasm specific treatments.


Also: Could you please add me as reviewer when changing dart2wasm related things (as I'm probably the most knowledgeable person for that) and alexmarkov when touching TFA (as he's the most knowledgeable person for that)?

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 13
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-CC: Martin Kustermann <kuste...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 10 Mar 2026 11:41:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
8:09 AM (3 hours ago) 8:09 AM
to Commit Queue, Martin Kustermann, Nate Biggs, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org

Daco Harkes added 1 comment

File sdk/lib/core/enum.dart
Line 108, Patchset 13 (Latest): @pragma('wasm:entry-point')
Martin Kustermann . unresolved

Could you explain why we would add entrypoints for wasm here?

What may happen is that these fields get tree shaken and they may rightfully be so if they are not used.

Users have to mark fields they want to reflect on with some record use annotation and they should only reflect on those fields. Code they cannot control (like core libs or other packages) they should not reflect on.

This is by design: For example I think it's perfectly fine for us to e.g. rename `_name` to `_enumName` here. It shouldn't impact or break anyone.

If you want link hooks to reflect on these fields, then we have to commit on making those fields always be there, never renamed, etc. In that case those two fields here should have a `@RecordUse` annotation and not a `@pragma('wasm:entry-point')`.

In any case, I don't see why handling of these fields should have any wasm specific treatments.


Also: Could you please add me as reviewer when changing dart2wasm related things (as I'm probably the most knowledgeable person for that) and alexmarkov when touching TFA (as he's the most knowledgeable person for that)?

Daco Harkes

I tried to reconstruct the index and name in another way in dart2wasm but wasn't able to find the right information in the ast at the point where the recordings are done.

(We explored an approach where we do all the recordings in the AST super early before any optimizations and TFA in the metadata repository and then trim it down later after TFA, but that also became very messy. So we went back to the approach where we record after TFA and reconstruct information that is lowered.)

Is there a way to get the name and index in dart2wasm without these entry-points?

Also: Could you please add me as reviewer when changing dart2wasm related things (as I'm probably the most knowledgeable person for that) and alexmarkov when touching TFA (as he's the most knowledgeable person for that)?

Yes, I'm chatting with Alex. We should probably have a chat as well about the high level approach things for dart2wasm where they don't align with the VM (which they don't in a bunch of cases). I'll shoot you a calendar invite.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 13
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-CC: Martin Kustermann <kuste...@google.com>
Gerrit-Comment-Date: Tue, 10 Mar 2026 12:09:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Martin Kustermann <kuste...@google.com>
satisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
8:37 AM (2 hours ago) 8:37 AM
to Daco Harkes, Commit Queue, Nate Biggs, Alexander Markov, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Daco Harkes

Martin Kustermann added 1 comment

File sdk/lib/core/enum.dart
Line 108, Patchset 13 (Latest): @pragma('wasm:entry-point')
Martin Kustermann . unresolved

Could you explain why we would add entrypoints for wasm here?

What may happen is that these fields get tree shaken and they may rightfully be so if they are not used.

Users have to mark fields they want to reflect on with some record use annotation and they should only reflect on those fields. Code they cannot control (like core libs or other packages) they should not reflect on.

This is by design: For example I think it's perfectly fine for us to e.g. rename `_name` to `_enumName` here. It shouldn't impact or break anyone.

If you want link hooks to reflect on these fields, then we have to commit on making those fields always be there, never renamed, etc. In that case those two fields here should have a `@RecordUse` annotation and not a `@pragma('wasm:entry-point')`.

In any case, I don't see why handling of these fields should have any wasm specific treatments.


Also: Could you please add me as reviewer when changing dart2wasm related things (as I'm probably the most knowledgeable person for that) and alexmarkov when touching TFA (as he's the most knowledgeable person for that)?

Daco Harkes

I tried to reconstruct the index and name in another way in dart2wasm but wasn't able to find the right information in the ast at the point where the recordings are done.

(We explored an approach where we do all the recordings in the AST super early before any optimizations and TFA in the metadata repository and then trim it down later after TFA, but that also became very messy. So we went back to the approach where we record after TFA and reconstruct information that is lowered.)

Is there a way to get the name and index in dart2wasm without these entry-points?

Also: Could you please add me as reviewer when changing dart2wasm related things (as I'm probably the most knowledgeable person for that) and alexmarkov when touching TFA (as he's the most knowledgeable person for that)?

Yes, I'm chatting with Alex. We should probably have a chat as well about the high level approach things for dart2wasm where they don't align with the VM (which they don't in a bunch of cases). I'll shoot you a calendar invite.

Martin Kustermann

Is there a way to get the name and index in dart2wasm without these entry-points?

The issue here has probably nothing to do with dart2wasm per se.

It's more by coincidence that it's not an issue for the VM: Even the smallest program (`main() {}`) compiled in product mode in VM AOT still has enums in them - namely instances of `const _OS(...)` and `const _Architecture(...)` and because there's multiple of those constants with different index/names we don't tree shake the fields.

Though one could argue a program that doesn't use FFI things should get ffi stuff tree shaken out. It doesn't happen atm because e.g. `_checkAbiSpecificIntegerMapping` has a `@pragma('vm:entry-point')` annotation and uses `Abi.current` internally which then depends on various enum constants.

If we made the ffi things not be retained if the program doesn't use ffi, then we may encounter the same issue that you encounter in dart2wasm also on the native AOT.

So as mentioned in previous comment: If at all this should be a `@RecordFieldUse` annotation (or something like) which applies to all backends equally.

Yes, I'm chatting with Alex. We should probably have a chat as well about the high level approach things for dart2wasm where they don't align with the VM (which they don't in a bunch of cases). I'll shoot you a calendar invite.

sgtm

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement satisfiedCore-Library-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: I9c7bccafe9b2032731ed48b74747679f5939de8b
Gerrit-Change-Number: 484640
Gerrit-PatchSet: 13
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Alexander Markov <alexm...@google.com>
Gerrit-CC: Martin Kustermann <kuste...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 10 Mar 2026 12:37:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Martin Kustermann <kuste...@google.com>
Comment-In-Reply-To: Daco Harkes <dacoh...@google.com>
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages