Skip to content

Use int.oneBitCount in PersistentHashMap and scope 53-bit caps to JS - #195005

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
kevmoo:numeric-spot-cleanup
Oct 28, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
kevmoo:numeric-spot-cleanup

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Replace the hand-rolled 32-bit SWAR _bitCount helper with Dart 3.13's int.oneBitCount, and narrow the 2^53 integer bounds in SliverMultiBoxAdaptorElement and OverlayPortalController from kIsWeb to kIsWeb && !kIsWasm (with TODOs to adopt double.maxSafeInteger / double.minSafeInteger on Dart 3.15).

Fixes #189716

Pre-launch Checklist

Replace hand-rolled `_bitCount` with `int.oneBitCount`, narrow `kIsWeb` 53-bit bounds in `sliver.dart` and `overlay.dart` to `kIsWeb && !kIsWasm`, and add Dart 3.15 `double.maxSafeInteger`/`minSafeInteger` TODOs.

Fixes flutter#189716
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 21, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Oct 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors PersistentHashMap to use the oneBitCount property instead of the custom _bitCount helper function, and adds a corresponding unit test. It also updates the _wallTime in OverlayPortalController and max in SliverMultiBoxAdaptorElement to check for kIsWeb && !kIsWasm instead of just kIsWeb, with TODO comments to use double.minSafeInteger and double.maxSafeInteger once the minimum Dart SDK is 3.15. There are no review comments, so I have no feedback to provide.

@kevmoo
kevmoo requested a review from Piinks October 21, 2026 22:13
Piinks
Piinks previously requested changes Oct 23, 2026

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One cross-cutting note alongside two small test comments inline: per the repo style guide for TODOs (https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#todo-comments), could you file and link a tracking flutter/flutter issue in the two new TODO(kevmoo) comments for adopting double.minSafeInteger and double.maxSafeInteger once our minimum Dart SDK reaches 3.15? Having an issue like #189716 makes these much easier to find when we bump the SDK constraint.

…ests

- Link flutter#195202 in the Dart 3.15 safe-integer TODO comments in `overlay.dart` and `sliver.dart`.
- Move index 31 first in `persistent_hash_map_test.dart` and test `_FullNode` inflation while bit 31 is occupied.
- Add `SliverMultiBoxAdaptorElement.childCount` widget test covering `2^53 - 1`, `2^53`, and `> 2^53` across JS web, Wasm, and VM.
@kevmoo

kevmoo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Filed #195202 and linked it in both TODO(kevmoo) comments alongside the updated PersistentHashMap and SliverList tests in 9f57a99.

@kevmoo
kevmoo dismissed Piinks’s stale review October 23, 2026 23:51

Addressed in 9f57a99 with #195202 linked in both TODOs and expanded bit-31 and SliverList tests; re-requesting review from Piinks.

@kevmoo
kevmoo requested a review from Piinks October 23, 2026 23:51

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 28, 2026
Merged via the queue into flutter:master with commit 9d1cdd5 Oct 28, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2026
@kevmoo
kevmoo deleted the numeric-spot-cleanup branch October 28, 2026 17:42
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2026
flutter/flutter@d4c8577...0c2473c

2026-10-28 [email protected] Roll Packages from a8549ae to 13d38e0 (9 revisions) (flutter/flutter#195488)
2026-10-28 [email protected] Use int.oneBitCount in PersistentHashMap and scope 53-bit caps to JS (flutter/flutter#195005)
2026-10-28 [email protected] Roll pub packages (flutter/flutter#195483)
2026-10-28 [email protected] [iPhone Duo] Use the correct UIScreen to report the display size and update when fold/unfold (flutter/flutter#195199)
2026-10-28 [email protected] [fuchsia] Fix portable_ui_test.h includes for newer Fuchsia SDKs (flutter/flutter#195420)
2026-10-28 [email protected] Change default pipeline options to match production draw calls (flutter/flutter#194597)
2026-10-28 [email protected] Roll Fuchsia Test Scripts from 2T18KC7-LDQtmQiLP... to xl1LWBuppzu-BnOzV... (flutter/flutter#195450)
2026-10-27 [email protected] [flutter_tools] Inject dependencies into Darwin build targets, native assets, and Xcode build settings (flutter/flutter#194052)
2026-10-27 [email protected] Revert: Reland square corners fix (flutter/flutter#195436)
2026-10-27 [email protected] [flutter_tools] Add DeviceService app launch and flutter run support for tool extensions (flutter/flutter#194589)
2026-10-27 [email protected] [engine] Honor targetWidth/targetHeight for animated images (flutter/flutter#194615)
2026-10-27 [email protected] [Android][a11y] Set visibleToUser=false for hidden semantics nodes (flutter/flutter#194411)
2026-10-27 [email protected] Fix repo deletion test flake (flutter/flutter#195349)
2026-10-27 [email protected] Roll Packages from 23a05b6 to a8549ae (10 revisions) (flutter/flutter#195434)
2026-10-27 [email protected] [web] Capture pointers to the Flutter view so drags survive platform view iframes (flutter/flutter#195187)
2026-10-27 [email protected] [web] Add opt-in raw samples, measured sample count and warm-up phase hook to the web benchmark recorder (flutter/flutter#195118)
2026-10-27 [email protected] Link migration guide in deprecation messages (flutter/flutter#195361)
2026-10-27 [email protected] Pin basic_material_app_macos__compile to macOS 26 (flutter/flutter#195429)
2026-10-27 [email protected] Add benchmark for warmed pipeline usage (flutter/flutter#195001)
2026-10-27 [email protected] [flutter_tools] Add device log streaming support to DeviceService and ExtensionBackedDevice (flutter/flutter#194964)
2026-10-27 [email protected] Roll Dart SDK from 1d16c04dc346 to 65fc979759ca (4 revisions) (flutter/flutter#195383)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…lutter#195005)

Replace the hand-rolled 32-bit SWAR `_bitCount` helper with Dart 3.13's
`int.oneBitCount`, and narrow the `2^53` integer bounds in
`SliverMultiBoxAdaptorElement` and `OverlayPortalController` from
`kIsWeb` to `kIsWeb && !kIsWasm` (with `TODO`s to adopt
`double.maxSafeInteger` / `double.minSafeInteger` on Dart 3.15).

Fixes flutter#189716

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace _bitCount popcount in persistent_hash_map.dart with int.oneBitCount

2 participants