diff --git a/config/check_vanilla_allocations.py b/config/check_vanilla_allocations.py index 2a3be879ec89..8c8efd545fdf 100644 --- a/config/check_vanilla_allocations.py +++ b/config/check_vanilla_allocations.py @@ -128,6 +128,12 @@ def main(): continue filename = m.group(1) + + # mozalloc contains calls to memalign. These are ok, so we whitelist + # them. + if "mozalloc" in filename: + continue + fn = m.group(2) if filename == 'jsutil.o': jsutil_cpp.add(fn) @@ -188,4 +194,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/js/moz.configure b/js/moz.configure index 4a8baf4d3342..5505fd1b7d42 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -22,12 +22,11 @@ option(env='JS_STANDALONE', default=building_js, def js_standalone(value): if value: return True - set_config('JS_STANDALONE', js_standalone) +set_define('JS_STANDALONE', js_standalone) add_old_configure_assignment('JS_STANDALONE', js_standalone) - js_option('--disable-js-shell', default=building_js, - help='Do not build the JS shell') + help='Do not build the JS shell') @depends('--disable-js-shell') def js_disable_shell(value): diff --git a/js/src/build.rs b/js/src/build.rs index bf23fc0461a7..97b57588265f 100644 --- a/js/src/build.rs +++ b/js/src/build.rs @@ -25,7 +25,12 @@ fn main() { let python = env::var("PYTHON").unwrap_or("python2.7".into()); let mut cmd = Command::new(&python); cmd.args(&["./devtools/automation/autospider.py", + // Only build SpiderMonkey, don't run all the tests. "--build-only", + // Disable Mozilla's jemalloc; Rust has its own jemalloc that we + // can swap in instead and everything using a single malloc is + // good. + "--no-jemalloc", "--objdir", &out_dir, variant]) .env("SOURCE", &js_src) diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py index b5c3695d8ca3..f417f55f037c 100755 --- a/js/src/devtools/automation/autospider.py +++ b/js/src/devtools/automation/autospider.py @@ -61,6 +61,14 @@ group.add_argument('--no-debug', action='store_false', dest='debug', help='generate a non-debug build. Overrides variant setting.') group.set_defaults(debug=None) +group = parser.add_mutually_exclusive_group() +group.add_argument('--jemalloc', action='store_true', + dest='jemalloc', + help='use mozilla\'s jemalloc instead of the default allocator') +group.add_argument('--no-jemalloc', action='store_false', + dest='jemalloc', + help='use the default allocator instead of mozilla\'s jemalloc') +group.set_defaults(jemalloc=None) parser.add_argument('--run-tests', '--tests', type=str, metavar='TESTSUITE', default='', help="comma-separated set of test suites to add to the variant's default set") @@ -176,6 +184,10 @@ if opt is None: if opt is not None: CONFIGURE_ARGS += (" --enable-debug" if opt else " --disable-debug") +opt = args.jemalloc +if opt is not None: + CONFIGURE_ARGS += (" --enable-jemalloc" if opt else " --disable-jemalloc") + # Any jobs that wish to produce additional output can save them into the upload # directory if there is such a thing, falling back to OBJDIR. env.setdefault('MOZ_UPLOAD_DIR', OBJDIR) diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 2aef42ccfa27..b270a8c2409d 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -1495,16 +1495,20 @@ dnl ======================================================== dnl = Enable jemalloc dnl ======================================================== -case "${OS_TARGET}" in -Android|WINNT|Darwin) +if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then MOZ_GLUE_IN_PROGRAM= - ;; -*) - 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 +else + 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 + AC_DEFINE(MOZ_GLUE_IN_PROGRAM) + ;; + esac +fi if test "$MOZ_MEMORY"; then dnl The generic feature tests that determine how to compute ncpus are long and diff --git a/mfbt/Types.h b/mfbt/Types.h index e7e18abb2746..30f4ea3d1f7c 100644 --- a/mfbt/Types.h +++ b/mfbt/Types.h @@ -78,23 +78,28 @@ * export mfbt declarations when building mfbt, and they expose import mfbt * declarations when using mfbt. */ -#if defined(IMPL_MFBT) +#if defined(IMPL_MFBT) || (defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && (defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API))) # define MFBT_API MOZ_EXPORT # define MFBT_DATA MOZ_EXPORT #else - /* - * On linux mozglue is linked in the program and we link libxul.so with - * -z,defs. Normally that causes the linker to reject undefined references in - * libxul.so, but as a loophole it allows undefined references to weak - * symbols. We add the weak attribute to the import version of the MFBT API - * macros to exploit this. - */ -# if defined(MOZ_GLUE_IN_PROGRAM) -# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API -# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA +# if defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && defined(STATIC_JS_API) +# define MFBT_API +# define MFBT_DATA # else -# define MFBT_API MOZ_IMPORT_API -# define MFBT_DATA MOZ_IMPORT_DATA + /* + * On linux mozglue is linked in the program and we link libxul.so with + * -z,defs. Normally that causes the linker to reject undefined references in + * libxul.so, but as a loophole it allows undefined references to weak + * symbols. We add the weak attribute to the import version of the MFBT API + * macros to exploit this. + */ +# if defined(MOZ_GLUE_IN_PROGRAM) +# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API +# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA +# else +# define MFBT_API MOZ_IMPORT_API +# define MFBT_DATA MOZ_IMPORT_DATA +# endif # endif #endif