Bug 1414155 - Remove SIZE_INV values for QUANTUM_2POW_MIN < 4. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 03 Nov 2017 11:41:30 +0900
changeset 693246 ab5a15fc1255b1848c3a2ccec666b91a3bbeed5c
parent 693245 458184d8ecd58211c93a51bea8c1289b438228f6
child 693247 a0e7c698b84bac16335be1f572c4d19d16183382
child 693253 50c1c7f4a28d731486f02ba827542f3f076929a5
push id87735
push userbmo:mh+mozilla@glandium.org
push dateSat, 04 Nov 2017 22:08:08 +0000
reviewersnjn
bugs1414155
milestone58.0a1
Bug 1414155 - Remove SIZE_INV values for QUANTUM_2POW_MIN < 4. r?njn QUANTUM_2POW_MIN is exactly 4, and we are unlikely to ever make it smaller. Also turn a MOZ_ASSERT into a static_assert, because it only uses constants, and will fail if QUANTUM_2POW_MIN is lowered without touching size_invs.
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -2334,34 +2334,23 @@ arena_run_reg_dalloc(arena_run_t* run, a
     SIZE_INV(3),
     SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7),
     SIZE_INV(8), SIZE_INV(9), SIZE_INV(10), SIZE_INV(11),
     SIZE_INV(12),SIZE_INV(13), SIZE_INV(14), SIZE_INV(15),
     SIZE_INV(16),SIZE_INV(17), SIZE_INV(18), SIZE_INV(19),
     SIZE_INV(20),SIZE_INV(21), SIZE_INV(22), SIZE_INV(23),
     SIZE_INV(24),SIZE_INV(25), SIZE_INV(26), SIZE_INV(27),
     SIZE_INV(28),SIZE_INV(29), SIZE_INV(30), SIZE_INV(31)
-#if (QUANTUM_2POW_MIN < 4)
-    ,
-    SIZE_INV(32), SIZE_INV(33), SIZE_INV(34), SIZE_INV(35),
-    SIZE_INV(36), SIZE_INV(37), SIZE_INV(38), SIZE_INV(39),
-    SIZE_INV(40), SIZE_INV(41), SIZE_INV(42), SIZE_INV(43),
-    SIZE_INV(44), SIZE_INV(45), SIZE_INV(46), SIZE_INV(47),
-    SIZE_INV(48), SIZE_INV(49), SIZE_INV(50), SIZE_INV(51),
-    SIZE_INV(52), SIZE_INV(53), SIZE_INV(54), SIZE_INV(55),
-    SIZE_INV(56), SIZE_INV(57), SIZE_INV(58), SIZE_INV(59),
-    SIZE_INV(60), SIZE_INV(61), SIZE_INV(62), SIZE_INV(63)
-#endif
   };
   // clang-format on
   unsigned diff, regind, elm, bit;
 
   MOZ_DIAGNOSTIC_ASSERT(run->magic == ARENA_RUN_MAGIC);
-  MOZ_ASSERT(((sizeof(size_invs)) / sizeof(unsigned)) + 3 >=
-             (SMALL_MAX_DEFAULT >> QUANTUM_2POW_MIN));
+  static_assert(((sizeof(size_invs)) / sizeof(unsigned)) + 3 >= nqbins,
+                "size_invs doesn't have enough values");
 
   // Avoid doing division with a variable divisor if possible.  Using
   // actual division here can reduce allocator throughput by over 20%!
   diff =
     (unsigned)((uintptr_t)ptr - (uintptr_t)run - bin->mRunFirstRegionOffset);
   if ((size & (size - 1)) == 0) {
     // log2_table allows fast division of a power of two in the
     // [1..128] range.