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 878383004: Subzero: Fix timers for multithreaded translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup 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
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 413278fe1e35aeccbf1c6901e9bf9885c23aa2f7..40b74e886372cabbecd071fae4f274a5dba9b852 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -143,8 +143,9 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
// 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());
- ICE_TLS_SET_FIELD(TLS, AllThreadContexts.back());
+ ThreadContext *MyTLS = new ThreadContext();
+ AllThreadContexts.push_back(MyTLS);
+ ICE_TLS_SET_FIELD(TLS, MyTLS);
// Pre-register built-in stack names.
if (ALLOW_DUMP) {
// TODO(stichnot): There needs to be a strong relationship between
@@ -152,6 +153,7 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
newTimerStackID("Total across all functions");
newTimerStackID("Per-function summary");
}
+ Timers.initInto(MyTLS->Timers);
if (Flags.UseELFWriter) {
ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr));
}
@@ -503,38 +505,32 @@ TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) {
TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID,
const IceString &Name) {
- auto Timers = getTimers();
+ auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
assert(StackID < Timers->size());
return Timers->at(StackID).getTimerID(Name);
}
void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) {
- // TODO(stichnot): Timers are completely broken for multithreading; fix.
- if (getFlags().NumTranslationThreads)
- llvm::report_fatal_error("Timers and multithreading are currently broken");
- auto Timers = getTimers();
+ auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
assert(StackID < Timers->size());
Timers->at(StackID).push(ID);
}
void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
- // TODO(stichnot): Timers are completely broken for multithreading; fix.
- if (getFlags().NumTranslationThreads)
- llvm::report_fatal_error("Timers and multithreading are currently broken");
- auto Timers = getTimers();
+ auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
assert(StackID < Timers->size());
Timers->at(StackID).pop(ID);
}
void GlobalContext::resetTimer(TimerStackIdT StackID) {
- auto Timers = getTimers();
+ auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
assert(StackID < Timers->size());
Timers->at(StackID).reset();
}
void GlobalContext::setTimerName(TimerStackIdT StackID,
const IceString &NewName) {
- auto Timers = getTimers();
+ auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
assert(StackID < Timers->size());
Timers->at(StackID).setName(NewName);
}
@@ -560,8 +556,8 @@ void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
Timers->at(StackID).dump(getStrDump(), DumpCumulative);
}
-TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func)
- : ID(ID), Ctx(Func->getContext()), Active(false) {
+TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func, TimerStackIdT StackID)
+ : ID(ID), Ctx(Func->getContext()), StackID(StackID), Active(false) {
if (ALLOW_DUMP) {
Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled;
if (Active)

Powered by Google App Engine
This is Rietveld 408576698