Index: src/IceGlobalContext.cpp |
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
index 74dfb9ecebd7c29797960fd13498721b6fa31dc7..395020168a1feac6d93b836f05b247d06ed9f70e 100644 |
--- a/src/IceGlobalContext.cpp |
+++ b/src/IceGlobalContext.cpp |
@@ -131,7 +131,8 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
IceString TestPrefix, const ClFlags &Flags) |
: StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
- TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() { |
+ TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter(), |
+ CfgQ(Flags.NumTranslationThreads), ErrorStatus(false) { |
// Create a new ThreadContext for the current thread. No need to |
// lock AllThreadContexts at this point since no other threads have |
// access yet to this GlobalContext object. |
@@ -149,6 +150,34 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
} |
} |
+void GlobalContext::translateFunctions() { |
+ while (Cfg *Func = cfgQueueGet()) { |
+ resetStats(); |
Jim Stichnoth
2015/01/22 19:10:29
Most of this function was moved from Translator::t
|
+ Func->updateTLS(); |
+ if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn)) |
+ Func->setVerbose(IceV_None); |
+ if (getFlags().DisableTranslation || |
+ !matchSymbolName(Func->getFunctionName(), getFlags().TranslateOnly)) { |
+ Func->dump(); |
JF
2015/01/22 20:50:56
What are the above two for?
Jim Stichnoth
2015/01/23 07:55:54
Documented.
|
+ } else { |
+ Func->translate(); |
+ if (Func->hasError()) { |
+ OstreamLocker L(this); |
+ getStrDump() << "ICE translation error: " << Func->getError() << "\n"; |
+ 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
|
+ } else { |
+ if (getFlags().UseIntegratedAssembler) |
+ Func->emitIAS(); |
+ else |
+ Func->emit(); |
+ // TODO(stichnot): actually add to emit queue |
+ } |
+ 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,
|
+ } |
+ 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.
|
+ } |
+} |
+ |
// 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 |
// legitimately contains that pattern, then the substitution will be |
@@ -464,12 +493,18 @@ TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
} |
void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
+ // TODO(stichnot): Timers are completely broken for multithreading; fix. |
+ if (getFlags().NumTranslationThreads) |
+ 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.
|
auto Timers = getTimers(); |
assert(StackID < Timers->size()); |
Timers->at(StackID).push(ID); |
} |
void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { |
+ // TODO(stichnot): Timers are completely broken for multithreading; fix. |
+ if (getFlags().NumTranslationThreads) |
+ return; |
auto Timers = getTimers(); |
assert(StackID < Timers->size()); |
Timers->at(StackID).pop(ID); |