Move ~200 Feature objects to read-only memory in Windows builds
A VC++ bug was preventing base::Feature objects from going into the read-only section despite being tagged as const. Adding a constexpr constructor solves this problem. Some of the variables (kTimerThrottlingForHiddenFrames for instance) get optimized away entirely which is why the size changes are not symmetrical. The VC++ bug is: https://connect.microsoft.com/VisualStudio/feedback/details/3117602 Previous instances of this bug were worked around by deleting const but this seemed undesirable in this case. Luckily the constexpr fix seems to work just as well. Approximate deltas are: chrome.dll .text: -48 bytes change .rdata: 1216 bytes change .data: -1376 bytes change .reloc: -32 bytes change Total change: -240 bytes chrome_child.dll .text: -16 bytes change .rdata: 704 bytes change .data: -800 bytes change .reloc: 32 bytes change Total change: -80 bytes Modest, but it's good to move a few hundred variables to read-only memory. This should not affect other platforms. BUG=677351 Review-Url: https://codereview.chromium.org/2623373004 Cr-Commit-Position: refs/heads/master@{#443616}
This commit is contained in:
@ -32,6 +32,8 @@ enum FeatureState {
|
||||
// for a given feature name - generally defined as a constant global variable or
|
||||
// file static.
|
||||
struct BASE_EXPORT Feature {
|
||||
constexpr Feature(const char* name, FeatureState default_state)
|
||||
: name(name), default_state(default_state) {}
|
||||
// The name of the feature. This should be unique to each feature and is used
|
||||
// for enabling/disabling features via command line flags and experiments.
|
||||
const char* const name;
|
||||
|
Reference in New Issue
Block a user