Bug 1363992 - Remove support for system jemalloc. r=njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 11 May 2017 13:03:20 +0900
changeset 578140 a856d2d8300ad6afcb47adbf51e3923e289e893d
parent 578139 648fe1aaa3ce005b7b00de5a692b7984e5995b09
child 578141 7e93ef0b24e914037fc4ed4d0ebdc1045087b6bd
push id58909
push userbmo:mh+mozilla@glandium.org
push dateMon, 15 May 2017 23:34:42 +0000
reviewersnjn
bugs1363992
milestone55.0a1
Bug 1363992 - Remove support for system jemalloc. r=njn
build/autoconf/jemalloc.m4
memory/build/jemalloc_config.cpp
memory/build/moz.build
memory/build/mozjemalloc_compat.c
memory/build/mozmemory_wrap.h
memory/build/replace_malloc.c
memory/moz.build
mozglue/build/moz.build
old-configure.in
storage/moz.build
--- a/build/autoconf/jemalloc.m4
+++ b/build/autoconf/jemalloc.m4
@@ -3,17 +3,17 @@ dnl License, v. 2.0. If a copy of the MP
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 AC_DEFUN([MOZ_SUBCONFIGURE_JEMALLOC], [
 
 if test "$MOZ_BUILD_APP" != js -o -n "$JS_STANDALONE"; then
 
   # Run jemalloc configure script
 
-  if test -z "$MOZ_SYSTEM_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC4" -o -n "$MOZ_REPLACE_MALLOC"; then
+  if test "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC4" -o -n "$MOZ_REPLACE_MALLOC"; then
     ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_ --disable-valgrind"
     if test -n "$MOZ_DEBUG"; then
       ac_configure_args="$ac_configure_args --enable-debug"
     fi
     # We're using memalign for _aligned_malloc in memory/build/mozmemory_wrap.c
     # on Windows, so just export memalign on all platforms.
     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
     if test -n "$MOZ_REPLACE_MALLOC"; then
--- a/memory/build/jemalloc_config.cpp
+++ b/memory/build/jemalloc_config.cpp
@@ -6,22 +6,18 @@
 
 #define MOZ_JEMALLOC_IMPL
 
 /* mozmemory_wrap.h needs to be included before MFBT headers */
 #include "mozmemory_wrap.h"
 #include <mozilla/Assertions.h>
 #include "mozilla/Types.h"
 
-#if defined(MOZ_SYSTEM_JEMALLOC)
-#include MALLOC_H
-#else
 #define DLLEXPORT
 #include "jemalloc/jemalloc.h"
-#endif
 
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 #ifdef XP_DARWIN
 #include <sys/mman.h>
 #endif
 
--- a/memory/build/moz.build
+++ b/memory/build/moz.build
@@ -46,15 +46,14 @@ if CONFIG['OS_TARGET'] == 'Darwin' and (
     ]
 
 Library('memory')
 
 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
     DIST_INSTALL = True
 
 # Keep jemalloc separated when mozglue is statically linked
-if CONFIG['MOZ_MEMORY'] and (CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android') or
-                             CONFIG['MOZ_SYSTEM_JEMALLOC']):
+if CONFIG['MOZ_MEMORY'] and CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'):
     FINAL_LIBRARY = 'mozglue'
 
 if CONFIG['MOZ_REPLACE_MALLOC'] and CONFIG['OS_TARGET'] == 'Darwin':
     # The zone allocator for OSX needs some jemalloc internal functions
     LOCAL_INCLUDES += ['/memory/jemalloc/src/include']
--- a/memory/build/mozjemalloc_compat.c
+++ b/memory/build/mozjemalloc_compat.c
@@ -9,21 +9,17 @@
 #define MOZ_JEMALLOC_IMPL
 
 #include "mozmemory_wrap.h"
 #include "jemalloc_types.h"
 #include "mozilla/Types.h"
 
 #include <stdbool.h>
 
-#if defined(MOZ_SYSTEM_JEMALLOC)
-#  include MALLOC_H
-#else
-#  include "jemalloc/jemalloc.h"
-#endif
+#include "jemalloc/jemalloc.h"
 
 /*
  *  CTL_* macros are from memory/jemalloc/src/src/stats.c with changes:
  *  - drop `t' argument to avoid redundancy in calculating type size
  *  - require `i' argument for arena number explicitly
  */
 
 #define	CTL_GET(n, v) do {						\
--- a/memory/build/mozmemory_wrap.h
+++ b/memory/build/mozmemory_wrap.h
@@ -121,53 +121,48 @@
 #  ifdef MFBT_API /* mozilla/Types.h was already included */
 #    error mozmemory_wrap.h has to be included before mozilla/Types.h when MOZ_MEMORY_IMPL is set and IMPL_MFBT is not.
 #  endif
 #  define IMPL_MFBT
 #endif
 
 #include "mozilla/Types.h"
 
-#if !defined(MOZ_SYSTEM_JEMALLOC)
-#  ifdef MOZ_MEMORY_IMPL
-#    if defined(MOZ_JEMALLOC_IMPL) && defined(MOZ_REPLACE_MALLOC) && !defined(MOZ_REPLACE_JEMALLOC)
-#      define mozmem_malloc_impl(a)     je_ ## a
-#      define mozmem_jemalloc_impl(a)   je_ ## a
+#ifdef MOZ_MEMORY_IMPL
+#  if defined(MOZ_JEMALLOC_IMPL) && defined(MOZ_REPLACE_MALLOC) && !defined(MOZ_REPLACE_JEMALLOC)
+#    define mozmem_malloc_impl(a)     je_ ## a
+#    define mozmem_jemalloc_impl(a)   je_ ## a
+#  else
+#    define MOZ_JEMALLOC_API MFBT_API
+#    ifdef MOZ_REPLACE_JEMALLOC
+#      define MOZ_MEMORY_API MFBT_API
+#      define mozmem_malloc_impl(a)     replace_ ## a
+#      define mozmem_jemalloc_impl(a)   replace_ ## a
+#    elif (defined(XP_WIN) || defined(XP_DARWIN))
+#      if defined(MOZ_REPLACE_MALLOC)
+#        define mozmem_malloc_impl(a)   a ## _impl
+#      else
+#        define mozmem_malloc_impl(a)   je_ ## a
+#      endif
 #    else
-#      define MOZ_JEMALLOC_API MFBT_API
-#      ifdef MOZ_REPLACE_JEMALLOC
-#        define MOZ_MEMORY_API MFBT_API
-#        define mozmem_malloc_impl(a)     replace_ ## a
-#        define mozmem_jemalloc_impl(a)   replace_ ## a
-#      elif (defined(XP_WIN) || defined(XP_DARWIN))
-#        if defined(MOZ_REPLACE_MALLOC)
-#          define mozmem_malloc_impl(a)   a ## _impl
-#        else
-#          define mozmem_malloc_impl(a)   je_ ## a
-#        endif
-#      else
-#        define MOZ_MEMORY_API MFBT_API
-#        if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
-#          define MOZ_WRAP_NEW_DELETE
-#        endif
+#      define MOZ_MEMORY_API MFBT_API
+#      if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#        define MOZ_WRAP_NEW_DELETE
 #      endif
 #    endif
-#    ifdef XP_WIN
-#      define mozmem_dup_impl(a)      wrap_ ## a
-#    endif
 #  endif
-
-/* All other jemalloc3 functions are prefixed with "je_", except when
- * building against an unprefixed system jemalloc library */
-#  define je_(a) je_ ## a
-#else /* defined(MOZ_SYSTEM_JEMALLOC) */
-#  define je_(a) a
+#  ifdef XP_WIN
+#    define mozmem_dup_impl(a)      wrap_ ## a
+#  endif
 #endif
 
-#if !defined(MOZ_MEMORY_IMPL) || defined(MOZ_SYSTEM_JEMALLOC)
+/* All other jemalloc3 functions are prefixed with "je_" */
+#define je_(a) je_ ## a
+
+#if !defined(MOZ_MEMORY_IMPL)
 #  define MOZ_MEMORY_API MFBT_API
 #  define MOZ_JEMALLOC_API MFBT_API
 #endif
 
 #ifndef MOZ_MEMORY_API
 #  define MOZ_MEMORY_API
 #endif
 #ifndef MOZ_JEMALLOC_API
--- a/memory/build/replace_malloc.c
+++ b/memory/build/replace_malloc.c
@@ -5,20 +5,16 @@
 #ifndef MOZ_MEMORY
 #  error Should not compile this file when MOZ_MEMORY is not set
 #endif
 
 #ifndef MOZ_REPLACE_MALLOC
 #  error Should not compile this file when replace-malloc is disabled
 #endif
 
-#ifdef MOZ_SYSTEM_JEMALLOC
-#  error Should not compile this file when we want to use native jemalloc
-#endif
-
 #include "mozmemory_wrap.h"
 
 /* Declare all je_* functions */
 #define MALLOC_DECL(name, return_type, ...) \
   return_type je_ ## name(__VA_ARGS__);
 #include "malloc_decls.h"
 
 #include "mozilla/Likely.h"
--- a/memory/moz.build
+++ b/memory/moz.build
@@ -19,13 +19,12 @@ if CONFIG['MOZ_MEMORY']:
     # NB: gtest dir is included in toolkit/toolkit.build due to its dependency
     # on libxul.
     DIRS += [
         'build',
         'mozjemalloc',
     ]
 
     if CONFIG['MOZ_JEMALLOC4'] or CONFIG['MOZ_REPLACE_MALLOC']:
-        if not CONFIG['MOZ_SYSTEM_JEMALLOC']:
-            DIRS += ['jemalloc']
+        DIRS += ['jemalloc']
 
     if CONFIG['MOZ_REPLACE_MALLOC']:
         DIRS += ['replace']
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -25,17 +25,17 @@ if CONFIG['OS_TARGET'] == 'WINNT':
     DEFFILE = 'mozglue.def'
     # We'll break the DLL blocklist if we immediately load user32.dll
     DELAYLOAD_DLLS += [
         'user32.dll',
     ]
 
 if not CONFIG['JS_STANDALONE']:
 
-    if CONFIG['MOZ_MEMORY'] and (CONFIG['MOZ_SYSTEM_JEMALLOC'] or FORCE_SHARED_LIB):
+    if CONFIG['MOZ_MEMORY'] and FORCE_SHARED_LIB:
         pass
         # TODO: SHARED_LIBRARY_LIBS go here
     else:
         # Temporary, until bug 662814 lands
         NO_VISIBILITY_FLAGS = True
         SOURCES += [
             'dummy.cpp',
         ]
--- a/old-configure.in
+++ b/old-configure.in
@@ -4071,18 +4071,16 @@ Android|WINNT|Darwin)
 *)
   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
   MOZ_GLUE_IN_PROGRAM=1
   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
   ;;
 esac
 
 if test -n "$MOZ_REPLACE_MALLOC"; then
-    MOZ_SYSTEM_JEMALLOC=
-
     dnl Replace-malloc Mac linkage quirks
     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
         AC_CACHE_CHECK([how to do weak dynamic linking],
             ac_cv_weak_dynamic_linking,
             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
                 test -s conftest${DLL_SUFFIX}; then
                  dnl There are several ways the linker can put link edit rules in a binary:
@@ -4139,38 +4137,28 @@ if test -z "$MOZ_MEMORY"; then
   case "${target}" in
     *-mingw*)
       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
         AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
       fi
       ;;
   esac
 else
-  if test -n "$MOZ_JEMALLOC4" -a -z "$MOZ_REPLACE_MALLOC"; then
-    MOZ_SYSTEM_JEMALLOC=1
-    AC_CHECK_FUNCS(mallctl nallocx,,
-      [MOZ_SYSTEM_JEMALLOC=
-       break])
-    if test -n "$MOZ_SYSTEM_JEMALLOC"; then
-      AC_DEFINE(MOZ_SYSTEM_JEMALLOC)
-    fi
-  fi
   if test "x$MOZ_DEBUG" = "x1"; then
     AC_DEFINE(MOZ_MEMORY_DEBUG)
   fi
   dnl The generic feature tests that determine how to compute ncpus are long and
   dnl complicated.  Therefore, simply define special cpp variables for the
   dnl platforms we have special knowledge of.
   case "${target}" in
   *-mingw*)
     export MOZ_NO_DEBUG_RTL=1
     ;;
   esac
 fi # MOZ_MEMORY
-AC_SUBST(MOZ_SYSTEM_JEMALLOC)
 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
 
 # Allow the application to provide a subconfigure script.
 # This should be after 'export MOZ_NO_DEBUG_RTL=1' since
 # ldap/c-sdk/configure refers to the enviroment value.
 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
   do_output_subdirs() {
     if test -n "$_subconfigure_subdirs"; then
--- a/storage/moz.build
+++ b/storage/moz.build
@@ -96,18 +96,17 @@ FINAL_LIBRARY = 'xul'
 # of memory using the default allocator, prior to the storage service
 # registering its allocator, causing memory management failures (bug 938730).
 # However, this is not an issue if both the jemalloc allocator and the default
 # allocator are the same thing.
 #
 # Note: On Windows our sqlite build assumes we use jemalloc.  If you disable
 # MOZ_STORAGE_MEMORY on Windows, you will also need to change the "ifdef
 # MOZ_MEMORY" options in db/sqlite3/src/Makefile.in.
-if CONFIG['MOZ_MEMORY'] and (not CONFIG['MOZ_SYSTEM_SQLITE']
-                             or CONFIG['MOZ_SYSTEM_JEMALLOC']):
+if CONFIG['MOZ_MEMORY'] and not CONFIG['MOZ_SYSTEM_SQLITE']:
     if CONFIG['OS_TARGET'] != 'Android':
         DEFINES['MOZ_STORAGE_MEMORY'] = True
 
 # This is the default value.  If we ever change it when compiling sqlite, we
 # will need to change it here as well.
 DEFINES['SQLITE_MAX_LIKE_PATTERN_LENGTH'] = 50000
 
 # See Sqlite moz.build for reasoning about TEMP_STORE.