Bug 1414155 - Replace the cacheline-related macros with a constant. r?njn
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -377,18 +377,17 @@ struct arena_chunk_t
// Size and alignment of memory chunks that are allocated by the OS's virtual
// memory system.
#define CHUNK_2POW_DEFAULT 20
// Maximum size of L1 cache line. This is used to avoid cache line aliasing,
// so over-estimates are okay (up to a point), but under-estimates will
// negatively affect performance.
-#define CACHELINE_2POW 6
-#define CACHELINE ((size_t)(1U << CACHELINE_2POW))
+static const size_t kCacheLineSize = 64;
// Smallest size class to support. On Windows the smallest allocation size
// must be 8 bytes on 32-bit, 16 bytes on 64-bit. On Linux and Mac, even
// malloc(1) must reserve a word's worth of memory (see Mozilla bug 691003).
#ifdef XP_WIN
#define TINY_MIN_2POW (sizeof(void*) == 8 ? 4 : 3)
#else
#define TINY_MIN_2POW (sizeof(void*) == 8 ? 3 : 2)
@@ -534,17 +533,18 @@ static size_t opt_dirty_max = DIRTY_MAX_
// \/ Implicit binary fixed point.
#define RUN_MAX_OVRHD 0x0000003dU
#define RUN_MAX_OVRHD_RELAX 0x00001800U
// Return the smallest chunk multiple that is >= s.
#define CHUNK_CEILING(s) (((s) + chunksize_mask) & ~chunksize_mask)
// Return the smallest cacheline multiple that is >= s.
-#define CACHELINE_CEILING(s) (((s) + (CACHELINE - 1)) & ~(CACHELINE - 1))
+#define CACHELINE_CEILING(s) \
+ (((s) + (kCacheLineSize - 1)) & ~(kCacheLineSize - 1))
// Return the smallest quantum multiple that is >= a.
#define QUANTUM_CEILING(a) (((a) + quantum_mask) & ~quantum_mask)
// Return the smallest pagesize multiple that is >= s.
#define PAGE_CEILING(s) (((s) + pagesize_mask) & ~pagesize_mask)
// ***************************************************************************
@@ -755,17 +755,17 @@ 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 = CACHELINE_2POW;
+ static const size_t kNodeSize2Pow = LOG2(kCacheLineSize);
#else
static const size_t kNodeSize2Pow = 14;
#endif
static const size_t kBitsPerLevel = kNodeSize2Pow - 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,