From e70bc26b57df85b314ae4ec03f1bcf148853f9e0 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Wed, 5 Oct 2011 14:03:39 -0400 Subject: [PATCH] Bug 691003 - jemalloc's minimum alignment must be word sized on *nix. r=khuey --HG-- extra : rebase_source : 24c31b1afcc10af36f6d87ec6ec3e462b18cceff --- memory/jemalloc/jemalloc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/memory/jemalloc/jemalloc.c b/memory/jemalloc/jemalloc.c index a8fc2a2b24b..74683930151 100644 --- a/memory/jemalloc/jemalloc.c +++ b/memory/jemalloc/jemalloc.c @@ -82,6 +82,10 @@ * | | ... | * |=====================================| * + * NOTE: Due to Mozilla bug 691003, we cannot reserve less than one word for an + * allocation on Linux or Mac. So on 32-bit *nix, the smallest bucket size is + * 4 bytes, and on 64-bit, the smallest bucket size is 8 bytes. + * * A different mechanism is used for each category: * * Small : Each size class is segregated into its own set of runs. Each run @@ -426,7 +430,7 @@ static const bool __isthreaded = true; /* Size of stack-allocated buffer passed to strerror_r(). */ #define STRERROR_BUF 64 -/* Minimum alignment of allocations is 2^QUANTUM_2POW_MIN bytes. */ +/* Minimum alignment of non-tiny allocations is 2^QUANTUM_2POW_MIN bytes. */ # define QUANTUM_2POW_MIN 4 #ifdef MOZ_MEMORY_SIZEOF_PTR_2POW # define SIZEOF_PTR_2POW MOZ_MEMORY_SIZEOF_PTR_2POW @@ -515,8 +519,15 @@ static const bool __isthreaded = true; #define CACHELINE_2POW 6 #define CACHELINE ((size_t)(1U << CACHELINE_2POW)) -/* Smallest size class to support. */ +/* + * Smallest size class to support. On Linux and Mac, even malloc(1) must + * reserve a word's worth of memory (see Mozilla bug 691003). + */ +#ifdef MOZ_MEMORY_WINDOWS #define TINY_MIN_2POW 1 +#else +#define TINY_MIN_2POW (sizeof(void*) == 8 ? 3 : 2) +#endif /* * Maximum size class that is a multiple of the quantum, but not (necessarily)