Chromium Code Reviews| Index: src/IceGlobalContext.cpp | 
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp | 
| index 7ea7e5dd02d10eaa64310926fb54b3cc9d3d4efc..23fb1dc96f79abab97acb4d83fb14ecab1668356 100644 | 
| --- a/src/IceGlobalContext.cpp | 
| +++ b/src/IceGlobalContext.cpp | 
| @@ -119,7 +119,11 @@ GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, | 
| : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), | 
| ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), | 
| TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), | 
| - RNG(""), Timers(new TimerStack("main")) {} | 
| + RNG(""), NumTimerStackIds(0) { | 
| + // Pre-register built-in stack names. | 
| + newTimerStackID("Total across all functions"); | 
| + newTimerStackID("Per-function summary"); | 
| +} | 
| // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 
| // S<num>_ where <num> is the next base-36 value. If a type name | 
| @@ -381,13 +385,26 @@ ConstantList GlobalContext::getConstantPool(Type Ty) const { | 
| llvm_unreachable("Unknown type"); | 
| } | 
| -TimerIdT GlobalContext::getTimerID(const IceString &Name) { | 
| - return TimerStack::getTimerID(Name); | 
| +TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, | 
| + const IceString &Name) { | 
| + assert(StackID < Timers.size()); | 
| + return Timers[StackID].getTimerID(Name); | 
| +} | 
| + | 
| +TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { | 
| + Timers.push_back(TimerStack(Name)); | 
| + return NumTimerStackIds++; | 
| 
 
jvoung (off chromium)
2014/10/06 23:01:52
Could this just use Timers.size() (or return void)
 
Jim Stichnoth
2014/10/06 23:54:39
Done (and removed the NumTimerStackIds field entir
 
 | 
| } | 
| -void GlobalContext::pushTimer(TimerIdT ID) { Timers->push(ID); } | 
| +void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { | 
| + assert(StackID < Timers.size()); | 
| + Timers[StackID].push(ID); | 
| +} | 
| -void GlobalContext::popTimer(TimerIdT ID) { Timers->pop(ID); } | 
| +void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { | 
| + assert(StackID < Timers.size()); | 
| + Timers[StackID].pop(ID); | 
| +} | 
| void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 
| if (Flags.DumpStats) { | 
| @@ -400,6 +417,16 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 
| } | 
| } | 
| -void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } | 
| +void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { | 
| + assert(Timers.size() > StackID); | 
| + Timers[StackID].dump(getStrDump(), DumpCumulative); | 
| +} | 
| + | 
| +TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | 
| + : ID(ID), Ctx(Func->getContext()), | 
| + Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { | 
| + if (Active) | 
| + Ctx->pushTimer(ID); | 
| +} | 
| } // end of namespace Ice |