Bug 1094552 (part 3) - DMD: rename |Block| as |LiveBlock|. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 18 Nov 2014 18:57:20 -0800
changeset 241355 c3ecdd9ea544eb0407fbeda412acfb6793e7c9a2
parent 241354 7a74315e55f511d81e00b4cf85fb8b47a80749a3
child 241356 26112e1b5c61b382bfc61dc68065e1946a99313d
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1094552
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1094552 (part 3) - DMD: rename |Block| as |LiveBlock|. r=mccr8. This is to give better contrast with |DeadBlock|, which will be added in the next patch.
memory/replace/dmd/DMD.cpp
memory/replace/dmd/DMD.h
xpcom/base/nsMemoryReporterManager.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -391,17 +391,17 @@ public:
     mIsLocked = false;
     MutexBase::Unlock();
   }
 
   bool IsLocked() { return mIsLocked; }
 };
 
 // This lock must be held while manipulating global state, such as
-// gStackTraceTable, gBlockTable, etc.
+// gStackTraceTable, gLiveBlockTable, etc.
 static Mutex* gStateLock = nullptr;
 
 class AutoLockState
 {
   DISALLOW_COPY_AND_ASSIGN(AutoLockState);
 
 public:
   AutoLockState()  { gStateLock->Lock(); }
@@ -770,17 +770,17 @@ public:
   }
 
   T Ptr() const { return reinterpret_cast<T>(mUint & kPtrMask); }
 
   bool Tag() const { return bool(mUint & kTagMask); }
 };
 
 // A live heap block.
-class Block
+class LiveBlock
 {
   const void*  mPtr;
   const size_t mReqSize;    // size requested
 
   // Ptr: |mAllocStackTrace| - stack trace where this block was allocated.
   // Tag bit 0: |mIsSampled| - was this block sampled? (if so, slop == 0).
   TaggedPtr<const StackTrace* const>
     mAllocStackTrace_mIsSampled;
@@ -788,23 +788,23 @@ class Block
   // This array has two elements because we record at most two reports of a
   // block.
   // - Ptr: |mReportStackTrace| - stack trace where this block was reported.
   //   nullptr if not reported.
   // - Tag bit 0: |mReportedOnAlloc| - was the block reported immediately on
   //   allocation?  If so, DMD must not clear the report at the end of
   //   AnalyzeReports(). Only relevant if |mReportStackTrace| is non-nullptr.
   //
-  // |mPtr| is used as the key in BlockTable, so it's ok for this member
+  // |mPtr| is used as the key in LiveBlockTable, so it's ok for this member
   // to be |mutable|.
   mutable TaggedPtr<const StackTrace*> mReportStackTrace_mReportedOnAlloc[2];
 
 public:
-  Block(const void* aPtr, size_t aReqSize, const StackTrace* aAllocStackTrace,
-        bool aIsSampled)
+  LiveBlock(const void* aPtr, size_t aReqSize,
+            const StackTrace* aAllocStackTrace, bool aIsSampled)
     : mPtr(aPtr),
       mReqSize(aReqSize),
       mAllocStackTrace_mIsSampled(aAllocStackTrace, aIsSampled),
       mReportStackTrace_mReportedOnAlloc()     // all fields get zeroed
   {
     MOZ_ASSERT(aAllocStackTrace);
   }
 
@@ -909,37 +909,37 @@ public:
 
   typedef const void* Lookup;
 
   static uint32_t hash(const void* const& aPtr)
   {
     return mozilla::HashGeneric(aPtr);
   }
 
-  static bool match(const Block& aB, const void* const& aPtr)
+  static bool match(const LiveBlock& aB, const void* const& aPtr)
   {
     return aB.mPtr == aPtr;
   }
 };
 
-typedef js::HashSet<Block, Block, InfallibleAllocPolicy> BlockTable;
-static BlockTable* gBlockTable = nullptr;
+typedef js::HashSet<LiveBlock, LiveBlock, InfallibleAllocPolicy> LiveBlockTable;
+static LiveBlockTable* gLiveBlockTable = nullptr;
 
 // Add a pointer to each live stack trace into the given StackTraceSet.  (A
 // stack trace is live if it's used by one of the live blocks.)
 static void
 GatherUsedStackTraces(StackTraceSet& aStackTraces)
 {
   MOZ_ASSERT(gStateLock->IsLocked());
   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
 
   aStackTraces.finish();
   aStackTraces.init(512);
 
-  for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
+  for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
     r.front().AddStackTracesToTable(aStackTraces);
   }
 }
 
 // Delete stack traces that we aren't using, and compact our hashtable.
 static void
 GCStackTraces()
 {
@@ -987,37 +987,38 @@ AllocCallback(void* aPtr, size_t aReqSiz
     // If this allocation is smaller than the sample-below size, increment the
     // cumulative counter.  Then, if that counter now exceeds the sample size,
     // blame this allocation for |sampleBelowSize| bytes.  This precludes the
     // measurement of slop.
     gSmallBlockActualSizeCounter += actualSize;
     if (gSmallBlockActualSizeCounter >= sampleBelowSize) {
       gSmallBlockActualSizeCounter -= sampleBelowSize;
 
-      Block b(aPtr, sampleBelowSize, StackTrace::Get(aT), /* isSampled */ true);
-      (void)gBlockTable->putNew(aPtr, b);
+      LiveBlock b(aPtr, sampleBelowSize, StackTrace::Get(aT),
+                  /* isSampled */ true);
+      (void)gLiveBlockTable->putNew(aPtr, b);
     }
   } else {
     // If this block size is larger than the sample size, record it exactly.
-    Block b(aPtr, aReqSize, StackTrace::Get(aT), /* isSampled */ false);
-    (void)gBlockTable->putNew(aPtr, b);
+    LiveBlock b(aPtr, aReqSize, StackTrace::Get(aT), /* isSampled */ false);
+    (void)gLiveBlockTable->putNew(aPtr, b);
   }
 }
 
 static void
 FreeCallback(void* aPtr, Thread* aT)
 {
   if (!aPtr) {
     return;
   }
 
   AutoLockState lock;
   AutoBlockIntercepts block(aT);
 
-  gBlockTable->remove(aPtr);
+  gLiveBlockTable->remove(aPtr);
 
   if (gStackTraceTable->count() > gGCStackTraceTableWhenSizeExceeds) {
     GCStackTraces();
   }
 }
 
 //---------------------------------------------------------------------------
 // malloc/free interception
@@ -1354,18 +1355,18 @@ Init(const malloc_table_t* aMallocTable)
   DMD_CREATE_TLS_INDEX(gTlsIndex);
 
   {
     AutoLockState lock;
 
     gStackTraceTable = InfallibleAllocPolicy::new_<StackTraceTable>();
     gStackTraceTable->init(8192);
 
-    gBlockTable = InfallibleAllocPolicy::new_<BlockTable>();
-    gBlockTable->init(8192);
+    gLiveBlockTable = InfallibleAllocPolicy::new_<LiveBlockTable>();
+    gLiveBlockTable->init(8192);
   }
 
   gIsDMDInitialized = true;
 }
 
 //---------------------------------------------------------------------------
 // DMD reporting and unreporting
 //---------------------------------------------------------------------------
@@ -1377,17 +1378,17 @@ ReportHelper(const void* aPtr, bool aRep
     return;
   }
 
   Thread* t = Thread::Fetch();
 
   AutoBlockIntercepts block(t);
   AutoLockState lock;
 
-  if (BlockTable::Ptr p = gBlockTable->lookup(aPtr)) {
+  if (LiveBlockTable::Ptr p = gLiveBlockTable->lookup(aPtr)) {
     p->Report(t, aReportedOnAlloc);
   } else {
     // We have no record of the block.  Do nothing.  Either:
     // - We're sampling and we skipped this block.  This is likely.
     // - It's a bogus pointer.  This is unlikely because Report() is almost
     //   always called in conjunction with a malloc_size_of-style function.
   }
 }
@@ -1444,17 +1445,17 @@ SizeOfInternal(Sizes* aSizes)
     } else {
       aSizes->mStackTracesUnused += MallocSizeOf(st);
     }
   }
 
   aSizes->mStackTraceTable =
     gStackTraceTable->sizeOfIncludingThis(MallocSizeOf);
 
-  aSizes->mBlockTable = gBlockTable->sizeOfIncludingThis(MallocSizeOf);
+  aSizes->mLiveBlockTable = gLiveBlockTable->sizeOfIncludingThis(MallocSizeOf);
 }
 
 void
 DMDFuncs::SizeOf(Sizes* aSizes)
 {
   aSizes->Clear();
 
   AutoBlockIntercepts block(Thread::Fetch());
@@ -1465,17 +1466,17 @@ DMDFuncs::SizeOf(Sizes* aSizes)
 void
 DMDFuncs::ClearReports()
 {
   AutoLockState lock;
 
   // Unreport all blocks that were marked reported by a memory reporter.  This
   // excludes those that were reported on allocation, because they need to keep
   // their reported marking.
-  for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
+  for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
     r.front().UnreportIfNotReportedOnAlloc();
   }
 }
 
 class ToIdStringConverter MOZ_FINAL
 {
 public:
   ToIdStringConverter() : mNextId(0) { mIdMap.init(512); }
@@ -1574,18 +1575,18 @@ AnalyzeReportsImpl(UniquePtr<JSONWriteFu
     writer.EndObject();
 
     StatusMsg("  Constructing the heap block list...\n");
 
     ToIdStringConverter isc;
 
     writer.StartArrayProperty("blockList");
     {
-      for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
-        const Block& b = r.front();
+      for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
+        const LiveBlock& b = r.front();
         b.AddStackTracesToTable(usedStackTraces);
 
         writer.StartObjectElement(writer.SingleLineStyle);
         {
           if (!b.IsSampled()) {
             writer.IntProperty("req", b.ReqSize());
             if (b.SlopSize() > 0) {
               writer.IntProperty("slop", b.SlopSize());
@@ -1670,20 +1671,20 @@ AnalyzeReportsImpl(UniquePtr<JSONWriteFu
     StatusMsg("      Unused stack traces:  %10s bytes\n",
       Show(sizes.mStackTracesUnused, buf1, kBufLen));
 
     StatusMsg("      Stack trace table:    %10s bytes (%s entries, %s used)\n",
       Show(sizes.mStackTraceTable,       buf1, kBufLen),
       Show(gStackTraceTable->capacity(), buf2, kBufLen),
       Show(gStackTraceTable->count(),    buf3, kBufLen));
 
-    StatusMsg("      Block table:          %10s bytes (%s entries, %s used)\n",
-      Show(sizes.mBlockTable,       buf1, kBufLen),
-      Show(gBlockTable->capacity(), buf2, kBufLen),
-      Show(gBlockTable->count(),    buf3, kBufLen));
+    StatusMsg("      Live block table:     %10s bytes (%s entries, %s used)\n",
+      Show(sizes.mLiveBlockTable,       buf1, kBufLen),
+      Show(gLiveBlockTable->capacity(), buf2, kBufLen),
+      Show(gLiveBlockTable->count(),    buf3, kBufLen));
 
     StatusMsg("    }\n");
     StatusMsg("    Data structures that are destroyed after Dump() ends {\n");
 
     StatusMsg("      Location service:      %10s bytes\n",
       Show(locService->SizeOfIncludingThis(MallocSizeOf), buf1, kBufLen));
     StatusMsg("      Used stack traces set: %10s bytes\n",
       Show(usedStackTraces.sizeOfExcludingThis(MallocSizeOf), buf1, kBufLen));
@@ -1731,14 +1732,14 @@ void
 DMDFuncs::SetSampleBelowSize(size_t aSize)
 {
   gOptions->SetSampleBelowSize(aSize);
 }
 
 void
 DMDFuncs::ClearBlocks()
 {
-  gBlockTable->clear();
+  gLiveBlockTable->clear();
   gSmallBlockActualSizeCounter = 0;
 }
 
 }   // namespace dmd
 }   // namespace mozilla
--- a/memory/replace/dmd/DMD.h
+++ b/memory/replace/dmd/DMD.h
@@ -23,17 +23,17 @@ class JSONWriteFunc;
 
 namespace dmd {
 
 struct Sizes
 {
   size_t mStackTracesUsed;
   size_t mStackTracesUnused;
   size_t mStackTraceTable;
-  size_t mBlockTable;
+  size_t mLiveBlockTable;
 
   Sizes() { Clear(); }
   void Clear() { memset(this, 0, sizeof(Sizes)); }
 };
 
 // See further below for a description of each method. The DMDFuncs class
 // should contain a virtual method for each of them (except IsRunning,
 // which can be inferred from the DMDFuncs singleton existing).
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -947,18 +947,18 @@ public:
            sizes.mStackTracesUnused,
            "Memory used by stack traces which don't correspond to any heap "
            "blocks DMD is currently tracking.");
 
     REPORT("explicit/dmd/stack-traces/table",
            sizes.mStackTraceTable,
            "Memory used by DMD's stack trace table.");
 
-    REPORT("explicit/dmd/block-table",
-           sizes.mBlockTable,
+    REPORT("explicit/dmd/live-block-table",
+           sizes.mLiveBlockTable,
            "Memory used by DMD's live block table.");
 
 #undef REPORT
 
     return NS_OK;
   }
 
 private: