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

Side by Side Diff: src/IceGlobalContext.h

Issue 1197863003: Subzero: Reduce the amount of #ifdef'd code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/IceFixups.cpp ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
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 declares aspects of the compilation that persist across 10 // This file declares aspects of the compilation that persist across
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 TimerList(const TimerList &) = delete; 108 TimerList(const TimerList &) = delete;
109 TimerList &operator=(const TimerList &) = delete; 109 TimerList &operator=(const TimerList &) = delete;
110 110
111 public: 111 public:
112 TimerList() = default; 112 TimerList() = default;
113 // initInto() initializes a target list of timers based on the 113 // initInto() initializes a target list of timers based on the
114 // current list. In particular, it creates the same number of 114 // current list. In particular, it creates the same number of
115 // timers, in the same order, with the same names, but initially 115 // timers, in the same order, with the same names, but initially
116 // empty of timing data. 116 // empty of timing data.
117 void initInto(TimerList &Dest) const { 117 void initInto(TimerList &Dest) const {
118 if (!ALLOW_DUMP) 118 if (!BuildDefs::dump())
119 return; 119 return;
120 Dest.clear(); 120 Dest.clear();
121 for (const TimerStack &Stack : *this) { 121 for (const TimerStack &Stack : *this) {
122 Dest.push_back(TimerStack(Stack.getName())); 122 Dest.push_back(TimerStack(Stack.getName()));
123 } 123 }
124 } 124 }
125 void mergeFrom(TimerList &Src) { 125 void mergeFrom(TimerList &Src) {
126 if (!ALLOW_DUMP) 126 if (!BuildDefs::dump())
127 return; 127 return;
128 assert(size() == Src.size()); 128 assert(size() == Src.size());
129 size_type i = 0; 129 size_type i = 0;
130 for (TimerStack &Stack : *this) { 130 for (TimerStack &Stack : *this) {
131 assert(Stack.getName() == Src[i].getName()); 131 assert(Stack.getName() == Src[i].getName());
132 Stack.mergeFrom(Src[i]); 132 Stack.mergeFrom(Src[i]);
133 ++i; 133 ++i;
134 } 134 }
135 } 135 }
136 }; 136 };
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } 236 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; }
237 237
238 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded 238 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded
239 // translation. 239 // translation.
240 RandomNumberGenerator &getRNG() { return RNG; } 240 RandomNumberGenerator &getRNG() { return RNG; }
241 241
242 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } 242 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); }
243 243
244 // Reset stats at the beginning of a function. 244 // Reset stats at the beginning of a function.
245 void resetStats() { 245 void resetStats() {
246 if (ALLOW_DUMP) 246 if (BuildDefs::dump())
247 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset(); 247 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset();
248 } 248 }
249 void dumpStats(const IceString &Name, bool Final = false); 249 void dumpStats(const IceString &Name, bool Final = false);
250 void statsUpdateEmitted(uint32_t InstCount) { 250 void statsUpdateEmitted(uint32_t InstCount) {
251 if (!getFlags().getDumpStats()) 251 if (!getFlags().getDumpStats())
252 return; 252 return;
253 ThreadContext *Tls = ICE_TLS_GET_FIELD(TLS); 253 ThreadContext *Tls = ICE_TLS_GET_FIELD(TLS);
254 Tls->StatsFunction.update(CodeStats::CS_InstCount, InstCount); 254 Tls->StatsFunction.update(CodeStats::CS_InstCount, InstCount);
255 Tls->StatsCumulative.update(CodeStats::CS_InstCount, InstCount); 255 Tls->StatsCumulative.update(CodeStats::CS_InstCount, InstCount);
256 } 256 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 TranslationThreads.clear(); 373 TranslationThreads.clear();
374 374
375 // Only notify the emit queue to end after all the translation 375 // Only notify the emit queue to end after all the translation
376 // threads have ended. 376 // threads have ended.
377 emitQueueNotifyEnd(); 377 emitQueueNotifyEnd();
378 for (std::thread &Worker : EmitterThreads) { 378 for (std::thread &Worker : EmitterThreads) {
379 Worker.join(); 379 Worker.join();
380 } 380 }
381 EmitterThreads.clear(); 381 EmitterThreads.clear();
382 382
383 if (ALLOW_DUMP) { 383 if (BuildDefs::dump()) {
384 auto Timers = getTimers(); 384 auto Timers = getTimers();
385 for (ThreadContext *TLS : AllThreadContexts) 385 for (ThreadContext *TLS : AllThreadContexts)
386 Timers->mergeFrom(TLS->Timers); 386 Timers->mergeFrom(TLS->Timers);
387 } 387 }
388 if (ALLOW_DUMP) { 388 if (BuildDefs::dump()) {
389 // Do a separate loop over AllThreadContexts to avoid holding 389 // Do a separate loop over AllThreadContexts to avoid holding
390 // two locks at once. 390 // two locks at once.
391 auto Stats = getStatsCumulative(); 391 auto Stats = getStatsCumulative();
392 for (ThreadContext *TLS : AllThreadContexts) 392 for (ThreadContext *TLS : AllThreadContexts)
393 Stats->add(TLS->StatsCumulative); 393 Stats->add(TLS->StatsCumulative);
394 } 394 }
395 } 395 }
396 396
397 // Translation thread startup routine. 397 // Translation thread startup routine.
398 void translateFunctionsWrapper(ThreadContext *MyTLS) { 398 void translateFunctionsWrapper(ThreadContext *MyTLS) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // convenient timing of regions of code. 553 // convenient timing of regions of code.
554 class TimerMarker { 554 class TimerMarker {
555 TimerMarker() = delete; 555 TimerMarker() = delete;
556 TimerMarker(const TimerMarker &) = delete; 556 TimerMarker(const TimerMarker &) = delete;
557 TimerMarker &operator=(const TimerMarker &) = delete; 557 TimerMarker &operator=(const TimerMarker &) = delete;
558 558
559 public: 559 public:
560 TimerMarker(TimerIdT ID, GlobalContext *Ctx, 560 TimerMarker(TimerIdT ID, GlobalContext *Ctx,
561 TimerStackIdT StackID = GlobalContext::TSK_Default) 561 TimerStackIdT StackID = GlobalContext::TSK_Default)
562 : ID(ID), Ctx(Ctx), StackID(StackID) { 562 : ID(ID), Ctx(Ctx), StackID(StackID) {
563 if (ALLOW_DUMP) 563 if (BuildDefs::dump())
564 push(); 564 push();
565 } 565 }
566 TimerMarker(TimerIdT ID, const Cfg *Func, 566 TimerMarker(TimerIdT ID, const Cfg *Func,
567 TimerStackIdT StackID = GlobalContext::TSK_Default) 567 TimerStackIdT StackID = GlobalContext::TSK_Default)
568 : ID(ID), Ctx(nullptr), StackID(StackID) { 568 : ID(ID), Ctx(nullptr), StackID(StackID) {
569 // Ctx gets set at the beginning of pushCfg(). 569 // Ctx gets set at the beginning of pushCfg().
570 if (ALLOW_DUMP) 570 if (BuildDefs::dump())
571 pushCfg(Func); 571 pushCfg(Func);
572 } 572 }
573 573
574 ~TimerMarker() { 574 ~TimerMarker() {
575 if (ALLOW_DUMP && Active) 575 if (BuildDefs::dump() && Active)
576 Ctx->popTimer(ID, StackID); 576 Ctx->popTimer(ID, StackID);
577 } 577 }
578 578
579 private: 579 private:
580 void push(); 580 void push();
581 void pushCfg(const Cfg *Func); 581 void pushCfg(const Cfg *Func);
582 const TimerIdT ID; 582 const TimerIdT ID;
583 GlobalContext *Ctx; 583 GlobalContext *Ctx;
584 const TimerStackIdT StackID; 584 const TimerStackIdT StackID;
585 bool Active = false; 585 bool Active = false;
(...skipping 11 matching lines...) Expand all
597 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } 597 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); }
598 ~OstreamLocker() { Ctx->unlockStr(); } 598 ~OstreamLocker() { Ctx->unlockStr(); }
599 599
600 private: 600 private:
601 GlobalContext *const Ctx; 601 GlobalContext *const Ctx;
602 }; 602 };
603 603
604 } // end of namespace Ice 604 } // end of namespace Ice
605 605
606 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H 606 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW
« no previous file with comments | « src/IceFixups.cpp ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698