Bug 1414155 - Define AddressRadixTree node size as a size rather than a power of 2. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 03 Nov 2017 13:50:44 +0900
changeset 693258 6481c8052ad1b292f1898ec331628e721d0896f7
parent 693257 e71852027eee19f3e2f1c9f627037b67a48c98cb
child 738975 2fb14c524a3e2110da5d58de7d51f2ab7b294a9b
push id87736
push userbmo:mh+mozilla@glandium.org
push dateSat, 04 Nov 2017 22:15:28 +0000
reviewersnjn
bugs1414155
milestone58.0a1
Bug 1414155 - Define AddressRadixTree node size as a size rather than a power of 2. r?njn
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -754,21 +754,21 @@ private:
 // like the following:
 // 0x12345678 -> mRoot[0x12][0x34]
 template<size_t Bits>
 class AddressRadixTree
 {
 // Size of each radix tree node (as a power of 2).
 // This impacts tree depth.
 #ifdef HAVE_64BIT_BUILD
-  static const size_t kNodeSize2Pow = LOG2(kCacheLineSize);
+  static const size_t kNodeSize = kCacheLineSize;
 #else
-  static const size_t kNodeSize2Pow = 14;
+  static const size_t kNodeSize = 16_KiB;
 #endif
-  static const size_t kBitsPerLevel = kNodeSize2Pow - LOG2(sizeof(void*));
+  static const size_t kBitsPerLevel = LOG2(kNodeSize) - LOG2(sizeof(void*));
   static const size_t kBitsAtLevel1 =
     (Bits % kBitsPerLevel) ? Bits % kBitsPerLevel : kBitsPerLevel;
   static const size_t kHeight = (Bits + kBitsPerLevel - 1) / kBitsPerLevel;
   static_assert(kBitsAtLevel1 + (kHeight - 1) * kBitsPerLevel == Bits,
                 "AddressRadixTree parameters don't work out");
 
   Mutex mLock;
   void** mRoot;