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

Unified Diff: src/IceGlobalContext.cpp

Issue 1768173002: Subzero: Count lookups of each constant value in the constant pool. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceOperand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index af3e6c7065e657aa98a4c989f89d64c5a120bc28..038d7cc0f73dcb187e18d7157cd0f49a6e342b08 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 (auto *C : getConstPool()->WhichPool.getConstantPool()) { \
+ 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.
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceOperand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698