зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356701 - Export unprefixed malloc and duplication functions on OSX. r=njn
Going through the system zone allocator for every call to realloc/free on OSX is costly, because the zone allocator needs to first verify that the allocations do belong to the allocator it invokes (which ends up calling jemalloc's malloc_usable_size), which is unnecessary when we expect the allocations to belong to jemalloc. So, we export the malloc/realloc/free/etc. symbols from libmozglue.dylib, such that libraries and programs linked against it calls directly into jemalloc instead of going through the system zone allocator, effectively shortcutting the allocator verification. The risk is that some things in Gecko try to realloc/free pointers it got from system libraries, if those were allocated with a system zone that is not jemalloc. --HG-- extra : rebase_source : 45b9b98499760a7f946878d41d2fdaadb6dff4d6
This commit is contained in:
Родитель
974747932d
Коммит
c65bedc1c8
|
@ -68,7 +68,6 @@ mozmem_malloc_impl(_ZdaPvRKSt9nothrow_t)(void *ptr)
|
|||
#undef strndup
|
||||
#undef strdup
|
||||
|
||||
#ifndef XP_DARWIN
|
||||
MOZ_MEMORY_API char *
|
||||
strndup_impl(const char *src, size_t len)
|
||||
{
|
||||
|
@ -86,7 +85,6 @@ strdup_impl(const char *src)
|
|||
size_t len = strlen(src);
|
||||
return strndup_impl(src, len);
|
||||
}
|
||||
#endif /* XP_DARWIN */
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <stdarg.h>
|
||||
|
|
|
@ -53,11 +53,10 @@
|
|||
*
|
||||
* - On MacOSX, the system libc has a zone allocator, which allows us to
|
||||
* hook custom malloc implementation functions without exporting them.
|
||||
* The malloc implementation functions are all prefixed with "je_" and used
|
||||
* this way from the custom zone allocator. They are not exported.
|
||||
* Duplication functions are not included, since they will call the custom
|
||||
* zone allocator anyways. Jemalloc-specific functions are also left
|
||||
* unprefixed.
|
||||
* However, since we want things in Firefox to skip the system zone
|
||||
* allocator, the malloc implementation functions are all exported
|
||||
* unprefixed, as well as duplication functions.
|
||||
* Jemalloc-specific functions are also left unprefixed.
|
||||
*
|
||||
* - On Android and Gonk, all functions are left unprefixed. Additionally,
|
||||
* C++ allocation functions (operator new/delete) are also exported and
|
||||
|
@ -134,7 +133,7 @@
|
|||
# define mozmem_jemalloc_impl(a) je_ ## a
|
||||
# else
|
||||
# define MOZ_JEMALLOC_API MOZ_EXTERN_C MFBT_API
|
||||
# if (defined(XP_WIN) || defined(XP_DARWIN))
|
||||
# if defined(XP_WIN)
|
||||
# if defined(MOZ_REPLACE_MALLOC)
|
||||
# define mozmem_malloc_impl(a) a ## _impl
|
||||
# else
|
||||
|
|
Загрузка…
Ссылка в новой задаче