Closed Bug 1602749 Opened 5 years ago Closed 5 years ago

Operations on CheckedInt should be constexpr

Categories

(Core :: MFBT, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(1 file)

No description provided.

This is approximately easy to do, of course. It does, however, somewhat foreclose changing CheckedInt functions to use compiler intrinsics to most efficiently (e.g. with direct knowledge of flags-register contents and specific instructions to implicitly observe these stateful results; in principle the compiler ought be able to understand this in plain ol' code; in practice I'm not sure they all do) perform computations with best-optimizable control flow. (At least, unless the intrinsics themselves are constexpr. They might be, with some or all compilers.) This may or may not be something to concern ourselves over.

Builtins such as __builtin_add_overflow are constexpr with GCC from at least 7.1 (the minimum supported version) and clang 7. They are not constexpr for clang 5 and 6. I will submit a patch that adds constexpr that handles this by reverting to not use the builtins with clang 5 and 6. If this is deemed not acceptable for performance reasons, it can be done in a different but less reabable way, using __builtin_constant_p in each function using __builtin_*_overflow. I am not sure how critical code generation with these old clang versions is.

Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/621dfa36a301 Make CheckedInt operations constexpr. r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: