Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Issue 2608763002: Move GritResourceMap arrays (~12,500 bytes) to read-only data segment (Closed)

Created:
3 years, 11 months ago by brucedawson
Modified:
3 years, 9 months ago
Reviewers:
Nico
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Move GritResourceMap arrays (~12,500 bytes) to read-only data segment Due to a quirk in VC++ it is easy to accidentally prevent a const global array from being placed in the read-only data segment. This change removes a should-be-harmless 'const' keyword to work around this quirk and move ~12,500 bytes to the .rdata (read-only) data segment in chrome.dll. VC++ bug is filed here: https://connect.microsoft.com/VisualStudio/feedback/details/3117602 Other instances of this quirk have also been worked around. BUG=677351

Patch Set 1 #

Patch Set 2 : Update unit tests to match new struct #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -5 lines) Patch
M tools/grit/grit/format/resource_map.py View 1 chunk +1 line, -1 line 0 comments Download
M tools/grit/grit/format/resource_map_unittest.py View 1 4 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 16 (11 generated)
brucedawson
I thought you might find this interesting or amusing. It is odd that *removing* const ...
3 years, 11 months ago (2016-12-29 20:00:53 UTC) #10
brucedawson
On 2016/12/29 20:00:53, brucedawson wrote: > I thought you might find this interesting or amusing. ...
3 years, 11 months ago (2016-12-31 21:49:59 UTC) #11
Nico
won't that hurt other compilers? it seems super hacky to work around such a basic ...
3 years, 11 months ago (2017-01-05 00:06:30 UTC) #12
brucedawson
On 2017/01/05 00:06:30, Nico (ooo sick) wrote: > won't that hurt other compilers? it seems ...
3 years, 11 months ago (2017-01-05 01:07:48 UTC) #13
brucedawson
3 years, 11 months ago (2017-01-14 00:10:25 UTC) #16
I looked at this again to see if there were any better solutions. A fix that
worked elsewhere was adding a constexpr constructor to the GritResourceMap type,
but that did not help here.

The ideal solution would be to mark all of the arrays as constexpr, but VC++
2015 does not support making constexpr objects visible outside of the
translation unit where they are defined. Pity. This should be fixed in VC++
2017.

So, our options are:
- Land it as is - because the arrays are all const this is safe
- Make the const conditional using an ifdef
- Close the issue - it only affects ~11 arrays totaling ~12.5 KB

The problem goes away anyway when we move off of VC++ 2015 so I'm not too
worried either way.

Powered by Google App Engine
This is Rietveld 408576698