[M] Change in dart/sdk[main]: [dart2bytecode] Visit new variables in Visitors of dart2bytecode

0 views
Skip to first unread message

Chloe Stefantsova (Gerrit)

unread,
Mar 12, 2026, 11:51:03 AMMar 12
to Chloe Stefantsova, Alexander Markov, Commit Queue, Jens Johansen, rev...@dartlang.org
Attention needed from Alexander Markov

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
Submit Requirements:
  • requirement is not 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: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Gerrit-Change-Number: 487381
Gerrit-PatchSet: 3
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-CC: Jens Johansen <je...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Thu, 12 Mar 2026 15:50:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Mar 12, 2026, 12:12:59 PMMar 12
to Chloe Stefantsova, Alexander Markov, Commit Queue, Jens Johansen, rev...@dartlang.org
Attention needed from Chloe Stefantsova

Alexander Markov voted and added 2 comments

Votes added by Alexander Markov

Code-Review+1

2 comments

File pkg/dart2bytecode/lib/local_vars.dart
Line 548, Patchset 3 (Latest): _handleFunctionParameter(node);
Alexander Markov . unresolved

What would be the right way to declare variables uniformly in the new world, without duplicated code in visitVariableInitialization/visitPositionalParameter/visitNamedParameter? Maybe we should have visitScope or visitContext which would declare all variables in it?

Line 853, Patchset 3 (Latest): void _allocateVariable(ExpressionVariable variable, {int? paramSlotIndex}) {
Alexander Markov . unresolved

The amount of `VariableDeclaration` -> `ExpressionVariable` and `.variable` -> `.expressionVariable` changes makes me wonder if we should:

1) Reserve a shorter class name `Variable` for expression variables, as it would make code much more readable. Current Variable can be called something like VariableBase, BaseVariable, AbstractVariable etc.

2) Perform global and mechanical renaming VariableDeclaration -> Variable and land it. Make their APIs compatible (e.g. Variable needs to have a getter and setter `initializer` even if it is going to delegate to VariableInitialization in the new world).

3) Mostly keep existing API even for new classes, just changing return values of some getters, e.g. VariableGet.variable would return Variable instead of VariableDeclaration, without changing the getter to `Variableget.expressionVariable`.

I think this would make overall migration much less painful - we would need a bit of preparation to make APIs compatible in a separate CL, then huge mechanical renaming CL and then we can switch to the new API under the flag without many repeated changes. WDYT?

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
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: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Gerrit-Change-Number: 487381
Gerrit-PatchSet: 3
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-CC: Jens Johansen <je...@google.com>
Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Comment-Date: Thu, 12 Mar 2026 16:12:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chloe Stefantsova (Gerrit)

unread,
Mar 13, 2026, 4:42:20 AMMar 13
to Chloe Stefantsova, Alexander Markov, Commit Queue, Jens Johansen, rev...@dartlang.org

Chloe Stefantsova voted and added 3 comments

Votes added by Chloe Stefantsova

Commit-Queue+2

3 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Chloe Stefantsova . resolved

Thank you for the review and the suggestions, Alex.

File pkg/dart2bytecode/lib/local_vars.dart
Line 548, Patchset 3 (Latest): _handleFunctionParameter(node);
Alexander Markov . resolved

What would be the right way to declare variables uniformly in the new world, without duplicated code in visitVariableInitialization/visitPositionalParameter/visitNamedParameter? Maybe we should have visitScope or visitContext which would declare all variables in it?

Chloe Stefantsova

I was planning to do that during Phase 2, where the bytecode generator starts recognizing variable contexts. Then visiting the parameters themselves would not be necessary.

Line 853, Patchset 3 (Latest): void _allocateVariable(ExpressionVariable variable, {int? paramSlotIndex}) {
Alexander Markov . resolved

The amount of `VariableDeclaration` -> `ExpressionVariable` and `.variable` -> `.expressionVariable` changes makes me wonder if we should:

1) Reserve a shorter class name `Variable` for expression variables, as it would make code much more readable. Current Variable can be called something like VariableBase, BaseVariable, AbstractVariable etc.

2) Perform global and mechanical renaming VariableDeclaration -> Variable and land it. Make their APIs compatible (e.g. Variable needs to have a getter and setter `initializer` even if it is going to delegate to VariableInitialization in the new world).

3) Mostly keep existing API even for new classes, just changing return values of some getters, e.g. VariableGet.variable would return Variable instead of VariableDeclaration, without changing the getter to `Variableget.expressionVariable`.

I think this would make overall migration much less painful - we would need a bit of preparation to make APIs compatible in a separate CL, then huge mechanical renaming CL and then we can switch to the new API under the flag without many repeated changes. WDYT?

Chloe Stefantsova

Thank you for the suggestions, Alex! I think some of them can be implemented right away, and some will need a further discussion.

1. I don't mind the renaming. I'm not extremely good at naming things, and I always welcome suggestions. I'll create a CL for that shortly.

2. A global and mechanical renaming can break on the boundary of migrated and unmigrated code. I can give it a go and see if it works well. In general though, doing the renaming as needed (lazily instead of eagerly) doesn't take too much time either. And I agree about the compatibility of the new and the old interfaces, and I try to follow that approach whenever possible. The delegating `initializer` setter, for example, was there from the very beginning in the `LocalVariable`.

3. Making `VariableGet.variable` return `Variable` instead of `VariableDeclaration` will be breaking for the backends that don't support the new variable model yet. That's the point of the `expressionVariable` getter, to use it in the code that supports the new model, while allowing the old `variable` getter to be used in the unmigrated code.

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: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Gerrit-Change-Number: 487381
Gerrit-PatchSet: 3
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-CC: Jens Johansen <je...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 08:42:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Alexander Markov <alexm...@google.com>
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Mar 13, 2026, 4:42:36 AMMar 13
to Chloe Stefantsova, Alexander Markov, Jens Johansen, rev...@dartlang.org

Commit Queue submitted the change

Change information

Commit message:
[dart2bytecode] Visit new variables in Visitors of dart2bytecode

Part of https://github.com/dart-lang/sdk/issues/61572
Change-Id: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Commit-Queue: Chloe Stefantsova <cstefa...@google.com>
Reviewed-by: Alexander Markov <alexm...@google.com>
Files:
  • M pkg/dart2bytecode/lib/bytecode_generator.dart
  • M pkg/dart2bytecode/lib/local_vars.dart
  • M pkg/kernel/lib/src/ast/variables.dart
Change size: M
Delta: 3 files changed, 58 insertions(+), 18 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Alexander Markov
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: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Gerrit-Change-Number: 487381
Gerrit-PatchSet: 4
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-CC: Jens Johansen <je...@google.com>
open
diffy
satisfied_requirement

Alexander Markov (Gerrit)

unread,
Mar 13, 2026, 8:48:25 AMMar 13
to Chloe Stefantsova, Commit Queue, Alexander Markov, Jens Johansen, rev...@dartlang.org

Alexander Markov added 1 comment

File pkg/dart2bytecode/lib/local_vars.dart
Line 853, Patchset 3: void _allocateVariable(ExpressionVariable variable, {int? paramSlotIndex}) {
Alexander Markov . resolved

The amount of `VariableDeclaration` -> `ExpressionVariable` and `.variable` -> `.expressionVariable` changes makes me wonder if we should:

1) Reserve a shorter class name `Variable` for expression variables, as it would make code much more readable. Current Variable can be called something like VariableBase, BaseVariable, AbstractVariable etc.

2) Perform global and mechanical renaming VariableDeclaration -> Variable and land it. Make their APIs compatible (e.g. Variable needs to have a getter and setter `initializer` even if it is going to delegate to VariableInitialization in the new world).

3) Mostly keep existing API even for new classes, just changing return values of some getters, e.g. VariableGet.variable would return Variable instead of VariableDeclaration, without changing the getter to `Variableget.expressionVariable`.

I think this would make overall migration much less painful - we would need a bit of preparation to make APIs compatible in a separate CL, then huge mechanical renaming CL and then we can switch to the new API under the flag without many repeated changes. WDYT?

Chloe Stefantsova

Thank you for the suggestions, Alex! I think some of them can be implemented right away, and some will need a further discussion.

1. I don't mind the renaming. I'm not extremely good at naming things, and I always welcome suggestions. I'll create a CL for that shortly.

2. A global and mechanical renaming can break on the boundary of migrated and unmigrated code. I can give it a go and see if it works well. In general though, doing the renaming as needed (lazily instead of eagerly) doesn't take too much time either. And I agree about the compatibility of the new and the old interfaces, and I try to follow that approach whenever possible. The delegating `initializer` setter, for example, was there from the very beginning in the `LocalVariable`.

3. Making `VariableGet.variable` return `Variable` instead of `VariableDeclaration` will be breaking for the backends that don't support the new variable model yet. That's the point of the `expressionVariable` getter, to use it in the code that supports the new model, while allowing the old `variable` getter to be used in the unmigrated code.

Alexander Markov

Re: 3. What I mean is to use one class `Variable` both as a new `ExpressionVariable` and old `VariableDeclaration`. In such a case we would not need extra getter`VariableGet.expressionVariable`. AST would just always (regardless of the flag) use node Variable, either in place of an old VariableDeclaration or when new ExpressionVariable was used.

The prerequisite is that full VariableDeclaration API should be present in Variable, front-end should always generate Variable nodes (but maybe with different parents depending on the flag). Just think of Variable as a renaming of old VariableDecalaration and adding new API / implemented interfaces to fit into the new hierarchy.

I think this would result in a much smoother transition. We can prune Variable API after switching the flag everywhere.

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: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Gerrit-Change-Number: 487381
Gerrit-PatchSet: 4
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-CC: Jens Johansen <je...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 12:48:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Chloe Stefantsova <cstefa...@google.com>
Comment-In-Reply-To: Alexander Markov <alexm...@google.com>
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages