Bug 738176 - Completely disable jemalloc when it's supposed to be disabled on OSX, and cleanup exposed APIs. r=jlebar,r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 05 Apr 2012 09:20:53 +0200
changeset 94381 26eb0d5a95a643a96e1b8b1f830809471aa670db
parent 94380 55ba87dd42e26d724283d2cc91a3fdf9f641c268
child 94382 e51a6ddc328297fed90bd4f84cd4b555e2646c02
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar, khuey
bugs738176
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 738176 - Completely disable jemalloc when it's supposed to be disabled on OSX, and cleanup exposed APIs. r=jlebar,r=khuey
configure.in
gfx/thebes/gfxImageSurface.cpp
ipc/chromium/src/base/process_util_linux.cc
js/src/configure.in
memory/jemalloc/jemalloc.c
memory/jemalloc/jemalloc.h
memory/mozalloc/mozalloc.cpp
memory/mozalloc/mozalloc.h
memory/mozalloc/mozalloc_macro_wrappers.h
memory/mozalloc/mozalloc_undef_macro_wrappers.h
mozglue/build/Makefile.in
mozglue/build/mozglue.def.in
storage/src/mozStorageService.cpp
xpcom/base/nsMemoryReporterManager.cpp
--- a/configure.in
+++ b/configure.in
@@ -7209,23 +7209,16 @@ else
     rm crtdll.obj
 
     export DLLFLAGS
     ;;
   *)
     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
     ;;
   esac
-
-  if test "$OS_ARCH" != "WINNT"; then
-    dnl NB: this must be kept in sync with jemalloc.h
-    AC_DEFINE(HAVE_JEMALLOC_VALLOC)
-  fi
-  AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
-  AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
 fi # MOZ_MEMORY
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_GLUE_LDFLAGS)
 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
 AC_SUBST(WIN32_CRT_LIBS)
 dnl Need to set this for make because NSS doesn't have configure
 AC_SUBST(DLLFLAGS)
 
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -104,17 +104,17 @@ gfxImageSurface::InitWithData(unsigned c
     // no check here.
     Init(surface);
 }
 
 static void*
 TryAllocAlignedBytes(size_t aSize)
 {
     // Use fallible allocators here
-#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
+#if defined(HAVE_POSIX_MEMALIGN)
     void* ptr;
     // Try to align for fast alpha recovery.  This should only help
     // cairo too, can't hurt.
     return moz_posix_memalign(&ptr,
                               1 << gfxAlphaRecovery::GoodAlignmentLog2(),
                               aSize) ?
              nsnull : ptr;
 #else
--- a/ipc/chromium/src/base/process_util_linux.cc
+++ b/ipc/chromium/src/base/process_util_linux.cc
@@ -14,20 +14,16 @@
 
 #include "base/debug_util.h"
 #include "base/eintr_wrapper.h"
 #include "base/file_util.h"
 #include "base/logging.h"
 #include "base/string_tokenizer.h"
 #include "base/string_util.h"
 
-#ifdef MOZ_MEMORY_ANDROID
-#include "jemalloc.h"
-#endif
-
 namespace {
 
 enum ParsingState {
   KEY_NAME,
   KEY_VALUE
 };
 
 static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG");
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -4083,23 +4083,16 @@ if test "$MOZ_MEMORY"; then
   *-mingw*)
     AC_DEFINE(MOZ_MEMORY_WINDOWS)
     # the interesting bits will get passed down in MOZ_GLUE_LDFLAGS
     ;;
   *)
     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
     ;;
   esac
-
-  if test "$OS_ARCH" != "Darwin"; then
-    dnl NB: this must be kept in sync with jemalloc.h
-    AC_DEFINE(HAVE_JEMALLOC_VALLOC)
-    AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
-    AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
-  fi
 fi
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_GLUE_LDFLAGS)
 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
 
 dnl ========================================================
 dnl = Use malloc wrapper lib
 dnl ========================================================
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -118,16 +118,18 @@
  * absence of memory pressure, the contribution from the heap to RSS will not
  * decrease due to our madvise calls.
  *
  * We therefore define MALLOC_DOUBLE_PURGE on Mac.  This causes jemalloc to
  * track which pages have been MADV_FREE'd.  You can then call
  * jemalloc_purge_freed_pages(), which will force the OS to release those
  * MADV_FREE'd pages, making the process's RSS reflect its true memory usage.
  *
+ * The jemalloc_purge_freed_pages definition in jemalloc.h needs to be
+ * adjusted if MALLOC_DOUBLE_PURGE is ever enabled on Linux.
  */
 #ifdef MOZ_MEMORY_DARWIN
 #define MALLOC_DOUBLE_PURGE
 #endif
 
 /*
  * MALLOC_PRODUCTION disables assertions and statistics gathering.  It also
  * defaults the A and J runtime options to off.  These settings are appropriate
@@ -369,17 +371,17 @@ typedef long ssize_t;
 #endif
 
 #ifndef MOZ_MEMORY
 #include "un-namespace.h"
 #endif
 
 #endif
 
-#include "jemalloc.h"
+#include "jemalloc_types.h"
 #include "linkedlist.h"
 
 /* Some tools, such as /dev/dsp wrappers, LD_PRELOAD libraries that
  * happen to override mmap() and call dlsym() from their overridden
  * mmap(). The problem is that dlsym() calls malloc(), and this ends
  * up in a dead lock in jemalloc.
  * On these systems, we prefer to directly use the system call.
  * We do that for Linux systems and kfreebsd with GNU userland.
@@ -6545,18 +6547,21 @@ free(void *ptr)
  * End malloc(3)-compatible functions.
  */
 /******************************************************************************/
 /*
  * Begin non-standard functions.
  */
 
 /* This was added by Mozilla for use by SQLite. */
+#ifdef MOZ_MEMORY_DARWIN
+static
+#endif
 size_t
-je_malloc_usable_size_in_advance(size_t size)
+je_malloc_good_size(size_t size)
 {
 	/*
 	 * This duplicates the logic in imalloc(), arena_malloc() and
 	 * arena_malloc_small().
 	 */
 	if (size < small_min) {
 		/* Small (tiny). */
 		size = pow2_ceil(size);
@@ -6576,17 +6581,17 @@ je_malloc_usable_size_in_advance(size_t 
 	} else if (size <= arena_maxclass) {
 		/* Large. */
 		size = PAGE_CEILING(size);
 	} else {
 		/*
 		 * Huge.  We use PAGE_CEILING to get psize, instead of using
 		 * CHUNK_CEILING to get csize.  This ensures that this
 		 * malloc_usable_size(malloc(n)) always matches
-		 * je_malloc_usable_size_in_advance(n).
+		 * je_malloc_good_size(n).
 		 */
 		size = PAGE_CEILING(size);
 	}
 	return size;
 }
 
 
 #ifdef MOZ_MEMORY_ANDROID
@@ -6910,17 +6915,17 @@ zone_destroy(malloc_zone_t *zone)
 	/* This function should never be called. */
 	assert(false);
 	return (NULL);
 }
 
 static size_t
 zone_good_size(malloc_zone_t *zone, size_t size)
 {
-	return je_malloc_usable_size_in_advance(size);
+	return je_malloc_good_size(size);
 }
 
 static size_t
 ozone_size(malloc_zone_t *zone, void *ptr)
 {
 	size_t ret = isalloc_validate(ptr);
 	if (ret == 0)
 		ret = szone->size(zone, ptr);
--- a/memory/jemalloc/jemalloc.h
+++ b/memory/jemalloc/jemalloc.h
@@ -27,62 +27,48 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef _JEMALLOC_H_
 #define _JEMALLOC_H_
 
+#if defined(MOZ_MEMORY_DARWIN)
+#include <malloc/malloc.h>
+#endif
 #include "jemalloc_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern const char *_malloc_options;
-
-/* Darwin and Linux already have memory allocation functions */
-#if (!defined(MOZ_MEMORY_DARWIN) && !defined(MOZ_MEMORY_LINUX))
-void	*malloc(size_t size);
-void	*valloc(size_t size);
-void	*calloc(size_t num, size_t size);
-void	*realloc(void *ptr, size_t size);
-void	free(void *ptr);
-int	posix_memalign(void **memptr, size_t alignment, size_t size);
-#endif /* MOZ_MEMORY_DARWIN, MOZ_MEMORY_LINUX */
-
-/* Android doesn't have posix_memalign */
-#ifdef MOZ_MEMORY_ANDROID
-int	posix_memalign(void **memptr, size_t alignment, size_t size);
+#if defined(MOZ_MEMORY_LINUX)
+__attribute__((weak))
 #endif
-
-#if defined(MOZ_MEMORY_DARWIN) || defined(MOZ_MEMORY_WINDOWS)
-void	*je_malloc(size_t size);
-void	*je_valloc(size_t size);
-void	*je_calloc(size_t num, size_t size);
-void	*je_realloc(void *ptr, size_t size);
-void	je_free(void *ptr);
-void *je_memalign(size_t alignment, size_t size);
-int	je_posix_memalign(void **memptr, size_t alignment, size_t size);
-char    *je_strndup(const char *src, size_t len);
-char    *je_strdup(const char *src);
-size_t	je_malloc_usable_size(const void *ptr);
-#endif
-
-/* Linux has memalign and malloc_usable_size */
-#if !defined(MOZ_MEMORY_LINUX)
-void	*memalign(size_t alignment, size_t size);
-size_t	malloc_usable_size(const void *ptr);
-#endif /* MOZ_MEMORY_LINUX */
-
 void	jemalloc_stats(jemalloc_stats_t *stats);
 
 /* Computes the usable size in advance. */
-size_t	je_malloc_usable_size_in_advance(size_t size);
+#if !defined(MOZ_MEMORY_DARWIN)
+#if defined(MOZ_MEMORY_LINUX)
+__attribute__((weak))
+#endif
+size_t je_malloc_good_size(size_t size);
+#endif
+
+static inline size_t je_malloc_usable_size_in_advance(size_t size) {
+#if defined(MOZ_MEMORY_DARWIN)
+  return malloc_good_size(size);
+#else
+  if (je_malloc_good_size)
+    return je_malloc_good_size(size);
+  else
+    return size;
+#endif
+}
 
 /*
  * On some operating systems (Mac), we use madvise(MADV_FREE) to hand pages
  * back to the operating system.  On Mac, the operating system doesn't take
  * this memory back immediately; instead, the OS takes it back only when the
  * machine is running out of physical memory.
  *
  * This is great from the standpoint of efficiency, but it makes measuring our
@@ -99,15 +85,19 @@ size_t	je_malloc_usable_size_in_advance(
  *
  * This function is also expensive in that the next time we go to access a page
  * which we've just explicitly decommitted, the operating system has to attach
  * to it a physical page!  If we hadn't run this function, the OS would have
  * less work to do.
  *
  * If MALLOC_DOUBLE_PURGE is not defined, this function does nothing.
  */
+#if defined(MOZ_MEMORY_LINUX)
+static inline void jemalloc_purge_freed_pages() { }
+#else
 void    jemalloc_purge_freed_pages();
+#endif
 
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
 
 #endif /* _JEMALLOC_H_ */
--- a/memory/mozalloc/mozalloc.cpp
+++ b/memory/mozalloc/mozalloc.cpp
@@ -48,54 +48,38 @@
 #  include MALLOC_H             // for memalign, valloc where available
 #endif // if defined(MALLOC_H)
 #include <stddef.h>             // for size_t
 #include <stdlib.h>             // for malloc, free
 #if defined(XP_UNIX)
 #  include <unistd.h>           // for valloc on *BSD
 #endif //if defined(XP_UNIX)
 
-#if defined(MOZ_MEMORY)
-// jemalloc.h doesn't redeclare symbols if they're provided by the OS
-#  include "jemalloc.h"
-#endif
-
 #if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
 #  define MOZALLOC_EXPORT __declspec(dllexport)
 #endif
 
 // Make sure that "malloc" et al. resolve to their libc variants.
 #define MOZALLOC_DONT_DEFINE_MACRO_WRAPPERS
 #include "mozilla/mozalloc.h"
 #include "mozilla/mozalloc_oom.h"  // for mozalloc_handle_oom
 
+/* Windows doesn't have malloc_usable_size, but jemalloc has */
+#if defined(MOZ_MEMORY_WINDOWS)
+extern "C" size_t malloc_usable_size(const void *ptr);
+#endif
 
 #if defined(__GNUC__) && (__GNUC__ > 2)
 #define LIKELY(x)    (__builtin_expect(!!(x), 1))
 #define UNLIKELY(x)  (__builtin_expect(!!(x), 0))
 #else
 #define LIKELY(x)    (x)
 #define UNLIKELY(x)  (x)
 #endif
 
-#ifdef MOZ_MEMORY_DARWIN
-#include "jemalloc.h"
-#define malloc(a)               je_malloc(a)
-#define posix_memalign(a, b, c) je_posix_memalign(a, b, c)
-#define valloc(a)               je_valloc(a)
-#define calloc(a, b)            je_calloc(a, b)
-#define memalign(a, b)          je_memalign(a, b)
-#define strdup(a)               je_strdup(a)
-#define strndup(a, b)           je_strndup(a, b)
-/* We omit functions which could be passed a memory region that was not
- * allocated by jemalloc (realloc, free and malloc_usable_size). Instead,
- * we use the system-provided functions, which will in turn call the
- * jemalloc versions when appropriate */
-#endif
-
 void
 moz_free(void* ptr)
 {
     free(ptr);
 }
 
 void*
 moz_xmalloc(size_t size)
@@ -174,17 +158,17 @@ moz_xstrndup(const char* str, size_t str
 }
 char*
 moz_strndup(const char* str, size_t strsize)
 {
     return strndup(str, strsize);
 }
 #endif  // if defined(HAVE_STRNDUP)
 
-#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
+#if defined(HAVE_POSIX_MEMALIGN)
 int
 moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
 {
     int err = posix_memalign(ptr, alignment, size);
     if (UNLIKELY(err && ENOMEM == err)) {
         mozalloc_handle_oom(size);
         return moz_xposix_memalign(ptr, alignment, size);
     }
@@ -209,17 +193,17 @@ moz_posix_memalign(void **ptr, size_t al
     }
 #endif
 
     return code;
 
 }
 #endif // if defined(HAVE_POSIX_MEMALIGN)
 
-#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_MEMALIGN)
+#if defined(HAVE_MEMALIGN)
 void*
 moz_xmemalign(size_t boundary, size_t size)
 {
     void* ptr = memalign(boundary, size);
     if (UNLIKELY(!ptr && EINVAL != errno)) {
         mozalloc_handle_oom(size);
         return moz_xmemalign(boundary, size);
     }
@@ -228,17 +212,17 @@ moz_xmemalign(size_t boundary, size_t si
 }
 void*
 moz_memalign(size_t boundary, size_t size)
 {
     return memalign(boundary, size);
 }
 #endif // if defined(HAVE_MEMALIGN)
 
-#if defined(HAVE_VALLOC) || defined(HAVE_JEMALLOC_VALLOC)
+#if defined(HAVE_VALLOC)
 void*
 moz_xvalloc(size_t size)
 {
     void* ptr = valloc(size);
     if (UNLIKELY(!ptr)) {
         mozalloc_handle_oom(size);
         return moz_xvalloc(size);
     }
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -141,35 +141,35 @@ MOZALLOC_EXPORT size_t moz_malloc_size_o
 MOZALLOC_EXPORT char* moz_xstrndup(const char* str, size_t strsize)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 MOZALLOC_EXPORT char* moz_strndup(const char* str, size_t strsize)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_STRNDUP) */
 
 
-#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
+#if defined(HAVE_POSIX_MEMALIGN)
 MOZALLOC_EXPORT int moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
     NS_WARN_UNUSED_RESULT;
 
 MOZALLOC_EXPORT int moz_posix_memalign(void **ptr, size_t alignment, size_t size)
     NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_POSIX_MEMALIGN) */
 
 
-#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_MEMALIGN)
+#if defined(HAVE_MEMALIGN)
 MOZALLOC_EXPORT void* moz_xmemalign(size_t boundary, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 MOZALLOC_EXPORT void* moz_memalign(size_t boundary, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_MEMALIGN) */
 
 
-#if defined(HAVE_VALLOC) || defined(HAVE_JEMALLOC_VALLOC)
+#if defined(HAVE_VALLOC)
 MOZALLOC_EXPORT void* moz_xvalloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 MOZALLOC_EXPORT void* moz_valloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_VALLOC) */
 
 
--- a/memory/mozalloc/mozalloc_macro_wrappers.h
+++ b/memory/mozalloc/mozalloc_macro_wrappers.h
@@ -58,21 +58,21 @@
 #define realloc(_, __) moz_realloc(_, __)
 
 #define strdup(_) moz_strdup(_)
 
 #if defined(HAVE_STRNDUP)
 #define strndup(_, __) moz_strndup(_, __)
 #endif
 
-#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
+#if defined(HAVE_POSIX_MEMALIGN)
 #define posix_memalign(_, __, ___) moz_posix_memalign(_, __, ___)
 #endif
 
-#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_MEMALIGN)
+#if defined(HAVE_MEMALIGN)
 #define memalign(_, __) moz_memalign(_, __)
 #endif
 
 #if defined(HAVE_VALLOC)
 #define valloc(_) moz_valloc(_)
 #endif
 
 
--- a/memory/mozalloc/mozalloc_undef_macro_wrappers.h
+++ b/memory/mozalloc/mozalloc_undef_macro_wrappers.h
@@ -59,19 +59,19 @@
 #undef calloc
 #undef realloc
 #undef strdup
 
 #if defined(HAVE_STRNDUP)
 #  undef strndup
 #endif
 
-#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
+#if defined(HAVE_POSIX_MEMALIGN)
 #  undef posix_memalign
 #endif
 
-#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_MEMALIGN)
+#if defined(HAVE_MEMALIGN)
 #  undef memalign
 #endif
 
 #if defined(HAVE_VALLOC)
 #  undef valloc
 #endif
--- a/mozglue/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -114,20 +114,16 @@ SHARED_LIBRARY_LIBS += $(call EXPAND_LIB
 
 ifeq (Android, $(OS_TARGET))
 WRAP_LDFLAGS =
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_MEMORY
-ifeq (Darwin,$(OS_TARGET))
-LDFLAGS += -init _jemalloc_darwin_init
-endif
-
 ifeq (WINNT,$(OS_TARGET))
 # Roll our own custom logic here for the import library
 
 ###############################################################################
 #
 # Linking Mozilla itself to jemalloc is not particularly difficult.  To do this
 # we avoid linking directly to the Microsoft-provided CRT import libraries.
 # Instead, we link to our own import library which we generate here.  To
--- a/mozglue/build/mozglue.def.in
+++ b/mozglue/build/mozglue.def.in
@@ -46,13 +46,13 @@ EXPORTS
   memalign=je_memalign
   posix_memalign=je_posix_memalign
   strndup=je_strndup
   strdup=je_strdup
   _strdup=je_strdup
   wcsdup=je_wcsdup
   _wcsdup=je_wcsdup
   malloc_usable_size=je_malloc_usable_size
-  je_malloc_usable_size_in_advance
+  je_malloc_good_size
   jemalloc_stats
   ; A hack to work around the CRT (see giant comment in Makefile.in)
   frex=je_dumb_free_thunk
 #endif
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -525,29 +525,17 @@ void
 Service::shutdown()
 {
   NS_IF_RELEASE(sXPConnect);
 }
 
 sqlite3_vfs *ConstructTelemetryVFS();
 
 #ifdef MOZ_MEMORY
-
-#  if defined(XP_WIN) || defined(SOLARIS) || defined(ANDROID) || defined(XP_MACOSX)
-#    include "jemalloc.h"
-#  elif defined(XP_LINUX)
-// jemalloc is directly linked into firefox-bin; libxul doesn't link
-// with it.  So if we tried to use je_malloc_usable_size_in_advance directly
-// here, it wouldn't be defined.  Instead, we don't include the jemalloc header
-// and weakly link against je_malloc_usable_size_in_advance.
-extern "C" {
-extern size_t je_malloc_usable_size_in_advance(size_t size)
-  NS_VISIBILITY_DEFAULT __attribute__((weak));
-}
-#  endif  // XP_LINUX
+#  include "jemalloc.h"
 
 namespace {
 
 // By default, SQLite tracks the size of all its heap blocks by adding an extra
 // 8 bytes at the start of the block to hold the size.  Unfortunately, this
 // causes a lot of 2^N-sized allocations to be rounded up by jemalloc
 // allocator, wasting memory.  For example, a request for 1024 bytes has 8
 // bytes added, becoming a request for 1032 bytes, and jemalloc rounds this up
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -57,31 +57,18 @@ static PRInt64 GetExplicit()
     PRInt64 n;
     nsresult rv = mgr->GetExplicit(&n);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return n;
 }
 
 #if defined(MOZ_MEMORY)
-#  if defined(XP_WIN) || defined(SOLARIS) || defined(ANDROID) || defined(XP_MACOSX)
-#    define HAVE_JEMALLOC_STATS 1
-#    include "jemalloc.h"
-#  elif defined(XP_LINUX)
-#    define HAVE_JEMALLOC_STATS 1
-#    include "jemalloc_types.h"
-// jemalloc is directly linked into firefox-bin; libxul doesn't link
-// with it.  So if we tried to use jemalloc_stats directly here, it
-// wouldn't be defined.  Instead, we don't include the jemalloc header
-// and weakly link against jemalloc_stats.
-extern "C" {
-extern void jemalloc_stats(jemalloc_stats_t* stats)
-  NS_VISIBILITY_DEFAULT __attribute__((weak));
-}
-#  endif  // XP_LINUX
+#  define HAVE_JEMALLOC_STATS 1
+#  include "jemalloc.h"
 #endif  // MOZ_MEMORY
 
 #if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
 
 #include <sys/time.h>
 #include <sys/resource.h>
 
 static PRInt64 GetHardPageFaults()