Chromium Code Reviews| Index: src/IceGlobalContext.cpp |
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
| index 8805cea111ec69b3760ac52ffe6ce8009a744686..2caf7aead4457c8ffbb221ed4be5b149683af222 100644 |
| --- a/src/IceGlobalContext.cpp |
| +++ b/src/IceGlobalContext.cpp |
| @@ -160,11 +160,11 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
| } |
| void GlobalContext::translateFunctions() { |
| - while (Cfg *Func = cfgQueueBlockingPop()) { |
| + while (std::unique_ptr<Cfg> Func = cfgQueueBlockingPop()) { |
| + // Install Func in TLS for Cfg-specific container allocators. |
| + Cfg::updateTLS(Func.get()); |
|
JF
2015/02/02 20:59:19
Hmm, now TLS is asymmetric. Maybe updateTLS(nullpt
Jim Stichnoth
2015/02/03 00:48:51
Done.
|
| // Reset per-function stats being accumulated in TLS. |
| resetStats(); |
| - // Install Func in TLS for Cfg-specific container allocators. |
| - Func->updateTLS(); |
| // Set verbose level to none if the current function does NOT |
| // match the -verbose-focus command-line option. |
| if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn)) |
| @@ -189,10 +189,10 @@ void GlobalContext::translateFunctions() { |
| Func->emit(); |
| // TODO(stichnot): actually add to emit queue |
| } |
| - // TODO(stichnot): fix multithreaded stats dumping. |
| dumpStats(Func->getFunctionName()); |
| } |
| - delete Func; |
| + // The Cfg now gets deleted as Func goes out of scope. This also |
| + // resets the thread-local CurrentCfg field. |
| } |
| } |
| @@ -535,6 +535,14 @@ void GlobalContext::setTimerName(TimerStackIdT StackID, |
| Timers->at(StackID).setName(NewName); |
| } |
| +void GlobalContext::cfgQueueBlockingPush(std::unique_ptr<Cfg> Func) { |
| + CfgQ.blockingPush(Func.release()); |
| +} |
| + |
| +std::unique_ptr<Cfg> GlobalContext::cfgQueueBlockingPop() { |
| + return std::unique_ptr<Cfg>(CfgQ.blockingPop()); |
| +} |
|
JF
2015/02/02 20:59:19
It would be nice to explain that the cfgQueue take
Jim Stichnoth
2015/02/03 00:48:51
Done.
|
| + |
| void GlobalContext::dumpStats(const IceString &Name, bool Final) { |
| if (!ALLOW_DUMP || !getFlags().DumpStats) |
| return; |