@@ -37,11 +37,9 @@ struct GlobalListNode {
37
37
GlobalListNode *next = nullptr ;
38
38
};
39
39
typedef IntrusiveList<GlobalListNode> ListOfGlobals;
40
- typedef DenseMap<uptr, ListOfGlobals> MapOfGlobals;
41
40
42
41
static Mutex mu_for_globals;
43
42
static ListOfGlobals list_of_all_globals;
44
- static MapOfGlobals map_of_globals_by_indicator;
45
43
46
44
static const int kDynamicInitGlobalsInitialCapacity = 512 ;
47
45
struct DynInitGlobal {
@@ -60,6 +58,19 @@ struct GlobalRegistrationSite {
60
58
typedef InternalMmapVector<GlobalRegistrationSite> GlobalRegistrationSiteVector;
61
59
static GlobalRegistrationSiteVector *global_registration_site_vector;
62
60
61
+ static ListOfGlobals &GlobalsByIndicator (uptr odr_indicator) {
62
+ using MapOfGlobals = DenseMap<uptr, ListOfGlobals>;
63
+
64
+ static MapOfGlobals *globals_by_indicator = nullptr ;
65
+ if (!globals_by_indicator) {
66
+ alignas (
67
+ alignof (MapOfGlobals)) static char placeholder[sizeof (MapOfGlobals)];
68
+ globals_by_indicator = new (placeholder) MapOfGlobals ();
69
+ }
70
+
71
+ return (*globals_by_indicator)[odr_indicator];
72
+ }
73
+
63
74
ALWAYS_INLINE void PoisonShadowForGlobal (const Global *g, u8 value) {
64
75
FastPoisonShadow (g->beg , g->size_with_redzone , value);
65
76
}
@@ -152,8 +163,7 @@ static void CheckODRViolationViaIndicator(const Global *g) {
152
163
if (g->odr_indicator == UINTPTR_MAX)
153
164
return ;
154
165
155
- ListOfGlobals &relevant_globals =
156
- map_of_globals_by_indicator[g->odr_indicator ];
166
+ ListOfGlobals &relevant_globals = GlobalsByIndicator (g->odr_indicator );
157
167
158
168
u8 *odr_indicator = reinterpret_cast <u8 *>(g->odr_indicator );
159
169
if (*odr_indicator == REGISTERED) {
0 commit comments