Skip to content

Commit

Permalink
bug 407459. hooking jemalloc up to the build system. r=various people
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartparmenter committed Feb 5, 2008
1 parent 6b75c9c commit 4b7d23a
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ tier_base_dirs = \
probes \
$(NULL)

ifdef MOZ_MEMORY
tier_base_dirs += memory/jemalloc
endif

include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk

TIERS += testharness
Expand Down
6 changes: 6 additions & 0 deletions allmakefiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ probes/Makefile
extensions/Makefile
"

if [ "$MOZ_MEMORY" ]; then
add_makefiles "
memory/jemalloc/Makefile
"
fi

#
# Application-specific makefiles
#
Expand Down
6 changes: 6 additions & 0 deletions browser/app/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ GRE_BUILDID = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBX

DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) -DGRE_BUILDID=$(GRE_BUILDID)

ifdef MOZ_MEMORY
ifneq ($(OS_ARCH),WINNT)
LIBS += -ljemalloc
endif
endif

ifdef LIBXUL_SDK
include $(topsrcdir)/config/rules.mk
else
Expand Down
1 change: 1 addition & 0 deletions browser/installer/unix/packages-static
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ bin/res/effective_tld_names.dat
bin/xpicleanup
bin/libsqlite3.so
bin/README.txt
bin/libjemalloc.so

; [Components]
bin/components/alerts.xpt
Expand Down
1 change: 1 addition & 0 deletions browser/installer/windows/packages-static
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bin\Microsoft.VC80.CRT.manifest
bin\msvcm80.dll
bin\msvcp80.dll
bin\msvcr80.dll
bin\mozcrt19.dll

[browser]
; [Base Browser Files]
Expand Down
9 changes: 8 additions & 1 deletion config/autoconf.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ MOZ_IMG_ENCODERS= @MOZ_IMG_ENCODERS@
MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
MOZ_PERF_METRICS = @MOZ_PERF_METRICS@
MOZ_LEAKY = @MOZ_LEAKY@
MOZ_MEMORY = @MOZ_MEMORY@
MOZ_JPROF = @MOZ_JPROF@
MOZ_SHARK = @MOZ_SHARK@
MOZ_XPCTOOLS = @MOZ_XPCTOOLS@
Expand Down Expand Up @@ -553,7 +554,13 @@ MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
MOZ_QUANTIFY = @MOZ_QUANTIFY@
MSMANIFEST_TOOL = @MSMANIFEST_TOOL@
WIN32_REDIST_DIR = @WIN32_REDIST_DIR@

WIN32_CRT_SRC_DIR = @WIN32_CRT_SRC_DIR@
WIN32_CUSTOM_CRT_DIR = @WIN32_CUSTOM_CRT_DIR@
# These are for custom CRT building
ifneq (,$(WIN32_CRT_SRC_DIR)$(WIN32_CUSTOM_CRT_DIR))
export LIB = @MOZ_LIB@
export PATH = @MOZ_PATH@
endif
# python options.
MOZ_PYTHON_EXTENSIONS = @MOZ_PYTHON_EXTENSIONS@
MOZ_PYTHON = @MOZ_PYTHON@
Expand Down
97 changes: 97 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -5992,6 +5992,103 @@ elif test -z "$_ENABLE_LOGREFCNT"; then
AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
fi

dnl ========================================================
dnl = memory
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(jemalloc,
[ --enable-jemalloc Replace memory allocator with jemalloc],
MOZ_MEMORY=1,
MOZ_MEMORY=)
if test "$MOZ_MEMORY"; then

dnl Don't try to run compiler tests on Windows
if test "$OS_ARCH" = "WINNT"; then
if test -z "$HAVE_64BIT_OS"; then
AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
else
AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
fi
else
AC_CHECK_SIZEOF([int *], [4])
case "${ac_cv_sizeof_int_p}" in
4)
AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
;;
8)
AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
;;
*)
AC_MSG_ERROR([Unexpected pointer size])
;;
esac
fi

AC_DEFINE(MOZ_MEMORY)
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_os}" in
darwin*)
AC_DEFINE(MOZ_MEMORY_DARWIN)
;;
*-freebsd*)
AC_DEFINE(MOZ_MEMORY_BSD)
;;
*linux*)
AC_DEFINE(MOZ_MEMORY_LINUX)
;;
netbsd*)
AC_DEFINE(MOZ_MEMORY_BSD)
;;
solaris*)
AC_DEFINE(MOZ_MEMORY_SOLARIS)
;;
msvc*|mks*|cygwin*|mingw*)
AC_DEFINE(MOZ_MEMORY_WINDOWS)
dnl XXX: should test for vc8sp1 here, otherwise patching the crt src
dnl will fail miserably
if test "$_CC_SUITE" -lt "8"; then
AC_MSG_ERROR([Building jemalloc requires Visual C++ 2005 or better])
fi
if test -z "$WIN32_CRT_SRC_DIR" -a -z "$WIN32_CUSTOM_CRT_DIR"; then
if test -z "$VCINSTALLDIR" -o ! -d "$VCINSTALLDIR"; then
AC_MSG_ERROR([When building jemalloc, either set WIN32_CRT_SRC_DIR to the path to the Visual C++ CRT source (usually VCINSTALLDIR\crt\src), or set WIN32_CUSTOM_CRT_DIR to the path to a folder containing a pre-built CRT DLL.])
else
WIN32_CRT_SRC_DIR="$VCINSTALLDIR\crt\src"
fi
fi
if test -z "$WIN32_CRT_SRC_DIR"; then
# pre-built dll
WIN32_CUSTOM_CRT_DIR=`cd "$WIN32_CUSTOM_CRT_DIR" && pwd`
_WIN_UNIX_CRT_PATH="$WIN32_CUSTOM_CRT_DIR"
else
# CRT source directory
WIN32_CRT_SRC_DIR=`cd "$WIN32_CRT_SRC_DIR" && pwd`
_CRT_BASE_DIR=`basename "$WIN32_CRT_SRC_DIR"`
_WIN_UNIX_CRT_PATH="$_objdir/memory/jemalloc/$_CRT_BASE_DIR/build/intel"
fi
dnl need win32 paths in LIB, hence this python abuse. extra brackets
dnl are to avoid m4
_WIN_CRT_PATH=[`$PYTHON -c 'import sys, os.path; print os.path.normpath(sys.argv[1])' "$_WIN_UNIX_CRT_PATH"`]
MOZ_LIB="$_WIN_CRT_PATH;$LIB"
dnl Needs to be in PATH too, since our tools will wind up linked against it.
dnl This needs to be unix style.
MOZ_PATH="$PATH:$_WIN_UNIX_CRT_PATH"
;;
*)
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
;;
esac
fi
AC_SUBST(MOZ_MEMORY)
AC_SUBST(WIN32_CRT_SRC_DIR)
AC_SUBST(WIN32_CUSTOM_CRT_DIR)
AC_SUBST(MOZ_LIB)
AC_SUBST(MOZ_PATH)

dnl ========================================================
dnl = Use malloc wrapper lib
dnl ========================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
// _snwprintf when using older CRTs.
#if _MSC_VER < 1400 // MSVC 2005/8
#define swprintf _snwprintf
#else
// For MSVC8 and newer, swprintf_s is the recommended method. Conveniently,
// it takes the same argument list as swprintf.
#define swprintf swprintf_s
#endif // MSC_VER < 1400

namespace google_breakpad {
Expand Down

0 comments on commit 4b7d23a

Please sign in to comment.