Repository navigation
Make iOS Color default constructor constexpr - #59044
Open
christophpurrer wants to merge 1 commit into
Open
christophpurrer wants to merge 1 commit into
christophpurrer wants to merge 1 commit into
Conversation
Summary: WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting. Agent: PRE Agent | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/865a7ddc-4190-4005-a3f5-2b8db052633f/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/67553995153430156/ --- ## The issue - On iOS, `HostPlatformColor.h` defines `NO_DESTROY static const Color UndefinedColor = Color();` at namespace scope. `Color()` is not `constexpr`, and it leaves `uiColorHashValue_` uninitialized, so every Objective-C++ translation unit that includes the header emits its own dynamic static initializer, which runs before `main`. - The header now reaches more translation units through the `<React/Graphics.h>` umbrella, and each new includer adds one more pre-main initializer. ## The fix - Make `Color()` `constexpr` and zero-initialize `uiColorHashValue_`, so `UndefinedColor` is constant-initialized and no longer emits an initializer. - This also gives the undefined color a defined hash value instead of an indeterminate one. - Update the Apple C++ API snapshots for the `constexpr` constructor. Changelog: [Internal] Differential Revision: D124952738
|
@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124952738. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting.
Agent: PRE Agent | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/865a7ddc-4190-4005-a3f5-2b8db052633f/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/67553995153430156/
The issue
HostPlatformColor.hdefinesNO_DESTROY static const Color UndefinedColor = Color();at namespace scope.Color()is notconstexpr, and it leavesuiColorHashValue_uninitialized, so every Objective-C++ translation unit that includes the header emits its own dynamic static initializer, which runs beforemain.<React/Graphics.h>umbrella, and each new includer adds one more pre-main initializer.The fix
Color()constexprand zero-initializeuiColorHashValue_, soUndefinedColoris constant-initialized and no longer emits an initializer.constexprconstructor.Changelog: [Internal]
Differential Revision: D124952738