mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1402282 - Clang-format on mozjemalloc r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D10794 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
896a7bbbd2
commit
a1d5bd1909
@ -515,7 +515,8 @@ static const size_t gRecycleLimit = 128_MiB;
|
||||
// The current amount of recycled bytes, updated atomically. Malloc may be
|
||||
// called non-deterministically when recording/replaying, so this atomic's
|
||||
// accesses are not recorded.
|
||||
static Atomic<size_t, ReleaseAcquire, recordreplay::Behavior::DontPreserve> gRecycledSize;
|
||||
static Atomic<size_t, ReleaseAcquire, recordreplay::Behavior::DontPreserve>
|
||||
gRecycledSize;
|
||||
|
||||
// Maximum number of dirty pages per arena.
|
||||
#define DIRTY_MAX_DEFAULT (1U << 8)
|
||||
@ -557,8 +558,10 @@ static bool malloc_initialized;
|
||||
#else
|
||||
// Malloc may be called non-deterministically when recording/replaying, so this
|
||||
// atomic's accesses are not recorded.
|
||||
static Atomic<bool, SequentiallyConsistent,
|
||||
recordreplay::Behavior::DontPreserve> malloc_initialized;
|
||||
static Atomic<bool,
|
||||
SequentiallyConsistent,
|
||||
recordreplay::Behavior::DontPreserve>
|
||||
malloc_initialized;
|
||||
#endif
|
||||
|
||||
static StaticMutex gInitLock = { STATIC_MUTEX_INIT };
|
||||
@ -2275,14 +2278,14 @@ arena_run_reg_alloc(arena_run_t* run, arena_bin_t* bin)
|
||||
static inline void
|
||||
arena_run_reg_dalloc(arena_run_t* run, arena_bin_t* bin, void* ptr, size_t size)
|
||||
{
|
||||
// To divide by a number D that is not a power of two we multiply
|
||||
// by (2^21 / D) and then right shift by 21 positions.
|
||||
//
|
||||
// X / D
|
||||
//
|
||||
// becomes
|
||||
//
|
||||
// (X * size_invs[(D / kQuantum) - 3]) >> SIZE_INV_SHIFT
|
||||
// To divide by a number D that is not a power of two we multiply
|
||||
// by (2^21 / D) and then right shift by 21 positions.
|
||||
//
|
||||
// X / D
|
||||
//
|
||||
// becomes
|
||||
//
|
||||
// (X * size_invs[(D / kQuantum) - 3]) >> SIZE_INV_SHIFT
|
||||
|
||||
#define SIZE_INV_SHIFT 21
|
||||
#define SIZE_INV(s) (((1U << SIZE_INV_SHIFT) / (s * kQuantum)) + 1)
|
||||
@ -4709,7 +4712,10 @@ static malloc_table_t gReplaceMallocTables[2] = {
|
||||
unsigned gReplaceMallocIndex = 0;
|
||||
|
||||
// Avoid races when swapping malloc impls dynamically
|
||||
static Atomic<malloc_table_t const*, mozilla::MemoryOrdering::Relaxed, recordreplay::Behavior::DontPreserve> gReplaceMallocTable;
|
||||
static Atomic<malloc_table_t const*,
|
||||
mozilla::MemoryOrdering::Relaxed,
|
||||
recordreplay::Behavior::DontPreserve>
|
||||
gReplaceMallocTable;
|
||||
|
||||
#ifdef MOZ_DYNAMIC_REPLACE_INIT
|
||||
#undef replace_init
|
||||
@ -4848,15 +4854,15 @@ jemalloc_replace_dynamic(jemalloc_init_func replace_init_func)
|
||||
gReplaceMallocTable = &gReplaceMallocTableDefault;
|
||||
}
|
||||
|
||||
#define MALLOC_DECL(name, return_type, ...) \
|
||||
#define MALLOC_DECL(name, return_type, ...) \
|
||||
template<> \
|
||||
inline return_type ReplaceMalloc::name( \
|
||||
ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) \
|
||||
{ \
|
||||
if (MOZ_UNLIKELY(!gReplaceMallocTable)) { \
|
||||
if (MOZ_UNLIKELY(!gReplaceMallocTable)) { \
|
||||
init(); \
|
||||
} \
|
||||
return (*gReplaceMallocTable).name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \
|
||||
return (*gReplaceMallocTable).name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \
|
||||
}
|
||||
#include "malloc_decls.h"
|
||||
|
||||
@ -4875,7 +4881,7 @@ get_bridge(void)
|
||||
// replace_valloc, and default implementations will be automatically derived
|
||||
// from replace_memalign.
|
||||
static void
|
||||
replace_malloc_init_funcs(malloc_table_t *table)
|
||||
replace_malloc_init_funcs(malloc_table_t* table)
|
||||
{
|
||||
if (table->posix_memalign == MozJemalloc::posix_memalign &&
|
||||
table->memalign != MozJemalloc::memalign) {
|
||||
@ -4889,8 +4895,7 @@ replace_malloc_init_funcs(malloc_table_t *table)
|
||||
}
|
||||
if (table->valloc == MozJemalloc::valloc &&
|
||||
table->memalign != MozJemalloc::memalign) {
|
||||
table->valloc =
|
||||
AlignedAllocator<ReplaceMalloc::memalign>::valloc;
|
||||
table->valloc = AlignedAllocator<ReplaceMalloc::memalign>::valloc;
|
||||
}
|
||||
if (table->moz_create_arena_with_params ==
|
||||
MozJemalloc::moz_create_arena_with_params &&
|
||||
@ -4900,8 +4905,7 @@ replace_malloc_init_funcs(malloc_table_t *table)
|
||||
#define MALLOC_FUNCS MALLOC_FUNCS_ARENA_BASE
|
||||
#include "malloc_decls.h"
|
||||
}
|
||||
if (table->moz_arena_malloc ==
|
||||
MozJemalloc::moz_arena_malloc &&
|
||||
if (table->moz_arena_malloc == MozJemalloc::moz_arena_malloc &&
|
||||
table->malloc != MozJemalloc::malloc) {
|
||||
#define MALLOC_DECL(name, ...) \
|
||||
table->name = DummyArenaAllocator<ReplaceMalloc>::name;
|
||||
@ -4911,8 +4915,8 @@ replace_malloc_init_funcs(malloc_table_t *table)
|
||||
}
|
||||
|
||||
#endif // MOZ_REPLACE_MALLOC
|
||||
// ***************************************************************************
|
||||
// Definition of all the _impl functions
|
||||
// ***************************************************************************
|
||||
// Definition of all the _impl functions
|
||||
|
||||
#define GENERIC_MALLOC_DECL2(name, name_impl, return_type, ...) \
|
||||
return_type name_impl(ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) \
|
||||
@ -4936,7 +4940,7 @@ replace_malloc_init_funcs(malloc_table_t *table)
|
||||
MOZ_JEMALLOC_API MACRO_CALL(GENERIC_MALLOC_DECL, (__VA_ARGS__))
|
||||
#define MALLOC_FUNCS (MALLOC_FUNCS_JEMALLOC | MALLOC_FUNCS_ARENA)
|
||||
#include "malloc_decls.h"
|
||||
// ***************************************************************************
|
||||
// ***************************************************************************
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
|
Loading…
Reference in New Issue
Block a user