From eab70d0a074d1e91b2d410d2e9166d91b843093b Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Thu, 14 Sep 2017 20:36:41 -0700 Subject: [PATCH] Backed out changeset 0e349b74bfc6 (bug 1399921) for failure to thrive on Mac MozReview-Commit-ID: HoBhxzIzn2d --- memory/build/mozjemalloc.cpp | 22 +++++++++++++++++++++- memory/build/zone.c | 3 +-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 315c8f02d0e8..ac7ec538cab5 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -4370,7 +4370,7 @@ huge_dalloc(void *ptr) * implementation has to take pains to avoid infinite recursion during * initialization. */ -#if defined(XP_WIN) +#if (defined(XP_WIN) || defined(XP_DARWIN)) #define malloc_init() false #else static inline bool @@ -4384,6 +4384,10 @@ malloc_init(void) } #endif +#if defined(XP_DARWIN) +extern "C" void register_zone(void); +#endif + static size_t GetKernelPageSize() { @@ -4648,6 +4652,10 @@ MALLOC_OUT: pthread_atfork(_malloc_prefork, _malloc_postfork_parent, _malloc_postfork_child); #endif +#if defined(XP_DARWIN) + register_zone(); +#endif + #ifndef XP_WIN malloc_mutex_unlock(&init_lock); #endif @@ -5437,6 +5445,18 @@ replace_malloc_init_funcs() # include #endif +#if defined(XP_DARWIN) + +__attribute__((constructor)) +void +jemalloc_darwin_init(void) +{ + if (malloc_init_hard()) + MOZ_CRASH(); +} + +#endif + #if defined(__GLIBC__) && !defined(__UCLIBC__) /* * glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible diff --git a/memory/build/zone.c b/memory/build/zone.c index ebc990a11758..afe6c232adad 100644 --- a/memory/build/zone.c +++ b/memory/build/zone.c @@ -345,8 +345,7 @@ static malloc_zone_t *get_default_zone() } - __attribute__((constructor)) -static void +void register_zone(void) { malloc_zone_t *default_zone = get_default_zone();