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

Side by Side Diff: src/IceGlobalContext.cpp

Issue 1747333002: Subzero: Print constant pool info with --szstats. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | no next file » | 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.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 /// \file 10 /// \file
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ConstantList Constants; 153 ConstantList Constants;
154 Constants.reserve(Pool.size()); 154 Constants.reserve(Pool.size());
155 for (auto &I : Pool) 155 for (auto &I : Pool)
156 Constants.push_back(I.second); 156 Constants.push_back(I.second);
157 // The sort (and its KeyCompareLess machinery) is not strictly necessary, 157 // The sort (and its KeyCompareLess machinery) is not strictly necessary,
158 // but is desirable for producing output that is deterministic across 158 // but is desirable for producing output that is deterministic across
159 // unordered_map::iterator implementations. 159 // unordered_map::iterator implementations.
160 std::sort(Constants.begin(), Constants.end(), KeyCompareLess<ValueType>()); 160 std::sort(Constants.begin(), Constants.end(), KeyCompareLess<ValueType>());
161 return Constants; 161 return Constants;
162 } 162 }
163 size_t size() const { return Pool.size(); }
163 164
164 private: 165 private:
165 // Use the default hash function, and a custom key comparison function. The 166 // Use the default hash function, and a custom key comparison function. The
166 // key comparison function for floating point variables can't use the default 167 // key comparison function for floating point variables can't use the default
167 // == based implementation because of special C++ semantics regarding +0.0, 168 // == based implementation because of special C++ semantics regarding +0.0,
168 // -0.0, and NaN comparison. However, it's OK to use the default hash for 169 // -0.0, and NaN comparison. However, it's OK to use the default hash for
169 // floating point values because KeyCompare is the final source of truth - in 170 // floating point values because KeyCompare is the final source of truth - in
170 // the worst case a "false" collision must be resolved. 171 // the worst case a "false" collision must be resolved.
171 using ContainerType = 172 using ContainerType =
172 std::unordered_map<KeyType, ValueType *, std::hash<KeyType>, 173 std::unordered_map<KeyType, ValueType *, std::hash<KeyType>,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 TypePool<IceType_i8, int8_t, ConstantInteger32> Integers8; 209 TypePool<IceType_i8, int8_t, ConstantInteger32> Integers8;
209 TypePool<IceType_i16, int16_t, ConstantInteger32> Integers16; 210 TypePool<IceType_i16, int16_t, ConstantInteger32> Integers16;
210 TypePool<IceType_i32, int32_t, ConstantInteger32> Integers32; 211 TypePool<IceType_i32, int32_t, ConstantInteger32> Integers32;
211 TypePool<IceType_i64, int64_t, ConstantInteger64> Integers64; 212 TypePool<IceType_i64, int64_t, ConstantInteger64> Integers64;
212 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> Relocatables; 213 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> Relocatables;
213 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> 214 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable>
214 ExternRelocatables; 215 ExternRelocatables;
215 UndefPool Undefs; 216 UndefPool Undefs;
216 }; 217 };
217 218
218 void GlobalContext::CodeStats::dump(const IceString &Name, Ostream &Str) { 219 void GlobalContext::CodeStats::dump(const IceString &Name, GlobalContext *Ctx) {
Eric Holk 2016/03/01 19:26:39 Optional, but I'd consider passing Ctx as a refere
John 2016/03/01 20:02:09 Please, do not pass non-const references to method
219 if (!BuildDefs::dump()) 220 if (!BuildDefs::dump())
220 return; 221 return;
222 OstreamLocker _(Ctx);
223 Ostream &Str = Ctx->getStrDump();
221 #define X(str, tag) \ 224 #define X(str, tag) \
222 Str << "|" << Name << "|" str "|" << Stats[CS_##tag] << "\n"; 225 Str << "|" << Name << "|" str "|" << Stats[CS_##tag] << "\n";
223 CODESTATS_TABLE 226 CODESTATS_TABLE
224 #undef X 227 #undef X
225 Str << "|" << Name << "|Spills+Fills|" 228 Str << "|" << Name << "|Spills+Fills|"
226 << Stats[CS_NumSpills] + Stats[CS_NumFills] << "\n"; 229 << Stats[CS_NumSpills] + Stats[CS_NumFills] << "\n";
227 Str << "|" << Name << "|Memory Usage|"; 230 Str << "|" << Name << "|Memory Usage|";
228 if (ssize_t MemUsed = llvm::TimeRecord::getCurrentTime(false).getMemUsed()) 231 if (ssize_t MemUsed = llvm::TimeRecord::getCurrentTime(false).getMemUsed())
229 Str << MemUsed; 232 Str << MemUsed;
230 else 233 else
231 Str << "(requires '-track-memory')"; 234 Str << "(requires '-track-memory')";
232 Str << "\n"; 235 Str << "\n";
236 Str << "|" << Name << "|CPool Sizes ";
237 {
238 auto Pool = Ctx->getConstPool();
239 Str << "|f32=" << Pool->Floats.size();
240 Str << "|f64=" << Pool->Doubles.size();
241 Str << "|i1=" << Pool->Integers1.size();
242 Str << "|i8=" << Pool->Integers8.size();
243 Str << "|i16=" << Pool->Integers16.size();
244 Str << "|i32=" << Pool->Integers32.size();
245 Str << "|i64=" << Pool->Integers64.size();
246 Str << "|Rel=" << Pool->Relocatables.size();
247 Str << "|ExtRel=" << Pool->ExternRelocatables.size();
248 }
249 Str << "\n";
233 } 250 }
234 251
235 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, 252 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError,
236 ELFStreamer *ELFStr, const ClFlags &Flags) 253 ELFStreamer *ELFStr, const ClFlags &Flags)
237 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), 254 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump),
238 StrEmit(OsEmit), StrError(OsError), Flags(Flags), ObjectWriter(), 255 StrEmit(OsEmit), StrError(OsError), Flags(Flags), ObjectWriter(),
239 OptQ(/*Sequential=*/Flags.isSequential(), 256 OptQ(/*Sequential=*/Flags.isSequential(),
240 /*MaxSize=*/Flags.getNumTranslationThreads()), 257 /*MaxSize=*/Flags.getNumTranslationThreads()),
241 // EmitQ is allowed unlimited size. 258 // EmitQ is allowed unlimited size.
242 EmitQ(/*Sequential=*/Flags.isSequential()), 259 EmitQ(/*Sequential=*/Flags.isSequential()),
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 emitItems(); 1007 emitItems();
991 } 1008 }
992 1009
993 EmitterWorkItem *GlobalContext::emitQueueBlockingPop() { 1010 EmitterWorkItem *GlobalContext::emitQueueBlockingPop() {
994 return EmitQ.blockingPop(); 1011 return EmitQ.blockingPop();
995 } 1012 }
996 1013
997 void GlobalContext::dumpStats(const IceString &Name, bool Final) { 1014 void GlobalContext::dumpStats(const IceString &Name, bool Final) {
998 if (!getFlags().getDumpStats()) 1015 if (!getFlags().getDumpStats())
999 return; 1016 return;
1000 OstreamLocker OL(this);
1001 if (Final) { 1017 if (Final) {
1002 getStatsCumulative()->dump(Name, getStrDump()); 1018 getStatsCumulative()->dump(Name, this);
1003 } else { 1019 } else {
1004 ICE_TLS_GET_FIELD(TLS)->StatsFunction.dump(Name, getStrDump()); 1020 ICE_TLS_GET_FIELD(TLS)->StatsFunction.dump(Name, this);
1005 } 1021 }
1006 } 1022 }
1007 1023
1008 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { 1024 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
1009 if (!BuildDefs::dump()) 1025 if (!BuildDefs::dump())
1010 return; 1026 return;
1011 auto Timers = getTimers(); 1027 auto Timers = getTimers();
1012 assert(Timers->size() > StackID); 1028 assert(Timers->size() > StackID);
1013 OstreamLocker L(this); 1029 OstreamLocker L(this);
1014 Timers->at(StackID).dump(getStrDump(), DumpCumulative); 1030 Timers->at(StackID).dump(getStrDump(), DumpCumulative);
(...skipping 18 matching lines...) Expand all
1033 Ctx = Func->getContext(); 1049 Ctx = Func->getContext();
1034 Active = 1050 Active =
1035 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); 1051 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled();
1036 if (Active) 1052 if (Active)
1037 Ctx->pushTimer(ID, StackID); 1053 Ctx->pushTimer(ID, StackID);
1038 } 1054 }
1039 1055
1040 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); 1056 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
1041 1057
1042 } // end of namespace Ice 1058 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698