Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 Str << "(requires '-track-memory')"; | 124 Str << "(requires '-track-memory')"; |
| 125 Str << "\n"; | 125 Str << "\n"; |
| 126 } | 126 } |
| 127 | 127 |
| 128 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, | 128 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
| 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 CfgQ(Flags.NumTranslationThreads), ErrorStatus(false) { | |
| 135 // Create a new ThreadContext for the current thread. No need to | 136 // Create a new ThreadContext for the current thread. No need to |
| 136 // lock AllThreadContexts at this point since no other threads have | 137 // lock AllThreadContexts at this point since no other threads have |
| 137 // access yet to this GlobalContext object. | 138 // access yet to this GlobalContext object. |
| 138 AllThreadContexts.push_back(new ThreadContext()); | 139 AllThreadContexts.push_back(new ThreadContext()); |
| 139 TLS = AllThreadContexts.back(); | 140 TLS = AllThreadContexts.back(); |
| 140 // Pre-register built-in stack names. | 141 // Pre-register built-in stack names. |
| 141 if (ALLOW_DUMP) { | 142 if (ALLOW_DUMP) { |
| 142 // TODO(stichnot): There needs to be a strong relationship between | 143 // TODO(stichnot): There needs to be a strong relationship between |
| 143 // the newTimerStackID() return values and TSK_Default/TSK_Funcs. | 144 // the newTimerStackID() return values and TSK_Default/TSK_Funcs. |
| 144 newTimerStackID("Total across all functions"); | 145 newTimerStackID("Total across all functions"); |
| 145 newTimerStackID("Per-function summary"); | 146 newTimerStackID("Per-function summary"); |
| 146 } | 147 } |
| 147 if (Flags.UseELFWriter) { | 148 if (Flags.UseELFWriter) { |
| 148 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); | 149 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 | 152 |
| 153 void GlobalContext::translateFunctions() { | |
| 154 while (Cfg *Func = cfgQueueGet()) { | |
| 155 resetStats(); | |
|
Jim Stichnoth
2015/01/22 19:10:29
Most of this function was moved from Translator::t
| |
| 156 Func->updateTLS(); | |
| 157 if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn)) | |
| 158 Func->setVerbose(IceV_None); | |
| 159 if (getFlags().DisableTranslation || | |
| 160 !matchSymbolName(Func->getFunctionName(), getFlags().TranslateOnly)) { | |
| 161 Func->dump(); | |
|
JF
2015/01/22 20:50:56
What are the above two for?
Jim Stichnoth
2015/01/23 07:55:54
Documented.
| |
| 162 } else { | |
| 163 Func->translate(); | |
| 164 if (Func->hasError()) { | |
| 165 OstreamLocker L(this); | |
| 166 getStrDump() << "ICE translation error: " << Func->getError() << "\n"; | |
| 167 ErrorStatus = true; | |
|
JF
2015/01/22 20:50:56
Should the thread continue when it has errors? Sho
Jim Stichnoth
2015/01/23 07:55:54
I do want to continue on an error, to give the use
| |
| 168 } else { | |
| 169 if (getFlags().UseIntegratedAssembler) | |
| 170 Func->emitIAS(); | |
| 171 else | |
| 172 Func->emit(); | |
| 173 // TODO(stichnot): actually add to emit queue | |
| 174 } | |
| 175 dumpStats(Func->getFunctionName()); | |
|
JF
2015/01/22 20:50:56
I think the stats should be joined at the end of t
Jim Stichnoth
2015/01/23 07:55:54
Per-function stats should be dumped at this point,
| |
| 176 } | |
| 177 delete Func; | |
|
JF
2015/01/22 20:50:56
Could you use unique_ptr so that you don't need to
Jim Stichnoth
2015/01/23 07:55:54
There's already a TODO in IceCfg.h:33 about this.
| |
| 178 } | |
| 179 } | |
| 180 | |
| 152 // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 181 // Scan a string for S[0-9A-Z]*_ patterns and replace them with |
| 153 // S<num>_ where <num> is the next base-36 value. If a type name | 182 // S<num>_ where <num> is the next base-36 value. If a type name |
| 154 // legitimately contains that pattern, then the substitution will be | 183 // legitimately contains that pattern, then the substitution will be |
| 155 // made in error and most likely the link will fail. In this case, | 184 // made in error and most likely the link will fail. In this case, |
| 156 // the test classes can be rewritten not to use that pattern, which is | 185 // the test classes can be rewritten not to use that pattern, which is |
| 157 // much simpler and more reliable than implementing a full demangling | 186 // much simpler and more reliable than implementing a full demangling |
| 158 // parser. Another substitution-in-error may occur if a type | 187 // parser. Another substitution-in-error may occur if a type |
| 159 // identifier ends with the pattern S[0-9A-Z]*, because an immediately | 188 // identifier ends with the pattern S[0-9A-Z]*, because an immediately |
| 160 // following substitution string like "S1_" or "PS1_" may be combined | 189 // following substitution string like "S1_" or "PS1_" may be combined |
| 161 // with the previous type. | 190 // with the previous type. |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 } | 486 } |
| 458 | 487 |
| 459 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, | 488 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
| 460 const IceString &Name) { | 489 const IceString &Name) { |
| 461 auto Timers = getTimers(); | 490 auto Timers = getTimers(); |
| 462 assert(StackID < Timers->size()); | 491 assert(StackID < Timers->size()); |
| 463 return Timers->at(StackID).getTimerID(Name); | 492 return Timers->at(StackID).getTimerID(Name); |
| 464 } | 493 } |
| 465 | 494 |
| 466 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { | 495 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
| 496 // TODO(stichnot): Timers are completely broken for multithreading; fix. | |
| 497 if (getFlags().NumTranslationThreads) | |
| 498 return; | |
|
jvoung (off chromium)
2015/01/22 23:06:06
Could report_fatal_error for now?
Jim Stichnoth
2015/01/23 07:55:54
Done.
| |
| 467 auto Timers = getTimers(); | 499 auto Timers = getTimers(); |
| 468 assert(StackID < Timers->size()); | 500 assert(StackID < Timers->size()); |
| 469 Timers->at(StackID).push(ID); | 501 Timers->at(StackID).push(ID); |
| 470 } | 502 } |
| 471 | 503 |
| 472 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { | 504 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { |
| 505 // TODO(stichnot): Timers are completely broken for multithreading; fix. | |
| 506 if (getFlags().NumTranslationThreads) | |
| 507 return; | |
| 473 auto Timers = getTimers(); | 508 auto Timers = getTimers(); |
| 474 assert(StackID < Timers->size()); | 509 assert(StackID < Timers->size()); |
| 475 Timers->at(StackID).pop(ID); | 510 Timers->at(StackID).pop(ID); |
| 476 } | 511 } |
| 477 | 512 |
| 478 void GlobalContext::resetTimer(TimerStackIdT StackID) { | 513 void GlobalContext::resetTimer(TimerStackIdT StackID) { |
| 479 auto Timers = getTimers(); | 514 auto Timers = getTimers(); |
| 480 assert(StackID < Timers->size()); | 515 assert(StackID < Timers->size()); |
| 481 Timers->at(StackID).reset(); | 516 Timers->at(StackID).reset(); |
| 482 } | 517 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 if (ALLOW_DUMP) { | 549 if (ALLOW_DUMP) { |
| 515 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; | 550 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; |
| 516 if (Active) | 551 if (Active) |
| 517 Ctx->pushTimer(ID); | 552 Ctx->pushTimer(ID); |
| 518 } | 553 } |
| 519 } | 554 } |
| 520 | 555 |
| 521 thread_local GlobalContext::ThreadContext *GlobalContext::TLS; | 556 thread_local GlobalContext::ThreadContext *GlobalContext::TLS; |
| 522 | 557 |
| 523 } // end of namespace Ice | 558 } // end of namespace Ice |
| OLD | NEW |