Bug 820652 (part 2) - DMD: Embriefen the hash policy of LiveBlockGroup and DoubleReportBlockGroup. r+a=jlebar
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 11 Dec 2012 19:46:53 -0800
changeset 117651 ca434ab2b8e0ad9bf864f30eee34634c44658e1c
parent 117650 937d81d021c6bb51e62b70781e3660502571d10b
child 117652 43236d3b597096eb047630b8d09261fa02f98134
push id47
push userryanvm@gmail.com
push dateTue, 18 Dec 2012 03:10:02 +0000
bugs820652
milestone18.0
Bug 820652 (part 2) - DMD: Embriefen the hash policy of LiveBlockGroup and DoubleReportBlockGroup. r+a=jlebar
memory/replace/dmd/DMD.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -645,33 +645,35 @@ public:
 
   bool IsReported() const
   {
     MOZ_ASSERT(IsSane());
     bool isRep = mReporterName != gUnreportedName;
     return isRep;
   }
 
-  // Quasi-hash policy (used by LiveBlockGroup's hash policy).
+  // Hash policy.
   //
-  // Hash() and Match() both assume that identical reporter names have
+  // hash() and match() both assume that identical reporter names have
   // identical pointers.  In practice this always happens because they are
   // static strings (as specified in the NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN
   // macro).  This is true even for multi-reporters.  (If it ever became
   // untrue, the worst that would happen is that some blocks that should be in
   // the same block group would end up in separate block groups.)
 
-  static uint32_t Hash(const LiveBlockKey& aKey)
+  typedef LiveBlockKey Lookup;
+
+  static uint32_t hash(const LiveBlockKey& aKey)
   {
     return mozilla::HashGeneric(aKey.mAllocStackTrace,
                                 aKey.mReportStackTrace,
                                 aKey.mReporterName);
   }
 
-  static bool Match(const LiveBlockKey& aA, const LiveBlockKey& aB)
+  static bool match(const LiveBlockKey& aA, const LiveBlockKey& aB)
   {
     return aA.mAllocStackTrace  == aB.mAllocStackTrace &&
            aA.mReportStackTrace == aB.mReportStackTrace &&
            aA.mReporterName     == aB.mReporterName;
   }
 };
 
 // This is used by DoubleReportBlockGroups.
@@ -707,31 +709,33 @@ public:
   {
     return mAllocStackTrace &&
            mReportStackTrace1 &&
            mReportStackTrace2 &&
            mReporterName1 != gUnreportedName &&
            mReporterName2 != gUnreportedName;
   }
 
-  // Quasi-hash policy (used by DoubleReportBlockGroup's hash policy).
+  // Hash policy.
   //
-  // Hash() and Match() both assume that identical reporter names have
+  // hash() and match() both assume that identical reporter names have
   // identical pointers.  See LiveBlockKey for more.
 
-  static uint32_t Hash(const DoubleReportBlockKey& aKey)
+  typedef DoubleReportBlockKey Lookup;
+
+  static uint32_t hash(const DoubleReportBlockKey& aKey)
   {
     return mozilla::HashGeneric(aKey.mAllocStackTrace,
                                 aKey.mReportStackTrace1,
                                 aKey.mReportStackTrace2,
                                 aKey.mReporterName1,
                                 aKey.mReporterName2);
   }
 
-  static bool Match(const DoubleReportBlockKey& aA,
+  static bool match(const DoubleReportBlockKey& aA,
                     const DoubleReportBlockKey& aB)
   {
     return aA.mAllocStackTrace   == aB.mAllocStackTrace &&
            aA.mReportStackTrace1 == aB.mReportStackTrace1 &&
            aA.mReportStackTrace2 == aB.mReportStackTrace2 &&
            aA.mReporterName1     == aB.mReporterName1 &&
            aA.mReporterName2     == aB.mReporterName2;
   }
@@ -1056,30 +1060,16 @@ public:
   {
     const LiveBlockGroup* const a =
       *static_cast<const LiveBlockGroup* const*>(aA);
     const LiveBlockGroup* const b =
       *static_cast<const LiveBlockGroup* const*>(aB);
 
     return BlockSize::Cmp(a->mCombinedSize, b->mCombinedSize);
   }
-
-  // Hash policy
-
-  typedef LiveBlockKey Lookup;
-
-  static uint32_t hash(const LiveBlockKey& aKey)
-  {
-    return LiveBlockKey::Hash(aKey);
-  }
-
-  static bool match(const LiveBlockGroup& aBg, const LiveBlockKey& aKey)
-  {
-    return LiveBlockKey::Match(aBg, aKey);
-  }
 };
 
 typedef js::HashSet<LiveBlockGroup, LiveBlockGroup, InfallibleAllocPolicy>
         LiveBlockGroupTable;
 
 void
 LiveBlockGroup::Print(const Writer& aWriter, uint32_t aM, uint32_t aN,
                       const char* aStr, const char* astr,
@@ -1137,31 +1127,16 @@ public:
   {
     const DoubleReportBlockGroup* const a =
       *static_cast<const DoubleReportBlockGroup* const*>(aA);
     const DoubleReportBlockGroup* const b =
       *static_cast<const DoubleReportBlockGroup* const*>(aB);
 
     return BlockSize::Cmp(a->mCombinedSize, b->mCombinedSize);
   }
-
-  // Hash policy
-
-  typedef DoubleReportBlockKey Lookup;
-
-  static uint32_t hash(const DoubleReportBlockKey& aKey)
-  {
-    return DoubleReportBlockKey::Hash(aKey);
-  }
-
-  static bool match(const DoubleReportBlockGroup& aBg,
-                    const DoubleReportBlockKey& aKey)
-  {
-    return DoubleReportBlockKey::Match(aBg, aKey);
-  }
 };
 
 typedef js::HashSet<DoubleReportBlockGroup, DoubleReportBlockGroup,
                     InfallibleAllocPolicy> DoubleReportBlockGroupTable;
 DoubleReportBlockGroupTable* gDoubleReportBlockGroupTable = nullptr;
 
 void
 DoubleReportBlockGroup::Print(const Writer& aWriter, uint32_t aM, uint32_t aN,