1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 @depends(target, js_package)
9 def jemalloc_default(target, js_package):
12 return target.kernel in ("Darwin", "Linux", "WINNT")
18 default=jemalloc_default,
19 help="{Replace|Do not replace} memory allocator with jemalloc",
23 set_config("MOZ_MEMORY", True, when="--enable-jemalloc")
24 set_define("MOZ_MEMORY", True, when="--enable-jemalloc")
25 add_old_configure_assignment("MOZ_MEMORY", True, when="--enable-jemalloc")
28 @depends(milestone, build_project)
29 def replace_malloc_default(milestone, build_project):
30 if build_project == "memory":
32 if milestone.is_early_beta_or_earlier and build_project != "js":
37 "--enable-replace-malloc",
38 default=replace_malloc_default,
39 when="--enable-jemalloc",
40 help="{Enable|Disable} ability to dynamically replace the malloc implementation",
44 set_config("MOZ_REPLACE_MALLOC", True, when="--enable-replace-malloc")
45 set_define("MOZ_REPLACE_MALLOC", True, when="--enable-replace-malloc")
48 @depends(build_project, when="--enable-replace-malloc")
49 def replace_malloc_static(build_project):
50 # Default to statically linking replace-malloc libraries that can be
51 # statically linked, except when building with --enable-project=memory.
52 if build_project != "memory":
56 set_config("MOZ_REPLACE_MALLOC_STATIC", replace_malloc_static)
58 # PHC (Probabilistic Heap Checker)
59 # ==============================================================
62 # In general, it only makes sense for PHC to run on the platforms that have a
68 when="--enable-jemalloc",
70 def phc_default(milestone, build_project, target):
71 # Nightly or early beta only because PHC has a non-negligible performance cost.
72 if not milestone.is_early_beta_or_earlier:
75 if build_project == "js":
78 # Both Linux32 and Win32 have frequent crashes when stack tracing (for
79 # unclear reasons), so PHC is enabled only on 64-bit only in both cases.
81 (target.os == "GNU" and target.kernel == "Linux" and target.bitness == 64)
82 or (target.kernel == "WINNT" and target.bitness == 64)
83 or (target.os == "OSX")
91 when="--enable-jemalloc",
92 help="{Enable|Disable} PHC (Probabilistic Memory Checker). "
93 "Also enables frame pointers",
95 imply_option("--enable-frame-pointers", True, when="--enable-phc")
98 set_config("MOZ_PHC", True, when="--enable-phc")
100 with only_when(depends(target.os)(lambda os: os != "WINNT")):
101 set_define("HAVE_STRNDUP", check_symbol("strndup"))
102 set_define("HAVE_POSIX_MEMALIGN", check_symbol("posix_memalign"))
103 set_define("HAVE_MEMALIGN", check_symbol("memalign"))
104 set_define("HAVE_MALLOC_USABLE_SIZE", check_symbol("malloc_usable_size"))