Skip to content

Commit

Permalink
Bug 1134039: Make SpiderMonkey standalone (JS_STANDALONE) builds use …
Browse files Browse the repository at this point in the history
…jemalloc and mozglue by default. r=glandium

JS_STANDALONE builds don't need everything in mozglue; have mozglue omit the
unneeded code for such builds.

Since the SpiderMonkey binaries are now more like the other Gecko binaries, we
can remove some special cases for JS_STANDALONE in GeckoSharedLibrary,
GeckoProgram, etc. All Gecko binaries now use mozglue, which contains mfbt, so
we no longer need mention mfbt explicitly.

Add a property to the getBuildConfiguration testing function's result that
indicates whether we're using jemalloc or not.

Include the newly necessary source directories in the SpiderMonkey source
package.
  • Loading branch information
Jim Blandy committed Mar 19, 2015
1 parent c83f877 commit 2dc48be
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 88 deletions.
4 changes: 1 addition & 3 deletions build/gecko_templates.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def GeckoBinary(linkage='dependent', msvcrt='dynamic', mozglue=None):
error('`linkage` must be "dependent", "standalone" or None')

if mozglue:
if CONFIG['JS_STANDALONE']:
pass
elif CONFIG['MOZ_CRT']:
if CONFIG['MOZ_CRT']:
if msvcrt == 'dynamic':
USE_LIBS += ['mozcrt']
elif msvcrt == 'static':
Expand Down
3 changes: 0 additions & 3 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -9219,9 +9219,6 @@ ac_configure_args="$ac_configure_args --prefix=$dist"
if test "$MOZ_MEMORY"; then
ac_configure_args="$ac_configure_args --enable-jemalloc"
fi
if test -n "$MOZ_GLUE_IN_PROGRAM"; then
export MOZ_GLUE_IN_PROGRAM
fi
if test -n "$ZLIB_IN_MOZGLUE"; then
MOZ_ZLIB_LIBS=
fi
Expand Down
8 changes: 8 additions & 0 deletions js/src/builtin/TestingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ GetBuildConfiguration(JSContext *cx, unsigned argc, jsval *vp)
if (!JS_SetProperty(cx, info, "mapped-array-buffer", value))
return false;

#ifdef MOZ_MEMORY
value = BooleanValue(true);
#else
value = BooleanValue(false);
#endif
if (!JS_SetProperty(cx, info, "moz-memory", value))
return false;

args.rval().setObject(*info);
return true;
}
Expand Down
16 changes: 13 additions & 3 deletions js/src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2993,11 +2993,21 @@ fi
dnl ========================================================
dnl = Enable jemalloc
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(jemalloc,
[ --enable-jemalloc Replace memory allocator with jemalloc],
MOZ_MEMORY=1,
MOZ_MEMORY=1
MOZ_ARG_DISABLE_BOOL(jemalloc,
[ --disable-jemalloc Don't replace memory allocator with jemalloc],
MOZ_MEMORY=)

case "${OS_TARGET}" in
Android|WINNT|Darwin)
MOZ_GLUE_IN_PROGRAM=
;;
*)
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
MOZ_GLUE_IN_PROGRAM=1
;;
esac

if test "$MOZ_MEMORY"; then
AC_DEFINE(MOZ_MEMORY)
if test "x$MOZ_DEBUG" = "x1"; then
Expand Down
49 changes: 31 additions & 18 deletions js/src/make-source-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pkgpath=${pkg%.tar*}
tgtpath=${DIST}/${pkgpath}
taropts="-jcf"

TOPSRCDIR=${SRCDIR}/../..

case $cmd in
"clean")
echo "Cleaning ${pkg} and ${tgtpath} ..."
Expand All @@ -43,21 +45,21 @@ case $cmd in

# copy the embedded icu
${MKDIR} -p ${tgtpath}/intl
cp -t ${tgtpath}/intl -dRp ${SRCDIR}/../../intl/icu
cp -t ${tgtpath}/intl -dRp ${TOPSRCDIR}/intl/icu

# copy main moz.build and Makefile.in
cp -t ${tgtpath} -dRp ${SRCDIR}/../../Makefile.in ${SRCDIR}/../../moz.build
cp -t ${tgtpath} -dRp ${TOPSRCDIR}/Makefile.in ${TOPSRCDIR}/moz.build

# copy a nspr file used by the build system
${MKDIR} -p ${tgtpath}/nsprpub/config
cp -t ${tgtpath}/nsprpub/config -dRp \
${SRCDIR}/../../nsprpub/config/make-system-wrappers.pl
${TOPSRCDIR}/nsprpub/config/make-system-wrappers.pl

# copy build and config directory.
cp -t ${tgtpath} -dRp ${SRCDIR}/../../build ${SRCDIR}/../../config
cp -t ${tgtpath} -dRp ${TOPSRCDIR}/build ${TOPSRCDIR}/config

# put in js itself
cp -t ${tgtpath} -dRp ${SRCDIR}/../../mfbt
cp -t ${tgtpath} -dRp ${TOPSRCDIR}/mfbt
cp -t ${tgtpath}/js -dRp ${SRCDIR}/../public
find ${SRCDIR} -mindepth 1 -maxdepth 1 -not -path ${DIST} -a -not -name ${pkg} \
-exec cp -t ${tgtpath}/js/src -dRp {} +
Expand All @@ -68,26 +70,37 @@ case $cmd in
fi

cp -t ${tgtpath} -dRp \
${SRCDIR}/../../python
${TOPSRCDIR}/python
${MKDIR} -p ${tgtpath}/dom/bindings
cp -t ${tgtpath}/dom/bindings -dRp \
${SRCDIR}/../../dom/bindings/mozwebidlcodegen
${TOPSRCDIR}/dom/bindings/mozwebidlcodegen
${MKDIR} -p ${tgtpath}/media/webrtc/trunk/tools
cp -t ${tgtpath}/media/webrtc/trunk/tools -dRp \
${SRCDIR}/../../media/webrtc/trunk/tools/gyp
${TOPSRCDIR}/media/webrtc/trunk/tools/gyp
${MKDIR} -p ${tgtpath}/testing
cp -t ${tgtpath}/testing -dRp \
${SRCDIR}/../../testing/mozbase
${TOPSRCDIR}/testing/mozbase
${MKDIR} -p ${tgtpath}/modules/zlib
cp -t ${tgtpath}/modules/zlib -dRp \
${SRCDIR}/../../modules/zlib/src
${TOPSRCDIR}/modules/zlib/src
${MKDIR} -p ${tgtpath}/layout/tools/reftest
cp -t ${tgtpath}/layout/tools/reftest -dRp \
${SRCDIR}/../../layout/tools/reftest/reftest
${TOPSRCDIR}/layout/tools/reftest/reftest
${MKDIR} -p ${tgtpath}/toolkit/mozapps/installer
cp -t ${tgtpath}/toolkit/mozapps/installer -dRp \
${SRCDIR}/../../toolkit/mozapps/installer/package-name.mk \
${SRCDIR}/../../toolkit/mozapps/installer/upload-files.mk \
${TOPSRCDIR}/toolkit/mozapps/installer/package-name.mk \
${TOPSRCDIR}/toolkit/mozapps/installer/upload-files.mk
${MKDIR} -p ${tgtpath}/mozglue
cp -t ${tgtpath}/mozglue -dRp \
${TOPSRCDIR}/mozglue/build \
${TOPSRCDIR}/mozglue/crt \
${TOPSRCDIR}/mozglue/moz.build
${MKDIR} -p ${tgtpath}/memory
cp -t ${tgtpath}/memory -dRp \
${TOPSRCDIR}/memory/moz.build \
${TOPSRCDIR}/memory/build \
${TOPSRCDIR}/memory/jemalloc \
${TOPSRCDIR}/memory/mozjemalloc

# remove *.pyc and *.pyo files if any
find ${tgtpath} -type f -name "*.pyc" -o -name "*.pyo" |xargs rm -f
Expand Down Expand Up @@ -128,17 +141,17 @@ README_EOF
fi

# copy LICENSE
if [ -e ${SRCDIR}/../../b2g/LICENSE ]; then
cp ${SRCDIR}/../../b2g/LICENSE ${tgtpath}/
if [ -e ${TOPSRCDIR}/b2g/LICENSE ]; then
cp ${TOPSRCDIR}/b2g/LICENSE ${tgtpath}/
else
cp ${SRCDIR}/../../LICENSE ${tgtpath}/
cp ${TOPSRCDIR}/LICENSE ${tgtpath}/
fi

# copy patches dir, if it currently exists in DIST
if [ -d ${DIST}/patches ]; then
cp -t ${tgtpath} -dRp ${DIST}/patches
elif [ -d ${SRCDIR}/../../patches ]; then
cp -t ${tgtpath} -dRp ${SRCDIR}/../../patches
elif [ -d ${TOPSRCDIR}/patches ]; then
cp -t ${tgtpath} -dRp ${TOPSRCDIR}/patches
fi

# Roll the tarball
Expand Down
7 changes: 1 addition & 6 deletions js/src/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ CONFIGURE_SUBST_FILES += [
'js.pc',
]

if CONFIG['JS_STANDALONE']:
DEFINES['IMPL_MFBT'] = True
USE_LIBS += [
'mfbt',
]
else:
if not CONFIG['JS_STANDALONE']:
CONFIGURE_SUBST_FILES += [
'../../config/autoconf-js.mk',
'../../config/emptyvars-js.mk',
Expand Down
8 changes: 4 additions & 4 deletions moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ if not CONFIG['JS_STANDALONE']:

if not CONFIG['LIBXUL_SDK']:
DIRS += [
'mozglue',
'mfbt',
'config/external/zlib',
]

if CONFIG['MOZ_MEMORY']:
DIRS += ['memory']

if not CONFIG['JS_STANDALONE']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['other-licenses/android']

if CONFIG['MOZ_MEMORY']:
DIRS += ['memory']

DIRS += [
'mozglue',
'memory/fallible',
'memory/mozalloc',
'memory/volatile',
Expand Down
103 changes: 53 additions & 50 deletions mozglue/build/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,75 +13,78 @@ else:

SDK_LIBRARY = True

if CONFIG['MOZ_MEMORY'] and (CONFIG['MOZ_NATIVE_JEMALLOC'] or FORCE_SHARED_LIB):
pass
# TODO: SHARED_LIBRARY_LIBS go here
else:
# Temporary, until bug 662814 lands
NO_VISIBILITY_FLAGS = True
SOURCES += [
'dummy.cpp',
]

if CONFIG['OS_TARGET'] == 'Android':
SOURCES += [
'BionicGlue.cpp',
]

if CONFIG['OS_TARGET'] == 'WINNT':
if CONFIG['MOZ_ASAN']:
SOURCES += [
'WindowsDllBlocklist.cpp',
'AsanOptions.cpp',
]

if CONFIG['OS_TARGET'] == 'WINNT':
DEFFILE = 'mozglue.def'
DISABLE_STL_WRAPPING = True
OS_LIBS += [
'version',
]

if CONFIG['MOZ_NUWA_PROCESS']:
EXPORTS.ipc += [
'Nuwa.h',
]
SOURCES += [
'Nuwa.cpp',
if not CONFIG['JS_STANDALONE']:

if CONFIG['MOZ_MEMORY'] and (CONFIG['MOZ_NATIVE_JEMALLOC'] or FORCE_SHARED_LIB):
pass
# TODO: SHARED_LIBRARY_LIBS go here
else:
# Temporary, until bug 662814 lands
NO_VISIBILITY_FLAGS = True
SOURCES += [
'dummy.cpp',
]

if CONFIG['OS_TARGET'] == 'WINNT':
SOURCES += [
'WindowsDllBlocklist.cpp',
]
DISABLE_STL_WRAPPING = True
OS_LIBS += [
'version',
]

if CONFIG['MOZ_NUWA_PROCESS']:
EXPORTS.ipc += [
'Nuwa.h',
]
SOURCES += [
'Nuwa.cpp',
]

EXPORTS.mozilla += [
'arm.h',
'SSE.h',
'WindowsDllBlocklist.h',
]

EXPORTS.mozilla += [
'arm.h',
'SSE.h',
'WindowsDllBlocklist.h',
]
if CONFIG['CPU_ARCH'].startswith('x86'):
SOURCES += [
'SSE.cpp',
]

if CONFIG['CPU_ARCH'].startswith('x86'):
SOURCES += [
'SSE.cpp',
]
if CONFIG['CPU_ARCH'] == 'arm':
SOURCES += [
'arm.cpp',
]

if CONFIG['CPU_ARCH'] == 'arm':
SOURCES += [
'arm.cpp',
]

if CONFIG['MOZ_ASAN']:
SOURCES += [
'AsanOptions.cpp',
]
if CONFIG['MOZ_LINKER']:
USE_LIBS += [
'zlib',
]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
SOURCES += [
'cpuacct.c',
]

USE_LIBS += [
'mfbt',
]

if CONFIG['MOZ_LINKER']:
USE_LIBS += [
'zlib',
]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
SOURCES += [
'cpuacct.c',
]

DEFINES['IMPL_MFBT'] = True

LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
Expand Down
3 changes: 2 additions & 1 deletion mozglue/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ DIRS += ['build']
if CONFIG['MOZ_CRT']:
DIRS += ['crt']

TEST_DIRS += ['tests']
if not CONFIG['JS_STANDALONE']:
TEST_DIRS += ['tests']

0 comments on commit 2dc48be

Please sign in to comment.