[XL] Change in dart/sdk[main]: [vm,modular_aot] Boxing/unboxing of int and double values

0 views
Skip to first unread message

Alexander Markov (Gerrit)

unread,
Mar 6, 2026, 1:42:27 PM (3 days ago) Mar 6
to Alexander Markov, Slava Egorov, Tess Strickland, Alexander Aprelev, Nate Biggs, Nicholas Shahan, Stephen Adams, Commit Queue, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedCommit-Message-Has-TEST
  • 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: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
Gerrit-Change-Number: 486240
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Fri, 06 Mar 2026 18:42:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
Mar 9, 2026, 9:44:35 AM (16 hours ago) Mar 9
to Alexander Markov, Tess Strickland, Alexander Aprelev, Nate Biggs, Nicholas Shahan, Stephen Adams, Commit Queue, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Markov

Slava Egorov voted and added 3 comments

Votes added by Slava Egorov

Code-Review+1

3 comments

File pkg/cfg/lib/ir/constant_value.dart
Line 390, Patchset 2 (Latest): int get hashCode => value.isNaN ? 31 : value.hashCode;
Slava Egorov . unresolved

Needs a comment to explain why `value.hashCode` is not good enough and why we need special case for NaN here. It's not obvious to me - I guess you want different NaNs to get the same hash code? `operator==` has no special provision and just uses `identical()` which would compare different NaNs as not-equal.

File pkg/cfg/lib/passes/constant_propagation.dart
Line 555, Patchset 2 (Latest): _setNonConstant(instr);
Slava Egorov . unresolved

TODO, I guess?

File pkg/native_compiler/lib/passes/unboxing.dart
Line 46, Patchset 2 (Latest): Phi() => _unboxedPhis[instr.id],
Slava Egorov . unresolved

I find it strange that this is not a property of the `Phi` means that after this pass we don't know anything about the type of the phi? Feels iffy.

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedCommit-Message-Has-TEST
  • 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: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
Gerrit-Change-Number: 486240
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Mon, 09 Mar 2026 13:44:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Mar 9, 2026, 11:32:22 AM (14 hours ago) Mar 9
to Alexander Markov, Slava Egorov, Tess Strickland, Alexander Aprelev, Nate Biggs, Nicholas Shahan, Stephen Adams, Commit Queue, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

Alexander Markov voted and added 4 comments

Votes added by Alexander Markov

Commit-Queue+1

4 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Alexander Markov . resolved

Slava, thank you for taking a look!

File pkg/cfg/lib/ir/constant_value.dart
Line 390, Patchset 2: int get hashCode => value.isNaN ? 31 : value.hashCode;
Slava Egorov . resolved

Needs a comment to explain why `value.hashCode` is not good enough and why we need special case for NaN here. It's not obvious to me - I guess you want different NaNs to get the same hash code? `operator==` has no special provision and just uses `identical()` which would compare different NaNs as not-equal.

Alexander Markov

`value.hashCode` should be good enough, cleaned up this code.

File pkg/cfg/lib/passes/constant_propagation.dart
Line 555, Patchset 2: _setNonConstant(instr);
Slava Egorov . unresolved

TODO, I guess?

Alexander Markov

My thinking is that constant propagation should be performed earlier in the pipeline, before box/unbox instructions are introduced (unboxing should happen very late in the pipeline). So I was borderline between adding `throw 'Unxpected'` and just making box/unbox instructions non-constant. Is there a good reason to perform constant propagation after unboxing too?

File pkg/native_compiler/lib/passes/unboxing.dart
Line 46, Patchset 2: Phi() => _unboxedPhis[instr.id],
Slava Egorov . resolved

I find it strange that this is not a property of the `Phi` means that after this pass we don't know anything about the type of the phi? Feels iffy.

Alexander Markov

This property is preserved by keeping the whole `Unboxing` pass in the `BackEndState`, where it can be accessed by the back-end. Currently only regalloc uses it in order to pick FP register class for unboxed doubles.

I didn't add the unboxed property directly to `Phi` to avoid cluttering core back-end independent instruction with back-end specific details.

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedCommit-Message-Has-TEST
  • 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: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
Gerrit-Change-Number: 486240
Gerrit-PatchSet: 3
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Mon, 09 Mar 2026 15:32:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Mar 9, 2026, 2:33:58 PM (11 hours ago) Mar 9
to Alexander Markov, Slava Egorov, Tess Strickland, Alexander Aprelev, Nate Biggs, Nicholas Shahan, Stephen Adams, Commit Queue, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

Alexander Markov voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedCommit-Message-Has-TEST
    • 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: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
    Gerrit-Change-Number: 486240
    Gerrit-PatchSet: 4
    Gerrit-Owner: Alexander Markov <alexm...@google.com>
    Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
    Gerrit-Reviewer: Slava Egorov <veg...@google.com>
    Gerrit-CC: Alexander Aprelev <a...@google.com>
    Gerrit-CC: Nate Biggs <nate...@google.com>
    Gerrit-CC: Nicholas Shahan <nsh...@google.com>
    Gerrit-CC: Stephen Adams <s...@google.com>
    Gerrit-CC: Tess Strickland <sstr...@google.com>
    Gerrit-Attention: Slava Egorov <veg...@google.com>
    Gerrit-Comment-Date: Mon, 09 Mar 2026 18:33:55 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Commit Queue (Gerrit)

    unread,
    Mar 9, 2026, 2:34:13 PM (11 hours ago) Mar 9
    to Alexander Markov, Slava Egorov, Tess Strickland, Alexander Aprelev, Nate Biggs, Nicholas Shahan, Stephen Adams, rev...@dartlang.org, vm-...@dartlang.org

    Commit Queue submitted the change with unreviewed changes

    Unreviewed changes

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

    ```
    The name of the file: pkg/cfg/lib/ir/constant_value.dart
    Insertions: 1, Deletions: 1.

    @@ -387,7 +387,7 @@
    String toString() => 'UnboxedDoubleConstant($value)';

    @override
    - int get hashCode => value.isNaN ? 31 : value.hashCode;
    + int get hashCode => value.hashCode;

    @override
    bool operator ==(Object other) =>
    ```

    Change information

    Commit message:
    [vm,modular_aot] Boxing/unboxing of int and double values

    TEST=ci
    Issue: https://github.com/dart-lang/sdk/issues/61635
    Change-Id: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
    Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486240
    Commit-Queue: Alexander Markov <alexm...@google.com>
    Reviewed-by: Slava Egorov <veg...@google.com>
    Files:
    • M pkg/cfg/lib/ir/constant_value.dart
    • M pkg/cfg/lib/ir/flow_graph_checker.dart
    • M pkg/cfg/lib/ir/instructions.dart
    • M pkg/cfg/lib/ir/visitor.dart
    • M pkg/cfg/lib/passes/constant_propagation.dart
    • M pkg/cfg/lib/passes/simplification.dart
    • M pkg/native_compiler/lib/back_end/arm64/assembler.dart
    • M pkg/native_compiler/lib/back_end/arm64/code_generator.dart
    • M pkg/native_compiler/lib/back_end/arm64/constraints.dart
    • M pkg/native_compiler/lib/back_end/arm64/stub_code_generator.dart
    • M pkg/native_compiler/lib/back_end/assembler.dart
    • M pkg/native_compiler/lib/back_end/back_end_state.dart
    • M pkg/native_compiler/lib/back_end/register_allocator.dart
    • M pkg/native_compiler/lib/configuration.dart
    • M pkg/native_compiler/lib/passes/lowering.dart
    • A pkg/native_compiler/lib/passes/unboxing.dart
    • M pkg/native_compiler/lib/snapshot/snapshot.dart
    • M pkg/native_compiler/test/back_end/arm64/assembler_test.dart
    • M pkg/native_compiler/test/back_end/arm64/disassembler.dart
    • M pkg/native_compiler/test/ir_test.dart
    • M pkg/native_compiler/testcases/lowering_test.dart.expect
    • M pkg/native_compiler/testcases/reorder_blocks_test.dart.expect
    • A pkg/native_compiler/testcases/unboxing_test.dart
    • A pkg/native_compiler/testcases/unboxing_test.dart.expect
    • M runtime/vm/module_snapshot.cc
    Change size: XL
    Delta: 25 files changed, 1057 insertions(+), 103 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Slava Egorov
    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: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
    Gerrit-Change-Number: 486240
    Gerrit-PatchSet: 5
    Gerrit-Owner: Alexander Markov <alexm...@google.com>
    Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
    Gerrit-Reviewer: Slava Egorov <veg...@google.com>
    Gerrit-CC: Alexander Aprelev <a...@google.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages