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

Unified Diff: src/IceGlobalContext.cpp

Issue 872933002: Subzero: Second attempt at fixing MacOS 10.6 build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add llvm:: prefix Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceTLS.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 9e1b72c9f47486f1b34e47066b69570d4c1e2f93..d5766d4f57aa7b01baf5336dcf5e5ef21506990f 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -132,11 +132,18 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
: StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() {
+ // Make sure thread_local fields are properly initialized before any
+ // accesses are made. Do this here instead of at the start of
+ // main() so that all clients (e.g. unit tests) can benefit for
+ // free.
+ GlobalContext::TlsInit();
+ Cfg::TlsInit();
+
// Create a new ThreadContext for the current thread. No need to
// lock AllThreadContexts at this point since no other threads have
// access yet to this GlobalContext object.
AllThreadContexts.push_back(new ThreadContext());
- TLS = AllThreadContexts.back();
+ ICE_TLS_SET_FIELD(TLS, AllThreadContexts.back());
// Pre-register built-in stack names.
if (ALLOW_DUMP) {
// TODO(stichnot): There needs to be a strong relationship between
@@ -495,7 +502,7 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) {
if (Final) {
getStatsCumulative()->dump(Name, getStrDump());
} else {
- TLS->StatsFunction.dump(Name, getStrDump());
+ ICE_TLS_GET_FIELD(TLS)->StatsFunction.dump(Name, getStrDump());
getStatsCumulative()->dump("_TOTAL_", getStrDump());
}
}
@@ -518,6 +525,6 @@ TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func)
}
}
-ICE_ATTRIBUTE_TLS GlobalContext::ThreadContext *GlobalContext::TLS;
+ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
} // end of namespace Ice
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceTLS.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698