зеркало из https://github.com/mozilla/pjs.git
Bug 580408 - Glue for jemalloc 3.0.0. r=khuey
This commit is contained in:
Родитель
80af61ba2b
Коммит
7c2c502a8f
|
@ -48,6 +48,9 @@ endif
|
|||
|
||||
ifdef MOZ_MEMORY
|
||||
tier_base_dirs += memory/mozjemalloc
|
||||
ifdef MOZ_JEMALLOC
|
||||
tier_base_dirs += memory/jemalloc
|
||||
endif
|
||||
tier_base_dirs += memory/build
|
||||
endif
|
||||
tier_base_dirs += \
|
||||
|
|
|
@ -59,6 +59,11 @@ if [ ! "$LIBXUL_SDK" ]; then
|
|||
mozglue/Makefile
|
||||
mozglue/build/Makefile
|
||||
"
|
||||
if [ "$MOZ_JEMALLOC" ]; then
|
||||
add_makefiles "
|
||||
memory/jemalloc/Makefile
|
||||
"
|
||||
fi
|
||||
if [ "$MOZ_MEMORY" ]; then
|
||||
add_makefiles "
|
||||
memory/mozjemalloc/Makefile
|
||||
|
|
|
@ -80,6 +80,7 @@ MOZ_EXTENSIONS = @MOZ_EXTENSIONS@
|
|||
MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
|
||||
MOZ_IPDL_TESTS = @MOZ_IPDL_TESTS@
|
||||
MOZ_MEMORY = @MOZ_MEMORY@
|
||||
MOZ_JEMALLOC = @MOZ_JEMALLOC@
|
||||
MOZ_PROFILING = @MOZ_PROFILING@
|
||||
MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PROFILER_SPS@
|
||||
MOZ_JPROF = @MOZ_JPROF@
|
||||
|
|
42
configure.in
42
configure.in
|
@ -3966,6 +3966,7 @@ AC_CACHE_CHECK(for __thread keyword for TLS variables,
|
|||
ac_cv_thread_keyword=no)])
|
||||
LDFLAGS=$_SAVE_LDFLAGS
|
||||
# The custom dynamic linker doesn't support TLS variables
|
||||
MOZ_TLS=
|
||||
if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
|
||||
# mips builds fail with TLS variables because of a binutils bug.
|
||||
# See bug 528687
|
||||
|
@ -3978,6 +3979,7 @@ if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
|
|||
;;
|
||||
*)
|
||||
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
|
||||
MOZ_TLS=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
@ -7277,6 +7279,9 @@ else
|
|||
fi
|
||||
|
||||
AC_DEFINE(MOZ_MEMORY)
|
||||
if test -n "$MOZ_JEMALLOC"; then
|
||||
AC_DEFINE(MOZ_JEMALLOC)
|
||||
fi
|
||||
if test "x$MOZ_DEBUG" = "x1"; then
|
||||
AC_DEFINE(MOZ_MEMORY_DEBUG)
|
||||
fi
|
||||
|
@ -7332,6 +7337,7 @@ else
|
|||
esac
|
||||
fi # MOZ_MEMORY
|
||||
AC_SUBST(MOZ_MEMORY)
|
||||
AC_SUBST(MOZ_JEMALLOC)
|
||||
AC_SUBST(MOZ_GLUE_LDFLAGS)
|
||||
AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
|
||||
AC_SUBST(WIN32_CRT_LIBS)
|
||||
|
@ -9121,6 +9127,42 @@ if test "$CAIRO_FEATURES_H"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Run jemalloc configure script
|
||||
|
||||
if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
|
||||
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
|
||||
if test "$OS_ARCH" = "Linux"; then
|
||||
MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
|
||||
MANGLED=
|
||||
JEMALLOC_WRAPPER=
|
||||
if test -n "$_WRAP_MALLOC"; then
|
||||
JEMALLOC_WRAPPER=__wrap_
|
||||
fi
|
||||
for mangle in ${MANGLE}; do
|
||||
if test -n "$MANGLED"; then
|
||||
MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
|
||||
else
|
||||
MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
|
||||
fi
|
||||
done
|
||||
ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
|
||||
fi
|
||||
unset CONFIG_FILES
|
||||
if test -z "$MOZ_TLS"; then
|
||||
ac_configure_args="$ac_configure_args --disable-tls"
|
||||
fi
|
||||
EXTRA_CFLAGS="$CFLAGS"
|
||||
for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
|
||||
ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
|
||||
done
|
||||
ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
|
||||
_save_cache_file="$cache_file"
|
||||
cache_file=$_objdir/memory/jemalloc/src/config.cache
|
||||
AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
|
||||
cache_file="$_save_cache_file"
|
||||
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
|
||||
fi
|
||||
|
||||
dnl Build libunwind for Android profiling builds
|
||||
if test "$OS_TARGET" = "Android" -a "$MOZ_PROFILING"; then
|
||||
old_ac_configure_arg="$ac_configure_args"
|
||||
|
|
|
@ -20,6 +20,11 @@ endif
|
|||
|
||||
CSRCS = extraMallocFuncs.c
|
||||
|
||||
ifdef MOZ_JEMALLOC
|
||||
CSRCS += mozjemalloc_compat.c
|
||||
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/jemalloc)
|
||||
else
|
||||
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -90,3 +90,21 @@ wrap(wcsdup)(const wchar_t *src)
|
|||
#endif /* XP_WIN */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_JEMALLOC
|
||||
/* Override some jemalloc defaults */
|
||||
const char *je_malloc_conf = "narenas:1,lg_chunk:20";
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
|
||||
static void
|
||||
_je_malloc_message(void *cbopaque, const char *s)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "GeckoJemalloc", "%s", s);
|
||||
}
|
||||
|
||||
void (*je_malloc_message)(void *, const char *s) = _je_malloc_message;
|
||||
#endif
|
||||
|
||||
#endif /* MOZ_JEMALLOC */
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Types.h"
|
||||
#include "jemalloc_types.h"
|
||||
|
||||
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
|
||||
|
||||
MOZ_EXPORT_API (void)
|
||||
jemalloc_stats(jemalloc_stats_t *stats)
|
||||
{
|
||||
size_t size = sizeof(stats->mapped);
|
||||
je_mallctl("stats.mapped", &stats->mapped, &size, NULL, 0);
|
||||
je_mallctl("stats.allocated", &stats->allocated, &size, NULL, 0);
|
||||
stats->committed = -1;
|
||||
stats->dirty = -1;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
VPATH = $(srcdir) $(srcdir)/src/src
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = jemalloc
|
||||
LIBRARY_NAME = jemalloc
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
ifdef MOZ_GLUE_PROGRAM_LDFLAGS
|
||||
SDK_LIBRARY = $(REAL_LIBRARY)
|
||||
DIST_INSTALL = 1
|
||||
endif
|
||||
|
||||
CSRCS := $(notdir $(wildcard $(srcdir)/src/src/*.c))
|
||||
ifneq ($(OS_TARGET),Darwin)
|
||||
CSRCS := $(filter-out zone.c,$(CSRCS))
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/src/include \
|
||||
-Isrc/include \
|
||||
$(NULL)
|
||||
|
||||
ifdef _MSC_VER
|
||||
LOCAL_INCLUDES += -I$(srcdir)/src/include/msvc_compat
|
||||
|
||||
DEFINES += -DDLLEXPORT
|
||||
endif
|
||||
|
||||
ifeq ($(OS_TARGET),Linux)
|
||||
# For mremap
|
||||
DEFINES += -D_GNU_SOURCE
|
||||
endif
|
||||
|
||||
ifdef GNU_CC
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
|
@ -12,12 +12,15 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = jemalloc
|
||||
|
||||
EXPORTS = jemalloc.h jemalloc_types.h
|
||||
|
||||
ifndef MOZ_JEMALLOC
|
||||
# jemalloc.c properly uses 'static', so don't burden it with manually exposing
|
||||
# symbols.
|
||||
VISIBILITY_FLAGS=
|
||||
|
||||
CSRCS = jemalloc.c
|
||||
EXPORTS = jemalloc.h jemalloc_types.h
|
||||
|
||||
LIBRARY_NAME = jemalloc
|
||||
FORCE_STATIC_LIB= 1
|
||||
|
||||
|
@ -32,5 +35,6 @@ ifeq (Linux,$(OS_TARGET))
|
|||
# See bug 419470
|
||||
NO_PROFILE_GUIDED_OPTIMIZE = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -51,12 +51,25 @@ void jemalloc_stats(jemalloc_stats_t *stats);
|
|||
#if defined(MOZ_MEMORY_LINUX)
|
||||
__attribute__((weak))
|
||||
#endif
|
||||
#if defined(MOZ_JEMALLOC)
|
||||
int je_nallocm(size_t *rsize, size_t size, int flags);
|
||||
#else
|
||||
size_t je_malloc_good_size(size_t size);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline size_t je_malloc_usable_size_in_advance(size_t size) {
|
||||
#if defined(MOZ_MEMORY_DARWIN)
|
||||
return malloc_good_size(size);
|
||||
#elif defined(MOZ_JEMALLOC)
|
||||
if (je_nallocm) {
|
||||
size_t ret;
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
if (!je_nallocm(&ret, size, 0))
|
||||
return ret;
|
||||
}
|
||||
return size;
|
||||
#else
|
||||
if (je_malloc_good_size)
|
||||
return je_malloc_good_size(size);
|
||||
|
@ -90,7 +103,7 @@ static inline size_t je_malloc_usable_size_in_advance(size_t size) {
|
|||
*
|
||||
* If MALLOC_DOUBLE_PURGE is not defined, this function does nothing.
|
||||
*/
|
||||
#if defined(MOZ_MEMORY_LINUX)
|
||||
#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_JEMALLOC)
|
||||
static inline void jemalloc_purge_freed_pages() { }
|
||||
#else
|
||||
void jemalloc_purge_freed_pages();
|
||||
|
|
|
@ -52,8 +52,6 @@ mozglue.def: mozglue.def.in
|
|||
|
||||
GARBAGE += mozglue.def
|
||||
|
||||
LDFLAGS += -ENTRY:DllMain
|
||||
|
||||
ifneq (,$(filter -DEFAULTLIB:mozcrt,$(MOZ_GLUE_LDFLAGS)))
|
||||
# Don't install the import library if we use mozcrt
|
||||
NO_INSTALL_IMPORT_LIBRARY = 1
|
||||
|
|
|
@ -8,11 +8,9 @@ EXPORTS
|
|||
#ifdef MOZ_MEMORY
|
||||
; symbols that are actually useful
|
||||
malloc=je_malloc
|
||||
valloc=je_valloc
|
||||
calloc=je_calloc
|
||||
realloc=je_realloc
|
||||
free=je_free
|
||||
memalign=je_memalign
|
||||
posix_memalign=je_posix_memalign
|
||||
strndup=je_strndup
|
||||
strdup=je_strdup
|
||||
|
@ -20,7 +18,11 @@ EXPORTS
|
|||
wcsdup=je_wcsdup
|
||||
_wcsdup=je_wcsdup
|
||||
malloc_usable_size=je_malloc_usable_size
|
||||
#ifdef MOZ_JEMALLOC
|
||||
je_nallocm
|
||||
#else
|
||||
je_malloc_good_size
|
||||
#endif
|
||||
jemalloc_stats
|
||||
; A hack to work around the CRT (see giant comment in Makefile.in)
|
||||
frex=je_dumb_free_thunk
|
||||
|
|
Загрузка…
Ссылка в новой задаче