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

Unified Diff: src/IceGlobalContext.h

Issue 580633002: Subzero: Add rudimentary statistics on generated code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 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
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index b67a232fc658770fb49b580f99add84c23812346..9e0a34948b3be594e81676116f60e2890e9eb5b1 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -28,6 +28,42 @@ namespace Ice {
class ClFlags;
+// This class collects rudimentary statistics during translation.
+class CodeStats {
+public:
+ CodeStats()
+ : InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0),
+ Fills(0), SpillsPlusFills(0) {}
+ void reset() { *this = CodeStats(); }
+ void updateEmitted(uint32_t InstCount) { InstructionsEmitted += InstCount; }
+ void updateRegistersSaved(uint32_t Num) { RegistersSaved += Num; }
+ void updateFrameBytes(uint32_t Bytes) { FrameBytes += Bytes; }
+ void updateSpills() {
+ ++Spills;
+ ++SpillsPlusFills;
+ }
+ void updateFills() {
+ ++Fills;
+ ++SpillsPlusFills;
+ }
+ void dump(const IceString &Name, Ostream &Str) {
+ Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
+ Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
+ Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
+ Str << "|" << Name << "|Spills |" << Spills << "\n";
+ Str << "|" << Name << "|Fills |" << Fills << "\n";
+ Str << "|" << Name << "|Spills+Fills|" << SpillsPlusFills << "\n";
jvoung (off chromium) 2014/09/17 01:21:12 nit: Seems like this could have been Spills + Fill
Jim Stichnoth 2014/09/17 02:57:06 True! Done.
+ }
+
+private:
+ uint32_t InstructionsEmitted;
+ uint32_t RegistersSaved;
+ uint32_t FrameBytes;
+ uint32_t Spills;
+ uint32_t Fills;
+ uint32_t SpillsPlusFills;
+};
+
// TODO: Accesses to all non-const fields of GlobalContext need to
// be synchronized, especially the constant pool, the allocator, and
// the output streams.
@@ -100,6 +136,30 @@ public:
// translation.
RandomNumberGenerator &getRNG() { return RNG; }
+ // Reset stats at the beginning of a function.
+ void resetStats() { StatsFunction.reset(); }
+ void dumpStats(const IceString &Name);
+ void statsUpdateEmitted(uint32_t InstCount) {
+ StatsFunction.updateEmitted(InstCount);
+ StatsCumulative.updateEmitted(InstCount);
+ }
+ void statsUpdateRegistersSaved(uint32_t Num) {
+ StatsFunction.updateRegistersSaved(Num);
+ StatsCumulative.updateRegistersSaved(Num);
+ }
+ void statsUpdateFrameBytes(uint32_t Bytes) {
+ StatsFunction.updateFrameBytes(Bytes);
+ StatsCumulative.updateFrameBytes(Bytes);
+ }
+ void statsUpdateSpills() {
+ StatsFunction.updateSpills();
+ StatsCumulative.updateSpills();
+ }
+ void statsUpdateFills() {
+ StatsFunction.updateFills();
+ StatsCumulative.updateFills();
+ }
+
private:
Ostream *StrDump; // Stream for dumping / diagnostics
Ostream *StrEmit; // Stream for code emission
@@ -114,6 +174,8 @@ private:
const ClFlags &Flags;
bool HasEmittedFirstMethod;
RandomNumberGenerator RNG;
+ CodeStats StatsFunction;
+ CodeStats StatsCumulative;
GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION;
GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION;
« src/IceCfgNode.cpp ('K') | « src/IceClFlags.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698