Bug 1744524: part 2) Add `WindowContext::GetUserGestureStart` and remove `WindowConte...
[gecko.git] / build / moz.configure / memory.configure
blob3a321bfb9560662be45f1f96a69adfad5ed87b4f
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):
10     if js_package:
11         return False
12     return target.kernel in ("Darwin", "Linux", "WINNT")
15 option(
16     "--enable-jemalloc",
17     env="MOZ_MEMORY",
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":
31         return True
32     if milestone.is_early_beta_or_earlier and build_project != "js":
33         return True
36 option(
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":
53         return True
56 set_config("MOZ_REPLACE_MALLOC_STATIC", replace_malloc_static)
58 # PHC (Probabilistic Heap Checker)
59 # ==============================================================
61 # In general, it only makes sense for PHC to run on the platforms that have a
62 # crash reporter.
63 @depends(
64     milestone,
65     target,
66     replace_malloc_default,
67     "--enable-replace-malloc",
68     when="--enable-jemalloc",
70 def phc_default(milestone, target, replace_malloc_default, replace_malloc):
71     if not replace_malloc_default or (
72         replace_malloc.origin != "default" and not replace_malloc
73     ):
74         return False
75     # Nightly or early beta only because PHC has a non-negligible performance cost.
76     if not milestone.is_early_beta_or_earlier:
77         return False
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.
80     return (
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")
84     )
87 option(
88     "--enable-phc",
89     env="MOZ_PHC",
90     default=phc_default,
91     when="--enable-jemalloc",
92     help="{Enable|Disable} PHC (Probabilistic Memory Checker). "
93     "Also enables replace-malloc and frame pointers",
95 imply_option("--enable-replace-malloc", True, when="--enable-phc")
96 imply_option("--enable-frame-pointers", True, when="--enable-phc")
99 set_config("MOZ_PHC", True, when="--enable-phc")
101 with only_when(depends(target.os)(lambda os: os != "WINNT")):
102     set_define("HAVE_STRNDUP", check_symbol("strndup"))
103     set_define("HAVE_POSIX_MEMALIGN", check_symbol("posix_memalign"))
104     set_define("HAVE_MEMALIGN", check_symbol("memalign"))
105     set_define("HAVE_MALLOC_USABLE_SIZE", check_symbol("malloc_usable_size"))