[M] Change in dart/sdk[main]: [vm/sdk] Use FinalThreadLocal for Iterable toString.

0 views
Skip to first unread message

Alexander Aprelev (Gerrit)

unread,
Dec 1, 2025, 11:56:47 AM (24 hours ago) Dec 1
to Alexander Aprelev, Lasse Nielsen, Slava Egorov, Commit Queue, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Slava Egorov

Alexander Aprelev voted and added 1 comment

Votes added by Alexander Aprelev

Commit-Queue+1

1 comment

File sdk/lib/_internal/vm_shared/lib/iterable_patch.dart
Line 15, Patchset 17: if (!_toStringVisiting.isBound) {
Slava Egorov . resolved

Given that we introduced `FinalThreadLocal` anyway... Maybe you can rewrite this code to use that instead. And I think when you do that you can share the iterableToFullString and iterableToShortString methods back - it becomes platform independent.

Platform dependent part is `toStringVisiting`, which for VM becomes:

```
List get toStringVisiting => _toStringVisiting.value;
...
```

And the rest of code can be shared.

Alexander Aprelev

Done

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 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: Iccdc218716cbbe2346aa85bb6134f4129debe057
Gerrit-Change-Number: 451841
Gerrit-PatchSet: 18
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Lasse Nielsen <l...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Mon, 01 Dec 2025 16:56:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
7:30 AM (4 hours ago) 7:30 AM
to Alexander Aprelev, Lasse Nielsen, Commit Queue, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Alexander Aprelev

Slava Egorov voted and added 1 comment

Votes added by Slava Egorov

Code-Review+1

1 comment

File sdk/lib/core/iterable.dart
Line 947, Patchset 23 (Latest): for (int i = 0; i < toStringVisiting.length; i++) {
Slava Egorov . unresolved

Consider caching result of getter, e.g.

```
final visiting = toStringVisiting;
for (int i = 0; i < visiting.length; i++) {
if (identical(object, visiting[i])) return true;
}
return false;
```
Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not 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: Iccdc218716cbbe2346aa85bb6134f4129debe057
Gerrit-Change-Number: 451841
Gerrit-PatchSet: 23
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Lasse Nielsen <l...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Comment-Date: Tue, 02 Dec 2025 12:29:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
9:08 AM (2 hours ago) 9:08 AM
to Alexander Aprelev, Slava Egorov, Lasse Nielsen, Commit Queue, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org

Alexander Aprelev voted and added 2 comments

Votes added by Alexander Aprelev

Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 25 (Latest):
Alexander Aprelev . resolved

thank you Slava

File sdk/lib/core/iterable.dart
Line 947, Patchset 23: for (int i = 0; i < toStringVisiting.length; i++) {
Slava Egorov . resolved

Consider caching result of getter, e.g.

```
final visiting = toStringVisiting;
for (int i = 0; i < visiting.length; i++) {
if (identical(object, visiting[i])) return true;
}
return false;
```
Alexander Aprelev

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • 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: Iccdc218716cbbe2346aa85bb6134f4129debe057
    Gerrit-Change-Number: 451841
    Gerrit-PatchSet: 25
    Gerrit-Owner: Alexander Aprelev <a...@google.com>
    Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
    Gerrit-Reviewer: Lasse Nielsen <l...@google.com>
    Gerrit-Reviewer: Slava Egorov <veg...@google.com>
    Gerrit-Comment-Date: Tue, 02 Dec 2025 14:08:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Slava Egorov <veg...@google.com>
    satisfied_requirement
    open
    diffy

    Lasse Nielsen (Gerrit)

    unread,
    10:20 AM (1 hour ago) 10:20 AM
    to Alexander Aprelev, Slava Egorov, Commit Queue, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
    Attention needed from Alexander Aprelev

    Lasse Nielsen voted and added 8 comments

    Votes added by Lasse Nielsen

    Code-Review-1

    8 comments

    Patchset-level comments
    Lasse Nielsen . resolved

    Don't move map-function into `Iterable` and don't make the helper functions public.

    File pkg/vm_snapshot_analysis/test/instruction_sizes_test.dart
    Line 890, Patchset 25 (Latest): const smallChangeThreshold = 13;
    Lasse Nielsen . resolved

    (Arbitrary number just changed arbitrarily, for _reasons_! 😜)

    File sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart
    Line 768, Patchset 25 (Latest): static List<Object> get toStringVisiting => _toStringVisiting;
    Lasse Nielsen . unresolved
    That looks like it's just
    ```dart
    @patch
    static final List<Object> toStringVisiting = [];
    ```
    with more steps. Unless that's not an allowed patch, then it's *necessary* more steps. Is it necessary?
    File sdk/lib/collection/maps.dart
    Line 110, Patchset 25 (Latest): static String mapToString(Map<Object?, Object?> m) => Iterable.mapToString(m);
    Lasse Nielsen . unresolved

    Don't move this function. It doesn't belong in `Iterable`.

    File sdk/lib/core/iterable.dart
    Line 917, Patchset 25 (Latest): static String mapToString(Map<Object?, Object?> m) {
    Lasse Nielsen . unresolved

    This is a new public function.
    It used to be in `MapBase` and now it's in `Iterable`.

    If it's no longer in `MapBase`, that's a breaking change, so don't remove it.
    Also, it doesn't really belong in `Iterable`, maps are not `Iterable`, so why move it here?

    If it stays, it should have a `@Since("3.11")`, or whatever version it goes into, and be documented in the CHANGELOG.md.

    If you want to share it without needing to import `dart:collection`, then put it in `dart:_internal` and let `MapBase` reference it there.

    Line 946, Patchset 25 (Latest): static bool isToStringVisiting(Object object) {
    Lasse Nielsen . unresolved

    This should *probably* not be public.

    Line 955, Patchset 25 (Latest): external static List<Object> get toStringVisiting;
    Lasse Nielsen . unresolved

    This should _definitely_ not be public.
    (Which tips the `toStringVisiting` towards not being public either.)

    File sdk/lib/internal/internal.dart
    Line 1135, Patchset 25 (Parent):}
    Lasse Nielsen . unresolved

    Why moved?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alexander Aprelev
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is blockingCode-Review
    • 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: Iccdc218716cbbe2346aa85bb6134f4129debe057
    Gerrit-Change-Number: 451841
    Gerrit-PatchSet: 25
    Gerrit-Owner: Alexander Aprelev <a...@google.com>
    Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
    Gerrit-Reviewer: Lasse Nielsen <l...@google.com>
    Gerrit-Reviewer: Slava Egorov <veg...@google.com>
    Gerrit-Attention: Alexander Aprelev <a...@google.com>
    Gerrit-Comment-Date: Tue, 02 Dec 2025 15:20:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    blocking_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages