base/numerics cleanup 2/n: More modern techniques [chromium/src : main]

0 views
Skip to first unread message

Peter Kasting (Gerrit)

unread,
Nov 12, 2024, 2:42:30 PMNov 12
to Stefan Zager, Stephen Chenney, Dirk Schulze, AyeAye, findit...@appspot.gserviceaccount.com, Tom Sepez, Tricium, Chromium LUCI CQ, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org
Attention needed from Stefan Zager and Tom Sepez

Peter Kasting voted and added 1 comment

Votes added by Peter Kasting

Auto-Submit+0

1 comment

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Peter Kasting . resolved

+szager for trivial Blink change

Open in Gerrit

Related details

Attention is currently required from:
  • Stefan Zager
  • Tom Sepez
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Gerrit-Change-Number: 6011505
Gerrit-PatchSet: 4
Gerrit-Owner: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Stefan Zager <sza...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Nov 2024 19:42:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Nov 12, 2024, 3:56:59 PMNov 12
to Peter Kasting, findit...@appspot.gserviceaccount.com, Stefan Zager, Stephen Chenney, Dirk Schulze, AyeAye, Tricium, Chromium LUCI CQ, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org
Attention needed from Peter Kasting and Stefan Zager

Tom Sepez voted and added 4 comments

Votes added by Tom Sepez

Code-Review+1

4 comments

File base/numerics/checked_math_impl.h
Line 538, Patchset 4 (Latest): // Written this way because std::isfinite is not reliably constexpr.
Tom Sepez . unresolved

nit: maybe mention that it might be in C++23 ?

File base/numerics/clamped_math_impl.h
Line 120, Patchset 4 (Latest): if (!std::is_constant_evaluated() && ClampedMulFastOp<T, U>::is_supported) {
Tom Sepez . unresolved

can this be constexpr-if ?

File base/safe_numerics_unittest.cc
Line 1896, Patchset 4 (Parent):void TestWrappingMathSigned() {
Tom Sepez . resolved

Nice, how this folds into one overloaded form.

File third_party/blink/renderer/platform/geometry/layout_unit.h
Line 358, Patchset 4 (Latest): if (std::is_constant_evaluated() || sizeof(Storage) > sizeof(int)) {
Tom Sepez . unresolved

constexpr-if ? and below.

Open in Gerrit

Related details

Attention is currently required from:
  • Peter Kasting
  • Stefan Zager
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Gerrit-Change-Number: 6011505
Gerrit-PatchSet: 4
Gerrit-Owner: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Peter Kasting <pkas...@chromium.org>
Gerrit-Attention: Stefan Zager <sza...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Nov 2024 20:56:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Nov 12, 2024, 3:57:31 PMNov 12
to Peter Kasting, findit...@appspot.gserviceaccount.com, Stefan Zager, Stephen Chenney, Dirk Schulze, AyeAye, Tricium, Chromium LUCI CQ, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org
Attention needed from Peter Kasting and Stefan Zager

Tom Sepez added 1 comment

File base/numerics/checked_math_impl.h
Line 538, Patchset 4 (Latest): // Written this way because std::isfinite is not reliably constexpr.
Tom Sepez . unresolved

nit: maybe mention that it might be in C++23 ?

Tom Sepez

or rather, that it will be if I'm reading cppreference correctly.

Gerrit-Comment-Date: Tue, 12 Nov 2024 20:57:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Stefan Zager (Gerrit)

unread,
Nov 12, 2024, 4:20:07 PMNov 12
to Peter Kasting, Tom Sepez, findit...@appspot.gserviceaccount.com, Stephen Chenney, Dirk Schulze, AyeAye, Tricium, Chromium LUCI CQ, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org
Attention needed from Peter Kasting

Stefan Zager voted and added 1 comment

Votes added by Stefan Zager

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Stefan Zager . resolved

lgtm % tsepez comments

Open in Gerrit

Related details

Attention is currently required from:
  • Peter Kasting
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Gerrit-Change-Number: 6011505
Gerrit-PatchSet: 5
Gerrit-Owner: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Peter Kasting <pkas...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Nov 2024 21:19:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Peter Kasting (Gerrit)

unread,
Nov 12, 2024, 6:50:26 PMNov 12
to Stefan Zager, Tom Sepez, findit...@appspot.gserviceaccount.com, Stephen Chenney, Dirk Schulze, AyeAye, Tricium, Chromium LUCI CQ, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org

Peter Kasting added 3 comments

File base/numerics/checked_math_impl.h
Line 538, Patchset 4: // Written this way because std::isfinite is not reliably constexpr.
Tom Sepez . resolved

nit: maybe mention that it might be in C++23 ?

Tom Sepez

or rather, that it will be if I'm reading cppreference correctly.

Peter Kasting

Done

File base/numerics/clamped_math_impl.h
Line 120, Patchset 4: if (!std::is_constant_evaluated() && ClampedMulFastOp<T, U>::is_supported) {
Tom Sepez . resolved

can this be constexpr-if ?

Peter Kasting

It cannot; if you force the conditional to be compile-time-evaluated like that, then `is_constant_evaluated()` is always true, so the negative branch becomes dead, and the compiler yells at you.

This is sorta weird and unintuitive, I had to test it.

File third_party/blink/renderer/platform/geometry/layout_unit.h
Line 358, Patchset 4: if (std::is_constant_evaluated() || sizeof(Storage) > sizeof(int)) {
Tom Sepez . resolved

constexpr-if ? and below.

Peter Kasting

Acknowledged

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Gerrit-Change-Number: 6011505
Gerrit-PatchSet: 5
Gerrit-Owner: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Nov 2024 23:50:12 +0000
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Nov 12, 2024, 8:23:00 PMNov 12
to Peter Kasting, Stefan Zager, Tom Sepez, findit...@appspot.gserviceaccount.com, Stephen Chenney, Dirk Schulze, AyeAye, Tricium, chromium...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, fmalit...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fserb...@chromium.org

Chromium LUCI CQ submitted the change with unreviewed changes

Unreviewed changes

5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
base/numerics cleanup 2/n: More modern techniques

* Use `std::is_constant_evaluated()`
* Use `_t` versions of type traits
* Use concepts more when available
* Convert more asserts to constraints
* const -> constexpr more
* if -> constexpr if more
* =default and assign-in-declaration
* `std::conditional_t<>` instead of specializations more
* Rely on C++20 rewritten comparison ops
* assert message is optional

Also removes a few pieces of dead code.
Bug: none
Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Reviewed-by: Stefan Zager <sza...@chromium.org>
Commit-Queue: Peter Kasting <pkas...@chromium.org>
Reviewed-by: Tom Sepez <tse...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382091}
Files:
  • M base/numerics/checked_math.h
  • M base/numerics/checked_math_impl.h
  • M base/numerics/clamped_math.h
  • M base/numerics/clamped_math_impl.h
  • M base/numerics/safe_conversions.h
  • M base/numerics/safe_conversions_impl.h
  • M base/safe_numerics_unittest.cc
  • M third_party/blink/renderer/platform/geometry/layout_unit.h
Change size: L
Delta: 8 files changed, 269 insertions(+), 350 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifd3dbd5e4d0713630ed20ddad41f117ba963a354
Gerrit-Change-Number: 6011505
Gerrit-PatchSet: 7
Gerrit-Owner: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Peter Kasting <pkas...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages