OLD | NEW |
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file defines aspects of the compilation that persist across | 10 // This file defines aspects of the compilation that persist across |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ELFStreamer *ELFStr, VerboseMask Mask, | 129 ELFStreamer *ELFStr, VerboseMask Mask, |
130 TargetArch Arch, OptLevel Opt, | 130 TargetArch Arch, OptLevel Opt, |
131 IceString TestPrefix, const ClFlags &Flags) | 131 IceString TestPrefix, const ClFlags &Flags) |
132 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), | 132 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
133 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), | 133 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
134 TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() { | 134 TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() { |
135 // Create a new ThreadContext for the current thread. No need to | 135 // Create a new ThreadContext for the current thread. No need to |
136 // lock AllThreadContexts at this point since no other threads have | 136 // lock AllThreadContexts at this point since no other threads have |
137 // access yet to this GlobalContext object. | 137 // access yet to this GlobalContext object. |
138 AllThreadContexts.push_back(new ThreadContext()); | 138 AllThreadContexts.push_back(new ThreadContext()); |
139 TLS = AllThreadContexts.back(); | 139 ICE_TLS_SET_FIELD(TLS, AllThreadContexts.back()); |
140 // Pre-register built-in stack names. | 140 // Pre-register built-in stack names. |
141 if (ALLOW_DUMP) { | 141 if (ALLOW_DUMP) { |
142 // TODO(stichnot): There needs to be a strong relationship between | 142 // TODO(stichnot): There needs to be a strong relationship between |
143 // the newTimerStackID() return values and TSK_Default/TSK_Funcs. | 143 // the newTimerStackID() return values and TSK_Default/TSK_Funcs. |
144 newTimerStackID("Total across all functions"); | 144 newTimerStackID("Total across all functions"); |
145 newTimerStackID("Per-function summary"); | 145 newTimerStackID("Per-function summary"); |
146 } | 146 } |
147 if (Flags.UseELFWriter) { | 147 if (Flags.UseELFWriter) { |
148 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); | 148 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); |
149 } | 149 } |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 Timers->at(StackID).setName(NewName); | 488 Timers->at(StackID).setName(NewName); |
489 } | 489 } |
490 | 490 |
491 void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 491 void GlobalContext::dumpStats(const IceString &Name, bool Final) { |
492 if (!ALLOW_DUMP || !getFlags().DumpStats) | 492 if (!ALLOW_DUMP || !getFlags().DumpStats) |
493 return; | 493 return; |
494 OstreamLocker OL(this); | 494 OstreamLocker OL(this); |
495 if (Final) { | 495 if (Final) { |
496 getStatsCumulative()->dump(Name, getStrDump()); | 496 getStatsCumulative()->dump(Name, getStrDump()); |
497 } else { | 497 } else { |
498 TLS->StatsFunction.dump(Name, getStrDump()); | 498 ICE_TLS_GET_FIELD(ThreadContext *, TLS) |
| 499 ->StatsFunction.dump(Name, getStrDump()); |
499 getStatsCumulative()->dump("_TOTAL_", getStrDump()); | 500 getStatsCumulative()->dump("_TOTAL_", getStrDump()); |
500 } | 501 } |
501 } | 502 } |
502 | 503 |
503 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { | 504 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
504 if (!ALLOW_DUMP) | 505 if (!ALLOW_DUMP) |
505 return; | 506 return; |
506 auto Timers = getTimers(); | 507 auto Timers = getTimers(); |
507 assert(Timers->size() > StackID); | 508 assert(Timers->size() > StackID); |
508 OstreamLocker L(this); | 509 OstreamLocker L(this); |
509 Timers->at(StackID).dump(getStrDump(), DumpCumulative); | 510 Timers->at(StackID).dump(getStrDump(), DumpCumulative); |
510 } | 511 } |
511 | 512 |
512 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | 513 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) |
513 : ID(ID), Ctx(Func->getContext()), Active(false) { | 514 : ID(ID), Ctx(Func->getContext()), Active(false) { |
514 if (ALLOW_DUMP) { | 515 if (ALLOW_DUMP) { |
515 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; | 516 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; |
516 if (Active) | 517 if (Active) |
517 Ctx->pushTimer(ID); | 518 Ctx->pushTimer(ID); |
518 } | 519 } |
519 } | 520 } |
520 | 521 |
521 ICE_ATTRIBUTE_TLS GlobalContext::ThreadContext *GlobalContext::TLS; | 522 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
522 | 523 |
523 } // end of namespace Ice | 524 } // end of namespace Ice |
OLD | NEW |