Chromium Code Reviews| Index: src/IceGlobalContext.cpp |
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
| index af3e6c7065e657aa98a4c989f89d64c5a120bc28..fc957f5370f4b1566b0960a4ce7921d4c9df885d 100644 |
| --- a/src/IceGlobalContext.cpp |
| +++ b/src/IceGlobalContext.cpp |
| @@ -143,10 +143,13 @@ public: |
| TypePool() = default; |
| ValueType *getOrAdd(GlobalContext *Ctx, KeyType Key) { |
| auto Iter = Pool.find(Key); |
| - if (Iter != Pool.end()) |
| + if (Iter != Pool.end()) { |
| + Iter->second->updateLookupCount(); |
| return Iter->second; |
| + } |
| auto *Result = ValueType::create(Ctx, Ty, Key); |
| Pool[Key] = Result; |
| + Result->updateLookupCount(); |
| return Result; |
| } |
| ConstantList getConstantPool() const { |
| @@ -410,10 +413,9 @@ void GlobalContext::addBlockInfoPtrs(VariableDeclaration *ProfileBlockInfo) { |
| void GlobalContext::lowerGlobals(const IceString &SectionSuffix) { |
| TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); |
| - const bool DumpGlobalVariables = |
| - BuildDefs::dump() && |
| - (Flags.getVerbose() & IceV_GlobalInit & Cfg::defaultVerboseMask()) && |
| - Flags.getVerboseFocusOn().empty(); |
| + const bool DumpGlobalVariables = BuildDefs::dump() && |
| + (Flags.getVerbose() & IceV_GlobalInit) && |
| + Flags.getVerboseFocusOn().empty(); |
| if (DumpGlobalVariables) { |
| OstreamLocker L(this); |
| Ostream &Stream = getStrDump(); |
| @@ -758,6 +760,35 @@ GlobalContext::~GlobalContext() { |
| Dtor(); |
| } |
| +void GlobalContext::dumpConstantLookupCounts() { |
| + if (!BuildDefs::dump()) |
| + return; |
| + const bool DumpCounts = (Flags.getVerbose() & IceV_ConstPoolStats) && |
| + Flags.getVerboseFocusOn().empty(); |
| + if (!DumpCounts) |
| + return; |
| + |
| + OstreamLocker _(this); |
| + Ostream &Str = getStrDump(); |
| + Str << "Constant pool use stats: count+value+type\n"; |
| +#define X(WhichPool) \ |
| + for (Constant * C : getConstPool()->WhichPool.getConstantPool()) { \ |
|
John
2016/03/07 15:50:26
auto? Anyway, remove the space between * and C
Jim Stichnoth
2016/03/07 16:11:10
Interesting, some sort of clang-format fail I gues
|
| + Str << C->getLookupCount() << " "; \ |
| + C->dump(Str); \ |
| + Str << " " << C->getType() << "\n"; \ |
| + } |
| + X(Integers1); |
| + X(Integers8); |
| + X(Integers16); |
| + X(Integers32); |
| + X(Integers64); |
| + X(Floats); |
| + X(Doubles); |
| + X(Relocatables); |
| + X(ExternRelocatables); |
| +#undef X |
| +} |
| + |
| // TODO(stichnot): Consider adding thread-local caches of constant pool entries |
| // to reduce contention. |