45
src/arena.c
45
src/arena.c
@@ -40,7 +40,6 @@ static void arena_bin_lower_slab(tsdn_t *tsdn, arena_t *arena,
|
||||
static size_t
|
||||
arena_extent_dirty_npages(const extent_t *extent)
|
||||
{
|
||||
|
||||
return (extent_size_get(extent) >> LG_PAGE);
|
||||
}
|
||||
|
||||
@@ -76,7 +75,6 @@ static void
|
||||
arena_extent_cache_dalloc_locked(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &arena->lock);
|
||||
|
||||
extent_dalloc_cache(tsdn, arena, r_extent_hooks, extent);
|
||||
@@ -87,7 +85,6 @@ void
|
||||
arena_extent_cache_dalloc(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
arena_extent_cache_dalloc_locked(tsdn, arena, r_extent_hooks, extent);
|
||||
malloc_mutex_unlock(tsdn, &arena->lock);
|
||||
@@ -97,7 +94,6 @@ void
|
||||
arena_extent_cache_maybe_insert(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
|
||||
bool cache)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &arena->extents_mtx);
|
||||
|
||||
if (cache) {
|
||||
@@ -110,7 +106,6 @@ void
|
||||
arena_extent_cache_maybe_remove(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
|
||||
bool dirty)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &arena->extents_mtx);
|
||||
|
||||
if (dirty) {
|
||||
@@ -196,14 +191,12 @@ arena_slab_reg_dalloc(tsdn_t *tsdn, extent_t *slab,
|
||||
static void
|
||||
arena_nactive_add(arena_t *arena, size_t add_pages)
|
||||
{
|
||||
|
||||
arena->nactive += add_pages;
|
||||
}
|
||||
|
||||
static void
|
||||
arena_nactive_sub(arena_t *arena, size_t sub_pages)
|
||||
{
|
||||
|
||||
assert(arena->nactive >= sub_pages);
|
||||
arena->nactive -= sub_pages;
|
||||
}
|
||||
@@ -279,7 +272,6 @@ arena_large_reset_stats_cancel(arena_t *arena, size_t usize)
|
||||
static void
|
||||
arena_large_ralloc_stats_update(arena_t *arena, size_t oldusize, size_t usize)
|
||||
{
|
||||
|
||||
arena_large_dalloc_stats_update(arena, oldusize);
|
||||
arena_large_malloc_stats_update(arena, usize);
|
||||
}
|
||||
@@ -391,7 +383,6 @@ arena_extent_ralloc_large_expand(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
|
||||
static void
|
||||
arena_decay_deadline_init(arena_t *arena)
|
||||
{
|
||||
|
||||
/*
|
||||
* Generate a new deadline that is uniformly random within the next
|
||||
* epoch after the current one.
|
||||
@@ -410,7 +401,6 @@ arena_decay_deadline_init(arena_t *arena)
|
||||
static bool
|
||||
arena_decay_deadline_reached(const arena_t *arena, const nstime_t *time)
|
||||
{
|
||||
|
||||
return (nstime_compare(&arena->decay.deadline, time) <= 0);
|
||||
}
|
||||
|
||||
@@ -451,7 +441,6 @@ arena_decay_backlog_update_last(arena_t *arena)
|
||||
static void
|
||||
arena_decay_backlog_update(arena_t *arena, uint64_t nadvance_u64)
|
||||
{
|
||||
|
||||
if (nadvance_u64 >= SMOOTHSTEP_NSTEPS) {
|
||||
memset(arena->decay.backlog, 0, (SMOOTHSTEP_NSTEPS-1) *
|
||||
sizeof(size_t));
|
||||
@@ -509,7 +498,6 @@ arena_decay_epoch_advance_purge(tsdn_t *tsdn, arena_t *arena)
|
||||
static void
|
||||
arena_decay_epoch_advance(tsdn_t *tsdn, arena_t *arena, const nstime_t *time)
|
||||
{
|
||||
|
||||
arena_decay_epoch_advance_helper(arena, time);
|
||||
arena_decay_epoch_advance_purge(tsdn, arena);
|
||||
}
|
||||
@@ -517,7 +505,6 @@ arena_decay_epoch_advance(tsdn_t *tsdn, arena_t *arena, const nstime_t *time)
|
||||
static void
|
||||
arena_decay_init(arena_t *arena, ssize_t decay_time)
|
||||
{
|
||||
|
||||
arena->decay.time = decay_time;
|
||||
if (decay_time > 0) {
|
||||
nstime_init2(&arena->decay.interval, decay_time, 0);
|
||||
@@ -535,7 +522,6 @@ arena_decay_init(arena_t *arena, ssize_t decay_time)
|
||||
static bool
|
||||
arena_decay_time_valid(ssize_t decay_time)
|
||||
{
|
||||
|
||||
if (decay_time < -1)
|
||||
return (false);
|
||||
if (decay_time == -1 || (uint64_t)decay_time <= NSTIME_SEC_MAX)
|
||||
@@ -558,7 +544,6 @@ arena_decay_time_get(tsdn_t *tsdn, arena_t *arena)
|
||||
bool
|
||||
arena_decay_time_set(tsdn_t *tsdn, arena_t *arena, ssize_t decay_time)
|
||||
{
|
||||
|
||||
if (!arena_decay_time_valid(decay_time))
|
||||
return (true);
|
||||
|
||||
@@ -623,7 +608,6 @@ arena_maybe_purge_helper(tsdn_t *tsdn, arena_t *arena)
|
||||
void
|
||||
arena_maybe_purge(tsdn_t *tsdn, arena_t *arena)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &arena->lock);
|
||||
|
||||
/* Don't recursively purge. */
|
||||
@@ -762,7 +746,6 @@ label_return:
|
||||
void
|
||||
arena_purge(tsdn_t *tsdn, arena_t *arena, bool all)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
if (all)
|
||||
arena_purge_to_limit(tsdn, arena, 0);
|
||||
@@ -783,7 +766,6 @@ arena_slab_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *slab)
|
||||
static void
|
||||
arena_bin_slabs_nonfull_insert(arena_bin_t *bin, extent_t *slab)
|
||||
{
|
||||
|
||||
assert(extent_slab_data_get(slab)->nfree > 0);
|
||||
extent_heap_insert(&bin->slabs_nonfull, slab);
|
||||
}
|
||||
@@ -791,7 +773,6 @@ arena_bin_slabs_nonfull_insert(arena_bin_t *bin, extent_t *slab)
|
||||
static void
|
||||
arena_bin_slabs_nonfull_remove(arena_bin_t *bin, extent_t *slab)
|
||||
{
|
||||
|
||||
extent_heap_remove(&bin->slabs_nonfull, slab);
|
||||
}
|
||||
|
||||
@@ -809,7 +790,6 @@ arena_bin_slabs_nonfull_tryget(arena_bin_t *bin)
|
||||
static void
|
||||
arena_bin_slabs_full_insert(arena_bin_t *bin, extent_t *slab)
|
||||
{
|
||||
|
||||
assert(extent_slab_data_get(slab)->nfree == 0);
|
||||
extent_ring_insert(&bin->slabs_full, slab);
|
||||
}
|
||||
@@ -817,7 +797,6 @@ arena_bin_slabs_full_insert(arena_bin_t *bin, extent_t *slab)
|
||||
static void
|
||||
arena_bin_slabs_full_remove(extent_t *slab)
|
||||
{
|
||||
|
||||
extent_ring_remove(slab);
|
||||
}
|
||||
|
||||
@@ -935,7 +914,6 @@ arena_destroy_retained(tsdn_t *tsdn, arena_t *arena)
|
||||
void
|
||||
arena_destroy(tsd_t *tsd, arena_t *arena)
|
||||
{
|
||||
|
||||
assert(base_ind_get(arena->base) >= narenas_auto);
|
||||
assert(arena_nthreads_get(arena, false) == 0);
|
||||
assert(arena_nthreads_get(arena, true) == 0);
|
||||
@@ -1176,7 +1154,6 @@ arena_tcache_fill_small(tsdn_t *tsdn, arena_t *arena, tcache_bin_t *tbin,
|
||||
void
|
||||
arena_alloc_junk_small(void *ptr, const arena_bin_info_t *bin_info, bool zero)
|
||||
{
|
||||
|
||||
if (!zero)
|
||||
memset(ptr, JEMALLOC_ALLOC_JUNK, bin_info->reg_size);
|
||||
}
|
||||
@@ -1188,7 +1165,6 @@ arena_alloc_junk_small(void *ptr, const arena_bin_info_t *bin_info, bool zero)
|
||||
void
|
||||
arena_dalloc_junk_small(void *ptr, const arena_bin_info_t *bin_info)
|
||||
{
|
||||
|
||||
memset(ptr, JEMALLOC_FREE_JUNK, bin_info->reg_size);
|
||||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
@@ -1255,7 +1231,6 @@ void *
|
||||
arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind,
|
||||
bool zero)
|
||||
{
|
||||
|
||||
assert(!tsdn_null(tsdn) || arena != NULL);
|
||||
|
||||
if (likely(!tsdn_null(tsdn)))
|
||||
@@ -1320,7 +1295,6 @@ arena_prof_promote(tsdn_t *tsdn, extent_t *extent, const void *ptr,
|
||||
static size_t
|
||||
arena_prof_demote(tsdn_t *tsdn, extent_t *extent, const void *ptr)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
assert(ptr != NULL);
|
||||
|
||||
@@ -1351,7 +1325,6 @@ arena_dalloc_promoted(tsdn_t *tsdn, extent_t *extent, void *ptr,
|
||||
static void
|
||||
arena_dissociate_bin_slab(extent_t *slab, arena_bin_t *bin)
|
||||
{
|
||||
|
||||
/* Dissociate slab from bin. */
|
||||
if (slab == bin->slabcur)
|
||||
bin->slabcur = NULL;
|
||||
@@ -1375,7 +1348,6 @@ static void
|
||||
arena_dalloc_bin_slab(tsdn_t *tsdn, arena_t *arena, extent_t *slab,
|
||||
arena_bin_t *bin)
|
||||
{
|
||||
|
||||
assert(slab != bin->slabcur);
|
||||
|
||||
malloc_mutex_unlock(tsdn, &bin->lock);
|
||||
@@ -1393,7 +1365,6 @@ static void
|
||||
arena_bin_lower_slab(tsdn_t *tsdn, arena_t *arena, extent_t *slab,
|
||||
arena_bin_t *bin)
|
||||
{
|
||||
|
||||
assert(extent_slab_data_get(slab)->nfree > 0);
|
||||
|
||||
/*
|
||||
@@ -1446,7 +1417,6 @@ void
|
||||
arena_dalloc_bin_junked_locked(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
|
||||
void *ptr)
|
||||
{
|
||||
|
||||
arena_dalloc_bin_locked_impl(tsdn, arena, extent, ptr, true);
|
||||
}
|
||||
|
||||
@@ -1463,7 +1433,6 @@ arena_dalloc_bin(tsdn_t *tsdn, arena_t *arena, extent_t *extent, void *ptr)
|
||||
void
|
||||
arena_dalloc_small(tsdn_t *tsdn, arena_t *arena, extent_t *extent, void *ptr)
|
||||
{
|
||||
|
||||
arena_dalloc_bin(tsdn, arena, extent, ptr);
|
||||
arena_decay_tick(tsdn, arena);
|
||||
}
|
||||
@@ -1508,7 +1477,6 @@ static void *
|
||||
arena_ralloc_move_helper(tsdn_t *tsdn, arena_t *arena, size_t usize,
|
||||
size_t alignment, bool zero, tcache_t *tcache)
|
||||
{
|
||||
|
||||
if (alignment == 0)
|
||||
return (arena_malloc(tsdn, arena, usize, size2index(usize),
|
||||
zero, tcache, true));
|
||||
@@ -1575,7 +1543,6 @@ arena_dss_prec_get(tsdn_t *tsdn, arena_t *arena)
|
||||
bool
|
||||
arena_dss_prec_set(tsdn_t *tsdn, arena_t *arena, dss_prec_t dss_prec)
|
||||
{
|
||||
|
||||
if (!have_dss)
|
||||
return (dss_prec != dss_prec_disabled);
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
@@ -1587,14 +1554,12 @@ arena_dss_prec_set(tsdn_t *tsdn, arena_t *arena, dss_prec_t dss_prec)
|
||||
ssize_t
|
||||
arena_decay_time_default_get(void)
|
||||
{
|
||||
|
||||
return ((ssize_t)atomic_read_zu((size_t *)&decay_time_default));
|
||||
}
|
||||
|
||||
bool
|
||||
arena_decay_time_default_set(ssize_t decay_time)
|
||||
{
|
||||
|
||||
if (!arena_decay_time_valid(decay_time))
|
||||
return (true);
|
||||
atomic_write_zu((size_t *)&decay_time_default, (size_t)decay_time);
|
||||
@@ -1605,7 +1570,6 @@ static void
|
||||
arena_basic_stats_merge_locked(arena_t *arena, unsigned *nthreads,
|
||||
const char **dss, ssize_t *decay_time, size_t *nactive, size_t *ndirty)
|
||||
{
|
||||
|
||||
*nthreads += arena_nthreads_get(arena, false);
|
||||
*dss = dss_prec_names[arena->dss_prec];
|
||||
*decay_time = arena->decay.time;
|
||||
@@ -1617,7 +1581,6 @@ void
|
||||
arena_basic_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
|
||||
const char **dss, ssize_t *decay_time, size_t *nactive, size_t *ndirty)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
arena_basic_stats_merge_locked(arena, nthreads, dss, decay_time,
|
||||
nactive, ndirty);
|
||||
@@ -1686,28 +1649,24 @@ arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
|
||||
unsigned
|
||||
arena_nthreads_get(arena_t *arena, bool internal)
|
||||
{
|
||||
|
||||
return (atomic_read_u(&arena->nthreads[internal]));
|
||||
}
|
||||
|
||||
void
|
||||
arena_nthreads_inc(arena_t *arena, bool internal)
|
||||
{
|
||||
|
||||
atomic_add_u(&arena->nthreads[internal], 1);
|
||||
}
|
||||
|
||||
void
|
||||
arena_nthreads_dec(arena_t *arena, bool internal)
|
||||
{
|
||||
|
||||
atomic_sub_u(&arena->nthreads[internal], 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
arena_extent_sn_next(arena_t *arena)
|
||||
{
|
||||
|
||||
return (atomic_add_zu(&arena->extent_sn_next, 1) - 1);
|
||||
}
|
||||
|
||||
@@ -1813,28 +1772,24 @@ label_error:
|
||||
void
|
||||
arena_boot(void)
|
||||
{
|
||||
|
||||
arena_decay_time_default_set(opt_decay_time);
|
||||
}
|
||||
|
||||
void
|
||||
arena_prefork0(tsdn_t *tsdn, arena_t *arena)
|
||||
{
|
||||
|
||||
malloc_mutex_prefork(tsdn, &arena->lock);
|
||||
}
|
||||
|
||||
void
|
||||
arena_prefork1(tsdn_t *tsdn, arena_t *arena)
|
||||
{
|
||||
|
||||
malloc_mutex_prefork(tsdn, &arena->extents_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
arena_prefork2(tsdn_t *tsdn, arena_t *arena)
|
||||
{
|
||||
|
||||
malloc_mutex_prefork(tsdn, &arena->extent_cache_mtx);
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,6 @@ base_map(extent_hooks_t *extent_hooks, unsigned ind, size_t size)
|
||||
static void
|
||||
base_unmap(extent_hooks_t *extent_hooks, unsigned ind, void *addr, size_t size)
|
||||
{
|
||||
|
||||
/*
|
||||
* Cascade through dalloc, decommit, purge_lazy, and purge_forced,
|
||||
* stopping at first success. This cascade is performed for consistency
|
||||
@@ -107,7 +106,6 @@ static void
|
||||
base_extent_bump_alloc_post(tsdn_t *tsdn, base_t *base, extent_t *extent,
|
||||
size_t gap_size, void *addr, size_t size)
|
||||
{
|
||||
|
||||
if (extent_size_get(extent) > 0) {
|
||||
/*
|
||||
* Compute the index for the largest size class that does not
|
||||
@@ -202,7 +200,6 @@ base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment)
|
||||
base_t *
|
||||
b0get(void)
|
||||
{
|
||||
|
||||
return (b0);
|
||||
}
|
||||
|
||||
@@ -263,7 +260,6 @@ base_delete(base_t *base)
|
||||
extent_hooks_t *
|
||||
base_extent_hooks_get(base_t *base)
|
||||
{
|
||||
|
||||
return ((extent_hooks_t *)atomic_read_p(&base->extent_hooks_pun));
|
||||
}
|
||||
|
||||
@@ -330,7 +326,6 @@ void
|
||||
base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated, size_t *resident,
|
||||
size_t *mapped)
|
||||
{
|
||||
|
||||
cassert(config_stats);
|
||||
|
||||
malloc_mutex_lock(tsdn, &base->mtx);
|
||||
@@ -345,28 +340,24 @@ base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated, size_t *resident,
|
||||
void
|
||||
base_prefork(tsdn_t *tsdn, base_t *base)
|
||||
{
|
||||
|
||||
malloc_mutex_prefork(tsdn, &base->mtx);
|
||||
}
|
||||
|
||||
void
|
||||
base_postfork_parent(tsdn_t *tsdn, base_t *base)
|
||||
{
|
||||
|
||||
malloc_mutex_postfork_parent(tsdn, &base->mtx);
|
||||
}
|
||||
|
||||
void
|
||||
base_postfork_child(tsdn_t *tsdn, base_t *base)
|
||||
{
|
||||
|
||||
malloc_mutex_postfork_child(tsdn, &base->mtx);
|
||||
}
|
||||
|
||||
bool
|
||||
base_boot(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
b0 = base_new(tsdn, 0, (extent_hooks_t *)&extent_hooks_default);
|
||||
return (b0 == NULL);
|
||||
}
|
||||
|
@@ -37,7 +37,6 @@ bitmap_info_init(bitmap_info_t *binfo, size_t nbits)
|
||||
static size_t
|
||||
bitmap_info_ngroups(const bitmap_info_t *binfo)
|
||||
{
|
||||
|
||||
return (binfo->levels[binfo->nlevels].group_offset);
|
||||
}
|
||||
|
||||
@@ -74,7 +73,6 @@ bitmap_init(bitmap_t *bitmap, const bitmap_info_t *binfo)
|
||||
void
|
||||
bitmap_info_init(bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
|
||||
assert(nbits > 0);
|
||||
assert(nbits <= (ZU(1) << LG_BITMAP_MAXBITS));
|
||||
|
||||
@@ -85,7 +83,6 @@ bitmap_info_init(bitmap_info_t *binfo, size_t nbits)
|
||||
static size_t
|
||||
bitmap_info_ngroups(const bitmap_info_t *binfo)
|
||||
{
|
||||
|
||||
return (binfo->ngroups);
|
||||
}
|
||||
|
||||
@@ -106,6 +103,5 @@ bitmap_init(bitmap_t *bitmap, const bitmap_info_t *binfo)
|
||||
size_t
|
||||
bitmap_size(const bitmap_info_t *binfo)
|
||||
{
|
||||
|
||||
return (bitmap_info_ngroups(binfo) << LG_SIZEOF_BITMAP);
|
||||
}
|
||||
|
@@ -411,7 +411,6 @@ label_return:
|
||||
void
|
||||
ckh_delete(tsd_t *tsd, ckh_t *ckh)
|
||||
{
|
||||
|
||||
assert(ckh != NULL);
|
||||
|
||||
#ifdef CKH_VERBOSE
|
||||
@@ -435,7 +434,6 @@ ckh_delete(tsd_t *tsd, ckh_t *ckh)
|
||||
size_t
|
||||
ckh_count(ckh_t *ckh)
|
||||
{
|
||||
|
||||
assert(ckh != NULL);
|
||||
|
||||
return (ckh->count);
|
||||
@@ -539,14 +537,12 @@ ckh_search(ckh_t *ckh, const void *searchkey, void **key, void **data)
|
||||
void
|
||||
ckh_string_hash(const void *key, size_t r_hash[2])
|
||||
{
|
||||
|
||||
hash(key, strlen((const char *)key), 0x94122f33U, r_hash);
|
||||
}
|
||||
|
||||
bool
|
||||
ckh_string_keycomp(const void *k1, const void *k2)
|
||||
{
|
||||
|
||||
assert(k1 != NULL);
|
||||
assert(k2 != NULL);
|
||||
|
||||
@@ -569,6 +565,5 @@ ckh_pointer_hash(const void *key, size_t r_hash[2])
|
||||
bool
|
||||
ckh_pointer_keycomp(const void *k1, const void *k2)
|
||||
{
|
||||
|
||||
return ((k1 == k2) ? true : false);
|
||||
}
|
||||
|
13
src/ctl.c
13
src/ctl.c
@@ -18,7 +18,6 @@ static ctl_stats_t *ctl_stats;
|
||||
JEMALLOC_INLINE_C const ctl_named_node_t *
|
||||
ctl_named_node(const ctl_node_t *node)
|
||||
{
|
||||
|
||||
return ((node->named) ? (const ctl_named_node_t *)node : NULL);
|
||||
}
|
||||
|
||||
@@ -33,7 +32,6 @@ ctl_named_children(const ctl_named_node_t *node, size_t index)
|
||||
JEMALLOC_INLINE_C const ctl_indexed_node_t *
|
||||
ctl_indexed_node(const ctl_node_t *node)
|
||||
{
|
||||
|
||||
return (!node->named ? (const ctl_indexed_node_t *)node : NULL);
|
||||
}
|
||||
|
||||
@@ -475,7 +473,6 @@ stats_arenas_i2a_impl(size_t i, bool compat, bool validate)
|
||||
static unsigned
|
||||
stats_arenas_i2a(size_t i)
|
||||
{
|
||||
|
||||
return (stats_arenas_i2a_impl(i, true, false));
|
||||
}
|
||||
|
||||
@@ -513,7 +510,6 @@ stats_arenas_i(size_t i)
|
||||
static void
|
||||
ctl_arena_clear(ctl_arena_stats_t *astats)
|
||||
{
|
||||
|
||||
astats->nthreads = 0;
|
||||
astats->dss = dss_prec_names[dss_prec_limit];
|
||||
astats->decay_time = -1;
|
||||
@@ -985,7 +981,6 @@ label_return:
|
||||
bool
|
||||
ctl_boot(void)
|
||||
{
|
||||
|
||||
if (malloc_mutex_init(&ctl_mtx, "ctl", WITNESS_RANK_CTL))
|
||||
return (true);
|
||||
|
||||
@@ -997,21 +992,18 @@ ctl_boot(void)
|
||||
void
|
||||
ctl_prefork(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
malloc_mutex_prefork(tsdn, &ctl_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
ctl_postfork_parent(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
malloc_mutex_postfork_parent(tsdn, &ctl_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
ctl_postfork_child(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
malloc_mutex_postfork_child(tsdn, &ctl_mtx);
|
||||
}
|
||||
|
||||
@@ -1540,7 +1532,6 @@ label_return:
|
||||
static void
|
||||
arena_i_purge(tsdn_t *tsdn, unsigned arena_ind, bool all)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &ctl_mtx);
|
||||
{
|
||||
unsigned narenas = ctl_stats->narenas;
|
||||
@@ -1918,7 +1909,6 @@ CTL_RO_NL_GEN(arenas_bin_i_slab_size, arena_bin_info[mib[2]].slab_size, size_t)
|
||||
static const ctl_named_node_t *
|
||||
arenas_bin_i_index(tsdn_t *tsdn, const size_t *mib, size_t miblen, size_t i)
|
||||
{
|
||||
|
||||
if (i > NBINS)
|
||||
return (NULL);
|
||||
return (super_arenas_bin_i_node);
|
||||
@@ -1929,7 +1919,6 @@ CTL_RO_NL_GEN(arenas_lextent_i_size, index2size(NBINS+(szind_t)mib[2]), size_t)
|
||||
static const ctl_named_node_t *
|
||||
arenas_lextent_i_index(tsdn_t *tsdn, const size_t *mib, size_t miblen, size_t i)
|
||||
{
|
||||
|
||||
if (i > NSIZES - NBINS)
|
||||
return (NULL);
|
||||
return (super_arenas_lextent_i_node);
|
||||
@@ -2159,7 +2148,6 @@ static const ctl_named_node_t *
|
||||
stats_arenas_i_bins_j_index(tsdn_t *tsdn, const size_t *mib, size_t miblen,
|
||||
size_t j)
|
||||
{
|
||||
|
||||
if (j > NBINS)
|
||||
return (NULL);
|
||||
return (super_stats_arenas_i_bins_j_node);
|
||||
@@ -2178,7 +2166,6 @@ static const ctl_named_node_t *
|
||||
stats_arenas_i_lextents_j_index(tsdn_t *tsdn, const size_t *mib, size_t miblen,
|
||||
size_t j)
|
||||
{
|
||||
|
||||
if (j > NSIZES - NBINS)
|
||||
return (NULL);
|
||||
return (super_stats_arenas_i_lextents_j_node);
|
||||
|
28
src/extent.c
28
src/extent.c
@@ -94,7 +94,6 @@ extent_alloc(tsdn_t *tsdn, arena_t *arena)
|
||||
void
|
||||
extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->extent_cache_mtx);
|
||||
ql_elm_new(extent, ql_link);
|
||||
ql_tail_insert(&arena->extent_cache, extent, ql_link);
|
||||
@@ -104,21 +103,18 @@ extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent)
|
||||
extent_hooks_t *
|
||||
extent_hooks_get(arena_t *arena)
|
||||
{
|
||||
|
||||
return (base_extent_hooks_get(arena->base));
|
||||
}
|
||||
|
||||
extent_hooks_t *
|
||||
extent_hooks_set(arena_t *arena, extent_hooks_t *extent_hooks)
|
||||
{
|
||||
|
||||
return (base_extent_hooks_set(arena->base, extent_hooks));
|
||||
}
|
||||
|
||||
static void
|
||||
extent_hooks_assure_initialized(arena_t *arena, extent_hooks_t **r_extent_hooks)
|
||||
{
|
||||
|
||||
if (*r_extent_hooks == EXTENT_HOOKS_INITIALIZER)
|
||||
*r_extent_hooks = extent_hooks_get(arena);
|
||||
}
|
||||
@@ -226,7 +222,6 @@ extent_rtree_acquire(tsdn_t *tsdn, rtree_ctx_t *rtree_ctx,
|
||||
const extent_t *extent, bool dependent, bool init_missing,
|
||||
rtree_elm_t **r_elm_a, rtree_elm_t **r_elm_b)
|
||||
{
|
||||
|
||||
*r_elm_a = rtree_elm_acquire(tsdn, &extents_rtree, rtree_ctx,
|
||||
(uintptr_t)extent_base_get(extent), dependent, init_missing);
|
||||
if (!dependent && *r_elm_a == NULL)
|
||||
@@ -252,7 +247,6 @@ static void
|
||||
extent_rtree_write_acquired(tsdn_t *tsdn, rtree_elm_t *elm_a,
|
||||
rtree_elm_t *elm_b, const extent_t *extent)
|
||||
{
|
||||
|
||||
rtree_elm_write_acquired(tsdn, &extents_rtree, elm_a, extent);
|
||||
if (elm_b != NULL)
|
||||
rtree_elm_write_acquired(tsdn, &extents_rtree, elm_b, extent);
|
||||
@@ -261,7 +255,6 @@ extent_rtree_write_acquired(tsdn_t *tsdn, rtree_elm_t *elm_a,
|
||||
static void
|
||||
extent_rtree_release(tsdn_t *tsdn, rtree_elm_t *elm_a, rtree_elm_t *elm_b)
|
||||
{
|
||||
|
||||
rtree_elm_release(tsdn, &extents_rtree, elm_a);
|
||||
if (elm_b != NULL)
|
||||
rtree_elm_release(tsdn, &extents_rtree, elm_b);
|
||||
@@ -285,7 +278,6 @@ extent_interior_register(tsdn_t *tsdn, rtree_ctx_t *rtree_ctx,
|
||||
static void
|
||||
extent_gprof_add(tsdn_t *tsdn, const extent_t *extent)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
if (opt_prof && extent_active_get(extent)) {
|
||||
@@ -307,7 +299,6 @@ extent_gprof_add(tsdn_t *tsdn, const extent_t *extent)
|
||||
static void
|
||||
extent_gprof_sub(tsdn_t *tsdn, const extent_t *extent)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
if (opt_prof && extent_active_get(extent)) {
|
||||
@@ -406,7 +397,6 @@ static void
|
||||
extent_leak(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
||||
bool cache, extent_t *extent)
|
||||
{
|
||||
|
||||
/*
|
||||
* Leak extent after making sure its pages have already been purged, so
|
||||
* that this is only a virtual memory leak.
|
||||
@@ -641,7 +631,6 @@ extent_alloc_cache_locked(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, void *new_addr, size_t usize, size_t pad,
|
||||
size_t alignment, bool *zero, bool *commit, bool slab)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &arena->extents_mtx);
|
||||
|
||||
return (extent_alloc_cache_impl(tsdn, arena, r_extent_hooks, true,
|
||||
@@ -653,7 +642,6 @@ extent_alloc_cache(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, void *new_addr, size_t usize, size_t pad,
|
||||
size_t alignment, bool *zero, bool *commit, bool slab)
|
||||
{
|
||||
|
||||
return (extent_alloc_cache_impl(tsdn, arena, r_extent_hooks, false,
|
||||
new_addr, usize, pad, alignment, zero, commit, slab));
|
||||
}
|
||||
@@ -694,7 +682,6 @@ static void
|
||||
extent_retain(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
||||
extent_t *extent)
|
||||
{
|
||||
|
||||
if (config_stats)
|
||||
arena->stats.retained += extent_size_get(extent);
|
||||
extent_record(tsdn, arena, r_extent_hooks, arena->extents_retained,
|
||||
@@ -906,7 +893,6 @@ extent_alloc_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
static bool
|
||||
extent_can_coalesce(const extent_t *a, const extent_t *b)
|
||||
{
|
||||
|
||||
if (extent_arena_get(a) != extent_arena_get(b))
|
||||
return (false);
|
||||
if (extent_active_get(a) != extent_active_get(b))
|
||||
@@ -924,7 +910,6 @@ extent_try_coalesce(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *a, extent_t *b,
|
||||
extent_heap_t extent_heaps[NPSIZES+1], bool cache)
|
||||
{
|
||||
|
||||
if (!extent_can_coalesce(a, b))
|
||||
return;
|
||||
|
||||
@@ -1008,7 +993,6 @@ void
|
||||
extent_dalloc_cache(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent)
|
||||
{
|
||||
|
||||
assert(extent_base_get(extent) != NULL);
|
||||
assert(extent_size_get(extent) != 0);
|
||||
|
||||
@@ -1022,7 +1006,6 @@ extent_dalloc_cache(tsdn_t *tsdn, arena_t *arena,
|
||||
static bool
|
||||
extent_dalloc_default_impl(void *addr, size_t size)
|
||||
{
|
||||
|
||||
if (!have_dss || !extent_in_dss(addr))
|
||||
return (extent_dalloc_mmap(addr, size));
|
||||
return (true);
|
||||
@@ -1033,7 +1016,6 @@ static bool
|
||||
extent_dalloc_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
bool committed, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
|
||||
return (extent_dalloc_default_impl(addr, size));
|
||||
@@ -1116,7 +1098,6 @@ static bool
|
||||
extent_commit_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
size_t offset, size_t length, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
|
||||
return (pages_commit((void *)((uintptr_t)addr + (uintptr_t)offset),
|
||||
@@ -1142,7 +1123,6 @@ static bool
|
||||
extent_decommit_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
size_t offset, size_t length, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
|
||||
return (pages_decommit((void *)((uintptr_t)addr + (uintptr_t)offset),
|
||||
@@ -1171,7 +1151,6 @@ static bool
|
||||
extent_purge_lazy_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
size_t offset, size_t length, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
assert(addr != NULL);
|
||||
assert((offset & PAGE_MASK) == 0);
|
||||
@@ -1188,7 +1167,6 @@ extent_purge_lazy_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length)
|
||||
{
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
return ((*r_extent_hooks)->purge_lazy == NULL ||
|
||||
(*r_extent_hooks)->purge_lazy(*r_extent_hooks,
|
||||
@@ -1201,7 +1179,6 @@ static bool
|
||||
extent_purge_forced_default(extent_hooks_t *extent_hooks, void *addr,
|
||||
size_t size, size_t offset, size_t length, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
assert(addr != NULL);
|
||||
assert((offset & PAGE_MASK) == 0);
|
||||
@@ -1218,7 +1195,6 @@ extent_purge_forced_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length)
|
||||
{
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
return ((*r_extent_hooks)->purge_forced == NULL ||
|
||||
(*r_extent_hooks)->purge_forced(*r_extent_hooks,
|
||||
@@ -1231,7 +1207,6 @@ static bool
|
||||
extent_split_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
size_t size_a, size_t size_b, bool committed, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
|
||||
if (!maps_coalesce)
|
||||
@@ -1310,7 +1285,6 @@ label_error_a:
|
||||
static bool
|
||||
extent_merge_default_impl(void *addr_a, void *addr_b)
|
||||
{
|
||||
|
||||
if (!maps_coalesce)
|
||||
return (true);
|
||||
if (have_dss && !extent_dss_mergeable(addr_a, addr_b))
|
||||
@@ -1324,7 +1298,6 @@ static bool
|
||||
extent_merge_default(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
|
||||
void *addr_b, size_t size_b, bool committed, unsigned arena_ind)
|
||||
{
|
||||
|
||||
assert(extent_hooks == &extent_hooks_default);
|
||||
|
||||
return (extent_merge_default_impl(addr_a, addr_b));
|
||||
@@ -1396,7 +1369,6 @@ extent_merge_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
bool
|
||||
extent_boot(void)
|
||||
{
|
||||
|
||||
if (rtree_new(&extents_rtree, (unsigned)((ZU(1) << (LG_SIZEOF_PTR+3)) -
|
||||
LG_PAGE)))
|
||||
return (true);
|
||||
|
@@ -32,7 +32,6 @@ static void *dss_max;
|
||||
static void *
|
||||
extent_dss_sbrk(intptr_t increment)
|
||||
{
|
||||
|
||||
#ifdef JEMALLOC_DSS
|
||||
return (sbrk(increment));
|
||||
#else
|
||||
@@ -55,7 +54,6 @@ extent_dss_prec_get(void)
|
||||
bool
|
||||
extent_dss_prec_set(dss_prec_t dss_prec)
|
||||
{
|
||||
|
||||
if (!have_dss)
|
||||
return (dss_prec != dss_prec_disabled);
|
||||
atomic_write_u(&dss_prec_default, (unsigned)dss_prec);
|
||||
@@ -208,7 +206,6 @@ label_oom:
|
||||
static bool
|
||||
extent_in_dss_helper(void *addr, void *max)
|
||||
{
|
||||
|
||||
return ((uintptr_t)addr >= (uintptr_t)dss_base && (uintptr_t)addr <
|
||||
(uintptr_t)max);
|
||||
}
|
||||
@@ -216,7 +213,6 @@ extent_in_dss_helper(void *addr, void *max)
|
||||
bool
|
||||
extent_in_dss(void *addr)
|
||||
{
|
||||
|
||||
cassert(have_dss);
|
||||
|
||||
return (extent_in_dss_helper(addr, atomic_read_p(&dss_max)));
|
||||
@@ -241,7 +237,6 @@ extent_dss_mergeable(void *addr_a, void *addr_b)
|
||||
void
|
||||
extent_dss_boot(void)
|
||||
{
|
||||
|
||||
cassert(have_dss);
|
||||
|
||||
dss_base = extent_dss_sbrk(0);
|
||||
|
@@ -69,7 +69,6 @@ extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
|
||||
bool
|
||||
extent_dalloc_mmap(void *addr, size_t size)
|
||||
{
|
||||
|
||||
if (config_munmap)
|
||||
pages_unmap(addr, size);
|
||||
return (!config_munmap);
|
||||
|
@@ -211,7 +211,6 @@ JEMALLOC_ATTR(constructor)
|
||||
static void WINAPI
|
||||
_init_init_lock(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* If another constructor in the same binary is using mallctl to e.g.
|
||||
* set up extent hooks, it may end up running before this one, and
|
||||
@@ -276,14 +275,12 @@ static bool malloc_init_hard(void);
|
||||
JEMALLOC_ALWAYS_INLINE_C bool
|
||||
malloc_initialized(void)
|
||||
{
|
||||
|
||||
return (malloc_init_state == malloc_init_initialized);
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE_C bool
|
||||
malloc_init_a0(void)
|
||||
{
|
||||
|
||||
if (unlikely(malloc_init_state == malloc_init_uninitialized))
|
||||
return (malloc_init_hard_a0());
|
||||
return (false);
|
||||
@@ -292,7 +289,6 @@ malloc_init_a0(void)
|
||||
JEMALLOC_ALWAYS_INLINE_C bool
|
||||
malloc_init(void)
|
||||
{
|
||||
|
||||
if (unlikely(!malloc_initialized()) && malloc_init_hard())
|
||||
return (true);
|
||||
return (false);
|
||||
@@ -306,7 +302,6 @@ malloc_init(void)
|
||||
static void *
|
||||
a0ialloc(size_t size, bool zero, bool is_internal)
|
||||
{
|
||||
|
||||
if (unlikely(malloc_init_a0()))
|
||||
return (NULL);
|
||||
|
||||
@@ -317,21 +312,18 @@ a0ialloc(size_t size, bool zero, bool is_internal)
|
||||
static void
|
||||
a0idalloc(extent_t *extent, void *ptr, bool is_internal)
|
||||
{
|
||||
|
||||
idalloctm(TSDN_NULL, extent, ptr, false, is_internal, true);
|
||||
}
|
||||
|
||||
void *
|
||||
a0malloc(size_t size)
|
||||
{
|
||||
|
||||
return (a0ialloc(size, false, true));
|
||||
}
|
||||
|
||||
void
|
||||
a0dalloc(void *ptr)
|
||||
{
|
||||
|
||||
a0idalloc(iealloc(NULL, ptr), ptr, true);
|
||||
}
|
||||
|
||||
@@ -344,7 +336,6 @@ a0dalloc(void *ptr)
|
||||
void *
|
||||
bootstrap_malloc(size_t size)
|
||||
{
|
||||
|
||||
if (unlikely(size == 0))
|
||||
size = 1;
|
||||
|
||||
@@ -368,7 +359,6 @@ bootstrap_calloc(size_t num, size_t size)
|
||||
void
|
||||
bootstrap_free(void *ptr)
|
||||
{
|
||||
|
||||
if (unlikely(ptr == NULL))
|
||||
return;
|
||||
|
||||
@@ -378,28 +368,24 @@ bootstrap_free(void *ptr)
|
||||
void
|
||||
arena_set(unsigned ind, arena_t *arena)
|
||||
{
|
||||
|
||||
atomic_write_p((void **)&arenas[ind], arena);
|
||||
}
|
||||
|
||||
static void
|
||||
narenas_total_set(unsigned narenas)
|
||||
{
|
||||
|
||||
atomic_write_u(&narenas_total, narenas);
|
||||
}
|
||||
|
||||
static void
|
||||
narenas_total_inc(void)
|
||||
{
|
||||
|
||||
atomic_add_u(&narenas_total, 1);
|
||||
}
|
||||
|
||||
unsigned
|
||||
narenas_total_get(void)
|
||||
{
|
||||
|
||||
return (atomic_read_u(&narenas_total));
|
||||
}
|
||||
|
||||
@@ -689,7 +675,6 @@ arenas_tdata_cleanup(tsd_t *tsd)
|
||||
static void
|
||||
stats_print_atexit(void)
|
||||
{
|
||||
|
||||
if (config_tcache && config_stats) {
|
||||
tsdn_t *tsdn;
|
||||
unsigned narenas, i;
|
||||
@@ -737,7 +722,6 @@ stats_print_atexit(void)
|
||||
static char *
|
||||
secure_getenv(const char *name)
|
||||
{
|
||||
|
||||
# ifdef JEMALLOC_HAVE_ISSETUGID
|
||||
if (issetugid() != 0)
|
||||
return (NULL);
|
||||
@@ -855,7 +839,6 @@ static void
|
||||
malloc_conf_error(const char *msg, const char *k, size_t klen, const char *v,
|
||||
size_t vlen)
|
||||
{
|
||||
|
||||
malloc_printf("<jemalloc>: %s: %.*s:%.*s\n", msg, (int)klen, k,
|
||||
(int)vlen, v);
|
||||
}
|
||||
@@ -1167,7 +1150,6 @@ malloc_conf_init(void)
|
||||
static bool
|
||||
malloc_init_hard_needed(void)
|
||||
{
|
||||
|
||||
if (malloc_initialized() || (IS_INITIALIZER && malloc_init_state ==
|
||||
malloc_init_recursible)) {
|
||||
/*
|
||||
@@ -1197,7 +1179,6 @@ malloc_init_hard_needed(void)
|
||||
static bool
|
||||
malloc_init_hard_a0_locked()
|
||||
{
|
||||
|
||||
malloc_initializer = INITIALIZER;
|
||||
|
||||
if (config_prof)
|
||||
@@ -1261,7 +1242,6 @@ malloc_init_hard_a0(void)
|
||||
static bool
|
||||
malloc_init_hard_recursible(void)
|
||||
{
|
||||
|
||||
malloc_init_state = malloc_init_recursible;
|
||||
|
||||
ncpus = malloc_ncpus();
|
||||
@@ -1285,7 +1265,6 @@ malloc_init_hard_recursible(void)
|
||||
static bool
|
||||
malloc_init_hard_finish(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
if (malloc_mutex_boot())
|
||||
return (true);
|
||||
|
||||
@@ -1458,7 +1437,6 @@ JEMALLOC_ALWAYS_INLINE_C void
|
||||
ialloc_post_check(void *ret, tsdn_t *tsdn, size_t usize, const char *func,
|
||||
bool update_errno, bool slow_path)
|
||||
{
|
||||
|
||||
assert(!tsdn_null(tsdn) || ret == NULL);
|
||||
|
||||
if (unlikely(ret == NULL)) {
|
||||
@@ -1617,7 +1595,6 @@ JEMALLOC_EXPORT int JEMALLOC_NOTHROW
|
||||
JEMALLOC_ATTR(nonnull(1))
|
||||
je_posix_memalign(void **memptr, size_t alignment, size_t size)
|
||||
{
|
||||
|
||||
return (imemalign(memptr, alignment, size, sizeof(void *)));
|
||||
}
|
||||
|
||||
@@ -1754,7 +1731,6 @@ JEMALLOC_INLINE_C void
|
||||
isfree(tsd_t *tsd, extent_t *extent, void *ptr, size_t usize, tcache_t *tcache,
|
||||
bool slow_path)
|
||||
{
|
||||
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
|
||||
assert(ptr != NULL);
|
||||
@@ -1850,7 +1826,6 @@ je_realloc(void *ptr, size_t size)
|
||||
JEMALLOC_EXPORT void JEMALLOC_NOTHROW
|
||||
je_free(void *ptr)
|
||||
{
|
||||
|
||||
UTRACE(ptr, 0, 0);
|
||||
if (likely(ptr != NULL)) {
|
||||
tsd_t *tsd = tsd_fetch();
|
||||
@@ -1959,7 +1934,6 @@ JEMALLOC_ALWAYS_INLINE_C bool
|
||||
imallocx_flags_decode(tsd_t *tsd, size_t size, int flags, size_t *usize,
|
||||
size_t *alignment, bool *zero, tcache_t **tcache, arena_t **arena)
|
||||
{
|
||||
|
||||
if ((flags & MALLOCX_LG_ALIGN_MASK) == 0) {
|
||||
*alignment = 0;
|
||||
*usize = s2u(size);
|
||||
@@ -2641,7 +2615,6 @@ JEMALLOC_ATTR(constructor)
|
||||
static void
|
||||
jemalloc_constructor(void)
|
||||
{
|
||||
|
||||
malloc_init();
|
||||
}
|
||||
#endif
|
||||
|
@@ -70,55 +70,47 @@ newImpl(std::size_t size) noexcept(IsNoExcept)
|
||||
void *
|
||||
operator new(std::size_t size)
|
||||
{
|
||||
|
||||
return (newImpl<false>(size));
|
||||
}
|
||||
|
||||
void *
|
||||
operator new[](std::size_t size)
|
||||
{
|
||||
|
||||
return (newImpl<false>(size));
|
||||
}
|
||||
|
||||
void *
|
||||
operator new(std::size_t size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
|
||||
return (newImpl<true>(size));
|
||||
}
|
||||
|
||||
void *
|
||||
operator new[](std::size_t size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
|
||||
return (newImpl<true>(size));
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* ptr) noexcept
|
||||
{
|
||||
|
||||
je_free(ptr);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete[](void* ptr) noexcept
|
||||
{
|
||||
|
||||
je_free(ptr);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* ptr, const std::nothrow_t&) noexcept
|
||||
{
|
||||
|
||||
je_free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, const std::nothrow_t&) noexcept
|
||||
{
|
||||
|
||||
je_free(ptr);
|
||||
}
|
||||
|
||||
@@ -127,13 +119,11 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept
|
||||
void
|
||||
operator delete(void* ptr, std::size_t size) noexcept
|
||||
{
|
||||
|
||||
je_sdallocx(ptr, size, /*flags=*/0);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, std::size_t size) noexcept
|
||||
{
|
||||
|
||||
je_sdallocx(ptr, size, /*flags=*/0);
|
||||
}
|
||||
|
||||
|
11
src/large.c
11
src/large.c
@@ -6,7 +6,6 @@
|
||||
void *
|
||||
large_malloc(tsdn_t *tsdn, arena_t *arena, size_t usize, bool zero)
|
||||
{
|
||||
|
||||
assert(usize == s2u(usize));
|
||||
|
||||
return (large_palloc(tsdn, arena, usize, CACHELINE, zero));
|
||||
@@ -67,7 +66,6 @@ large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
|
||||
void
|
||||
large_dalloc_junk(void *ptr, size_t usize)
|
||||
{
|
||||
|
||||
memset(ptr, JEMALLOC_FREE_JUNK, usize);
|
||||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
@@ -83,7 +81,6 @@ large_dalloc_junk_t *large_dalloc_junk = JEMALLOC_N(n_large_dalloc_junk);
|
||||
void
|
||||
large_dalloc_maybe_junk(void *ptr, size_t usize)
|
||||
{
|
||||
|
||||
if (config_fill && have_dss && unlikely(opt_junk_free)) {
|
||||
/*
|
||||
* Only bother junk filling if the extent isn't about to be
|
||||
@@ -198,7 +195,6 @@ bool
|
||||
large_ralloc_no_move(tsdn_t *tsdn, extent_t *extent, size_t usize_min,
|
||||
size_t usize_max, bool zero)
|
||||
{
|
||||
|
||||
assert(s2u(extent_usize_get(extent)) == extent_usize_get(extent));
|
||||
/* The following should have been caught by callers. */
|
||||
assert(usize_min > 0 && usize_max <= LARGE_MAXCLASS);
|
||||
@@ -247,7 +243,6 @@ static void *
|
||||
large_ralloc_move_helper(tsdn_t *tsdn, arena_t *arena, size_t usize,
|
||||
size_t alignment, bool zero)
|
||||
{
|
||||
|
||||
if (alignment <= CACHELINE)
|
||||
return (large_malloc(tsdn, arena, usize, zero));
|
||||
return (large_palloc(tsdn, arena, usize, alignment, zero));
|
||||
@@ -314,41 +309,35 @@ large_dalloc_impl(tsdn_t *tsdn, extent_t *extent, bool junked_locked)
|
||||
void
|
||||
large_dalloc_junked_locked(tsdn_t *tsdn, extent_t *extent)
|
||||
{
|
||||
|
||||
large_dalloc_impl(tsdn, extent, true);
|
||||
}
|
||||
|
||||
void
|
||||
large_dalloc(tsdn_t *tsdn, extent_t *extent)
|
||||
{
|
||||
|
||||
large_dalloc_impl(tsdn, extent, false);
|
||||
}
|
||||
|
||||
size_t
|
||||
large_salloc(tsdn_t *tsdn, const extent_t *extent)
|
||||
{
|
||||
|
||||
return (extent_usize_get(extent));
|
||||
}
|
||||
|
||||
prof_tctx_t *
|
||||
large_prof_tctx_get(tsdn_t *tsdn, const extent_t *extent)
|
||||
{
|
||||
|
||||
return (extent_prof_tctx_get(extent));
|
||||
}
|
||||
|
||||
void
|
||||
large_prof_tctx_set(tsdn_t *tsdn, extent_t *extent, prof_tctx_t *tctx)
|
||||
{
|
||||
|
||||
extent_prof_tctx_set(extent, tctx);
|
||||
}
|
||||
|
||||
void
|
||||
large_prof_tctx_reset(tsdn_t *tsdn, extent_t *extent)
|
||||
{
|
||||
|
||||
large_prof_tctx_set(tsdn, extent, (prof_tctx_t *)(uintptr_t)1U);
|
||||
}
|
||||
|
@@ -37,7 +37,6 @@ static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *,
|
||||
static void
|
||||
pthread_create_once(void)
|
||||
{
|
||||
|
||||
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
|
||||
if (pthread_create_fptr == NULL) {
|
||||
malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
|
||||
@@ -71,7 +70,6 @@ JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
|
||||
bool
|
||||
malloc_mutex_init(malloc_mutex_t *mutex, const char *name, witness_rank_t rank)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
# if _WIN32_WINNT >= 0x0600
|
||||
InitializeSRWLock(&mutex->lock);
|
||||
@@ -113,21 +111,18 @@ malloc_mutex_init(malloc_mutex_t *mutex, const char *name, witness_rank_t rank)
|
||||
void
|
||||
malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, mutex);
|
||||
}
|
||||
|
||||
void
|
||||
malloc_mutex_postfork_parent(tsdn_t *tsdn, malloc_mutex_t *mutex)
|
||||
{
|
||||
|
||||
malloc_mutex_unlock(tsdn, mutex);
|
||||
}
|
||||
|
||||
void
|
||||
malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex)
|
||||
{
|
||||
|
||||
#ifdef JEMALLOC_MUTEX_INIT_CB
|
||||
malloc_mutex_unlock(tsdn, mutex);
|
||||
#else
|
||||
@@ -144,7 +139,6 @@ malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex)
|
||||
bool
|
||||
malloc_mutex_boot(void)
|
||||
{
|
||||
|
||||
#ifdef JEMALLOC_MUTEX_INIT_CB
|
||||
postpone_init = false;
|
||||
while (postponed_mutexes != NULL) {
|
||||
|
14
src/nstime.c
14
src/nstime.c
@@ -5,56 +5,48 @@
|
||||
void
|
||||
nstime_init(nstime_t *time, uint64_t ns)
|
||||
{
|
||||
|
||||
time->ns = ns;
|
||||
}
|
||||
|
||||
void
|
||||
nstime_init2(nstime_t *time, uint64_t sec, uint64_t nsec)
|
||||
{
|
||||
|
||||
time->ns = sec * BILLION + nsec;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
nstime_ns(const nstime_t *time)
|
||||
{
|
||||
|
||||
return (time->ns);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
nstime_sec(const nstime_t *time)
|
||||
{
|
||||
|
||||
return (time->ns / BILLION);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
nstime_nsec(const nstime_t *time)
|
||||
{
|
||||
|
||||
return (time->ns % BILLION);
|
||||
}
|
||||
|
||||
void
|
||||
nstime_copy(nstime_t *time, const nstime_t *source)
|
||||
{
|
||||
|
||||
*time = *source;
|
||||
}
|
||||
|
||||
int
|
||||
nstime_compare(const nstime_t *a, const nstime_t *b)
|
||||
{
|
||||
|
||||
return ((a->ns > b->ns) - (a->ns < b->ns));
|
||||
}
|
||||
|
||||
void
|
||||
nstime_add(nstime_t *time, const nstime_t *addend)
|
||||
{
|
||||
|
||||
assert(UINT64_MAX - time->ns >= addend->ns);
|
||||
|
||||
time->ns += addend->ns;
|
||||
@@ -63,7 +55,6 @@ nstime_add(nstime_t *time, const nstime_t *addend)
|
||||
void
|
||||
nstime_subtract(nstime_t *time, const nstime_t *subtrahend)
|
||||
{
|
||||
|
||||
assert(nstime_compare(time, subtrahend) >= 0);
|
||||
|
||||
time->ns -= subtrahend->ns;
|
||||
@@ -72,7 +63,6 @@ nstime_subtract(nstime_t *time, const nstime_t *subtrahend)
|
||||
void
|
||||
nstime_imultiply(nstime_t *time, uint64_t multiplier)
|
||||
{
|
||||
|
||||
assert((((time->ns | multiplier) & (UINT64_MAX << (sizeof(uint64_t) <<
|
||||
2))) == 0) || ((time->ns * multiplier) / multiplier == time->ns));
|
||||
|
||||
@@ -82,7 +72,6 @@ nstime_imultiply(nstime_t *time, uint64_t multiplier)
|
||||
void
|
||||
nstime_idivide(nstime_t *time, uint64_t divisor)
|
||||
{
|
||||
|
||||
assert(divisor != 0);
|
||||
|
||||
time->ns /= divisor;
|
||||
@@ -91,7 +80,6 @@ nstime_idivide(nstime_t *time, uint64_t divisor)
|
||||
uint64_t
|
||||
nstime_divide(const nstime_t *time, const nstime_t *divisor)
|
||||
{
|
||||
|
||||
assert(divisor->ns != 0);
|
||||
|
||||
return (time->ns / divisor->ns);
|
||||
@@ -135,7 +123,6 @@ nstime_get(nstime_t *time)
|
||||
static void
|
||||
nstime_get(nstime_t *time)
|
||||
{
|
||||
|
||||
nstime_init(time, mach_absolute_time());
|
||||
}
|
||||
#else
|
||||
@@ -157,7 +144,6 @@ nstime_get(nstime_t *time)
|
||||
bool
|
||||
nstime_monotonic(void)
|
||||
{
|
||||
|
||||
return (NSTIME_MONOTONIC);
|
||||
#undef NSTIME_MONOTONIC
|
||||
}
|
||||
|
@@ -64,7 +64,6 @@ pages_map(void *addr, size_t size, bool *commit)
|
||||
void
|
||||
pages_unmap(void *addr, size_t size)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
if (VirtualFree(addr, 0, MEM_RELEASE) == 0)
|
||||
#else
|
||||
@@ -121,7 +120,6 @@ pages_trim(void *addr, size_t alloc_size, size_t leadsize, size_t size,
|
||||
static bool
|
||||
pages_commit_impl(void *addr, size_t size, bool commit)
|
||||
{
|
||||
|
||||
if (os_overcommits)
|
||||
return (true);
|
||||
|
||||
@@ -151,21 +149,18 @@ pages_commit_impl(void *addr, size_t size, bool commit)
|
||||
bool
|
||||
pages_commit(void *addr, size_t size)
|
||||
{
|
||||
|
||||
return (pages_commit_impl(addr, size, true));
|
||||
}
|
||||
|
||||
bool
|
||||
pages_decommit(void *addr, size_t size)
|
||||
{
|
||||
|
||||
return (pages_commit_impl(addr, size, false));
|
||||
}
|
||||
|
||||
bool
|
||||
pages_purge_lazy(void *addr, size_t size)
|
||||
{
|
||||
|
||||
if (!pages_can_purge_lazy)
|
||||
return (true);
|
||||
|
||||
@@ -182,7 +177,6 @@ pages_purge_lazy(void *addr, size_t size)
|
||||
bool
|
||||
pages_purge_forced(void *addr, size_t size)
|
||||
{
|
||||
|
||||
if (!pages_can_purge_forced)
|
||||
return (true);
|
||||
|
||||
@@ -196,7 +190,6 @@ pages_purge_forced(void *addr, size_t size)
|
||||
bool
|
||||
pages_huge(void *addr, size_t size)
|
||||
{
|
||||
|
||||
assert(HUGEPAGE_ADDR2BASE(addr) == addr);
|
||||
assert(HUGEPAGE_CEILING(size) == size);
|
||||
|
||||
@@ -210,7 +203,6 @@ pages_huge(void *addr, size_t size)
|
||||
bool
|
||||
pages_nohuge(void *addr, size_t size)
|
||||
{
|
||||
|
||||
assert(HUGEPAGE_ADDR2BASE(addr) == addr);
|
||||
assert(HUGEPAGE_CEILING(size) == size);
|
||||
|
||||
@@ -284,7 +276,6 @@ os_overcommits_proc(void)
|
||||
void
|
||||
pages_boot(void)
|
||||
{
|
||||
|
||||
#ifndef _WIN32
|
||||
mmap_flags = MAP_PRIVATE | MAP_ANON;
|
||||
#endif
|
||||
|
29
src/prof.c
29
src/prof.c
@@ -226,7 +226,6 @@ void
|
||||
prof_malloc_sample_object(tsdn_t *tsdn, extent_t *extent, const void *ptr,
|
||||
size_t usize, prof_tctx_t *tctx)
|
||||
{
|
||||
|
||||
prof_tctx_set(tsdn, extent, ptr, usize, tctx);
|
||||
|
||||
malloc_mutex_lock(tsdn, tctx->tdata->lock);
|
||||
@@ -243,7 +242,6 @@ prof_malloc_sample_object(tsdn_t *tsdn, extent_t *extent, const void *ptr,
|
||||
void
|
||||
prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock);
|
||||
assert(tctx->cnts.curobjs > 0);
|
||||
assert(tctx->cnts.curbytes >= usize);
|
||||
@@ -259,7 +257,6 @@ prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx)
|
||||
void
|
||||
bt_init(prof_bt_t *bt, void **vec)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
bt->vec = vec;
|
||||
@@ -269,7 +266,6 @@ bt_init(prof_bt_t *bt, void **vec)
|
||||
JEMALLOC_INLINE_C void
|
||||
prof_enter(tsd_t *tsd, prof_tdata_t *tdata)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
assert(tdata == prof_tdata_get(tsd, false));
|
||||
|
||||
@@ -284,7 +280,6 @@ prof_enter(tsd_t *tsd, prof_tdata_t *tdata)
|
||||
JEMALLOC_INLINE_C void
|
||||
prof_leave(tsd_t *tsd, prof_tdata_t *tdata)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
assert(tdata == prof_tdata_get(tsd, false));
|
||||
|
||||
@@ -326,7 +321,6 @@ prof_backtrace(prof_bt_t *bt)
|
||||
static _Unwind_Reason_Code
|
||||
prof_unwind_init_callback(struct _Unwind_Context *context, void *arg)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
return (_URC_NO_REASON);
|
||||
@@ -525,7 +519,6 @@ prof_backtrace(prof_bt_t *bt)
|
||||
void
|
||||
prof_backtrace(prof_bt_t *bt)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
not_reached();
|
||||
}
|
||||
@@ -542,7 +535,6 @@ prof_gctx_mutex_choose(void)
|
||||
static malloc_mutex_t *
|
||||
prof_tdata_mutex_choose(uint64_t thr_uid)
|
||||
{
|
||||
|
||||
return (&tdata_locks[thr_uid % PROF_NTDATA_LOCKS]);
|
||||
}
|
||||
|
||||
@@ -576,7 +568,6 @@ static void
|
||||
prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx,
|
||||
prof_tdata_t *tdata)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
/*
|
||||
@@ -612,7 +603,6 @@ prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx,
|
||||
static bool
|
||||
prof_tctx_should_destroy(tsdn_t *tsdn, prof_tctx_t *tctx)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, tctx->tdata->lock);
|
||||
|
||||
if (opt_prof_accum)
|
||||
@@ -627,7 +617,6 @@ prof_tctx_should_destroy(tsdn_t *tsdn, prof_tctx_t *tctx)
|
||||
static bool
|
||||
prof_gctx_should_destroy(prof_gctx_t *gctx)
|
||||
{
|
||||
|
||||
if (opt_prof_accum)
|
||||
return (false);
|
||||
if (!tctx_tree_empty(&gctx->tctxs))
|
||||
@@ -1044,7 +1033,6 @@ prof_dump_printf(bool propagate_err, const char *format, ...)
|
||||
static void
|
||||
prof_tctx_merge_tdata(tsdn_t *tsdn, prof_tctx_t *tctx, prof_tdata_t *tdata)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, tctx->tdata->lock);
|
||||
|
||||
malloc_mutex_lock(tsdn, tctx->gctx->lock);
|
||||
@@ -1077,7 +1065,6 @@ prof_tctx_merge_tdata(tsdn_t *tsdn, prof_tctx_t *tctx, prof_tdata_t *tdata)
|
||||
static void
|
||||
prof_tctx_merge_gctx(tsdn_t *tsdn, prof_tctx_t *tctx, prof_gctx_t *gctx)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, gctx->lock);
|
||||
|
||||
gctx->cnt_summed.curobjs += tctx->dump_cnts.curobjs;
|
||||
@@ -1173,7 +1160,6 @@ label_return:
|
||||
static void
|
||||
prof_dump_gctx_prep(tsdn_t *tsdn, prof_gctx_t *gctx, prof_gctx_tree_t *gctxs)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
malloc_mutex_lock(tsdn, gctx->lock);
|
||||
@@ -1421,7 +1407,6 @@ prof_open_maps(const char *format, ...)
|
||||
static int
|
||||
prof_getpid(void)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
return (GetCurrentProcessId());
|
||||
#else
|
||||
@@ -1491,7 +1476,6 @@ static void
|
||||
prof_leakcheck(const prof_cnt_t *cnt_all, size_t leak_ngctx,
|
||||
const char *filename)
|
||||
{
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
/*
|
||||
* Scaling is equivalent AdjustSamples() in jeprof, but the result may
|
||||
@@ -1640,7 +1624,6 @@ label_open_close_error:
|
||||
static void
|
||||
prof_dump_filename(char *filename, char v, uint64_t vseq)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
if (vseq != VSEQ_INVALID) {
|
||||
@@ -1844,7 +1827,6 @@ prof_tdata_init_impl(tsd_t *tsd, uint64_t thr_uid, uint64_t thr_discrim,
|
||||
prof_tdata_t *
|
||||
prof_tdata_init(tsd_t *tsd)
|
||||
{
|
||||
|
||||
return (prof_tdata_init_impl(tsd, prof_thr_uid_alloc(tsd_tsdn(tsd)), 0,
|
||||
NULL, prof_thread_active_init_get(tsd_tsdn(tsd))));
|
||||
}
|
||||
@@ -1852,7 +1834,6 @@ prof_tdata_init(tsd_t *tsd)
|
||||
static bool
|
||||
prof_tdata_should_destroy_unlocked(prof_tdata_t *tdata, bool even_if_attached)
|
||||
{
|
||||
|
||||
if (tdata->attached && !even_if_attached)
|
||||
return (false);
|
||||
if (ckh_count(&tdata->bt2tctx) != 0)
|
||||
@@ -1864,7 +1845,6 @@ static bool
|
||||
prof_tdata_should_destroy(tsdn_t *tsdn, prof_tdata_t *tdata,
|
||||
bool even_if_attached)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, tdata->lock);
|
||||
|
||||
return (prof_tdata_should_destroy_unlocked(tdata, even_if_attached));
|
||||
@@ -1874,7 +1854,6 @@ static void
|
||||
prof_tdata_destroy_locked(tsd_t *tsd, prof_tdata_t *tdata,
|
||||
bool even_if_attached)
|
||||
{
|
||||
|
||||
malloc_mutex_assert_owner(tsd_tsdn(tsd), &tdatas_mtx);
|
||||
|
||||
tdata_tree_remove(&tdatas, tdata);
|
||||
@@ -1893,7 +1872,6 @@ prof_tdata_destroy_locked(tsd_t *tsd, prof_tdata_t *tdata,
|
||||
static void
|
||||
prof_tdata_destroy(tsd_t *tsd, prof_tdata_t *tdata, bool even_if_attached)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx);
|
||||
prof_tdata_destroy_locked(tsd, tdata, even_if_attached);
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx);
|
||||
@@ -2162,7 +2140,6 @@ prof_gdump_set(tsdn_t *tsdn, bool gdump)
|
||||
void
|
||||
prof_boot0(void)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
memcpy(opt_prof_prefix, PROF_PREFIX_DEFAULT,
|
||||
@@ -2172,7 +2149,6 @@ prof_boot0(void)
|
||||
void
|
||||
prof_boot1(void)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
/*
|
||||
@@ -2198,7 +2174,6 @@ prof_boot1(void)
|
||||
bool
|
||||
prof_boot2(tsd_t *tsd)
|
||||
{
|
||||
|
||||
cassert(config_prof);
|
||||
|
||||
if (opt_prof) {
|
||||
@@ -2292,7 +2267,6 @@ prof_boot2(tsd_t *tsd)
|
||||
void
|
||||
prof_prefork0(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
if (opt_prof) {
|
||||
unsigned i;
|
||||
|
||||
@@ -2309,7 +2283,6 @@ prof_prefork0(tsdn_t *tsdn)
|
||||
void
|
||||
prof_prefork1(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
if (opt_prof) {
|
||||
malloc_mutex_prefork(tsdn, &prof_active_mtx);
|
||||
malloc_mutex_prefork(tsdn, &prof_dump_seq_mtx);
|
||||
@@ -2322,7 +2295,6 @@ prof_prefork1(tsdn_t *tsdn)
|
||||
void
|
||||
prof_postfork_parent(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
if (opt_prof) {
|
||||
unsigned i;
|
||||
|
||||
@@ -2345,7 +2317,6 @@ prof_postfork_parent(tsdn_t *tsdn)
|
||||
void
|
||||
prof_postfork_child(tsdn_t *tsdn)
|
||||
{
|
||||
|
||||
if (opt_prof) {
|
||||
unsigned i;
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
static unsigned
|
||||
hmin(unsigned ha, unsigned hb)
|
||||
{
|
||||
|
||||
return (ha < hb ? ha : hb);
|
||||
}
|
||||
|
||||
@@ -71,7 +70,6 @@ rtree_new(rtree_t *rtree, unsigned bits)
|
||||
static rtree_elm_t *
|
||||
rtree_node_alloc(tsdn_t *tsdn, rtree_t *rtree, size_t nelms)
|
||||
{
|
||||
|
||||
return ((rtree_elm_t *)base_alloc(tsdn, b0get(), nelms *
|
||||
sizeof(rtree_elm_t), CACHELINE));
|
||||
}
|
||||
@@ -88,7 +86,6 @@ rtree_node_alloc_t *rtree_node_alloc = JEMALLOC_N(rtree_node_alloc_impl);
|
||||
UNUSED static void
|
||||
rtree_node_dalloc(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node)
|
||||
{
|
||||
|
||||
/* Nodes are never deleted during normal operation. */
|
||||
not_reached();
|
||||
}
|
||||
@@ -103,7 +100,6 @@ static void
|
||||
rtree_delete_subtree(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node,
|
||||
unsigned level)
|
||||
{
|
||||
|
||||
if (level + 1 < rtree->height) {
|
||||
size_t nchildren, i;
|
||||
|
||||
@@ -157,7 +153,6 @@ rtree_node_init(tsdn_t *tsdn, rtree_t *rtree, unsigned level,
|
||||
rtree_elm_t *
|
||||
rtree_subtree_read_hard(tsdn_t *tsdn, rtree_t *rtree, unsigned level)
|
||||
{
|
||||
|
||||
return (rtree_node_init(tsdn, rtree, level,
|
||||
&rtree->levels[level].subtree));
|
||||
}
|
||||
@@ -166,7 +161,6 @@ rtree_elm_t *
|
||||
rtree_child_read_hard(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *elm,
|
||||
unsigned level)
|
||||
{
|
||||
|
||||
return (rtree_node_init(tsdn, rtree, level+1, &elm->child));
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,6 @@ static tcaches_t *tcaches_avail;
|
||||
size_t
|
||||
tcache_salloc(tsdn_t *tsdn, const void *ptr)
|
||||
{
|
||||
|
||||
return (arena_salloc(tsdn, iealloc(tsdn, ptr), ptr));
|
||||
}
|
||||
|
||||
@@ -249,7 +248,6 @@ tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind,
|
||||
static void
|
||||
tcache_arena_associate(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena)
|
||||
{
|
||||
|
||||
if (config_stats) {
|
||||
/* Link into list of extant tcaches. */
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
@@ -262,7 +260,6 @@ tcache_arena_associate(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena)
|
||||
static void
|
||||
tcache_arena_dissociate(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena)
|
||||
{
|
||||
|
||||
if (config_stats) {
|
||||
/* Unlink from list of extant tcaches. */
|
||||
malloc_mutex_lock(tsdn, &arena->lock);
|
||||
@@ -287,7 +284,6 @@ void
|
||||
tcache_arena_reassociate(tsdn_t *tsdn, tcache_t *tcache, arena_t *oldarena,
|
||||
arena_t *newarena)
|
||||
{
|
||||
|
||||
tcache_arena_dissociate(tsdn, tcache, oldarena);
|
||||
tcache_arena_associate(tsdn, tcache, newarena);
|
||||
}
|
||||
@@ -473,7 +469,6 @@ tcaches_create(tsd_t *tsd, unsigned *r_ind)
|
||||
static void
|
||||
tcaches_elm_flush(tsd_t *tsd, tcaches_t *elm)
|
||||
{
|
||||
|
||||
if (elm->tcache == NULL)
|
||||
return;
|
||||
tcache_destroy(tsd, elm->tcache);
|
||||
@@ -483,7 +478,6 @@ tcaches_elm_flush(tsd_t *tsd, tcaches_t *elm)
|
||||
void
|
||||
tcaches_flush(tsd_t *tsd, unsigned ind)
|
||||
{
|
||||
|
||||
tcaches_elm_flush(tsd, &tcaches[ind]);
|
||||
}
|
||||
|
||||
|
@@ -14,21 +14,18 @@ malloc_tsd_data(, , tsd_t, TSD_INITIALIZER)
|
||||
void *
|
||||
malloc_tsd_malloc(size_t size)
|
||||
{
|
||||
|
||||
return (a0malloc(CACHELINE_CEILING(size)));
|
||||
}
|
||||
|
||||
void
|
||||
malloc_tsd_dalloc(void *wrapper)
|
||||
{
|
||||
|
||||
a0dalloc(wrapper);
|
||||
}
|
||||
|
||||
void
|
||||
malloc_tsd_no_cleanup(void *arg)
|
||||
{
|
||||
|
||||
not_reached();
|
||||
}
|
||||
|
||||
@@ -61,7 +58,6 @@ _malloc_thread_cleanup(void)
|
||||
void
|
||||
malloc_tsd_cleanup_register(bool (*f)(void))
|
||||
{
|
||||
|
||||
assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX);
|
||||
cleanups[ncleanups] = f;
|
||||
ncleanups++;
|
||||
@@ -127,7 +123,6 @@ malloc_tsd_boot0(void)
|
||||
void
|
||||
malloc_tsd_boot1(void)
|
||||
{
|
||||
|
||||
tsd_boot1();
|
||||
*tsd_arenas_tdata_bypassp_get(tsd_fetch()) = false;
|
||||
}
|
||||
@@ -136,7 +131,6 @@ malloc_tsd_boot1(void)
|
||||
static BOOL WINAPI
|
||||
_tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
|
||||
switch (fdwReason) {
|
||||
#ifdef JEMALLOC_LAZY_LOCK
|
||||
case DLL_THREAD_ATTACH:
|
||||
@@ -194,7 +188,6 @@ tsd_init_check_recursion(tsd_init_head_t *head, tsd_init_block_t *block)
|
||||
void
|
||||
tsd_init_finish(tsd_init_head_t *head, tsd_init_block_t *block)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(TSDN_NULL, &head->lock);
|
||||
ql_remove(&head->blocks, block, link);
|
||||
malloc_mutex_unlock(TSDN_NULL, &head->lock);
|
||||
|
@@ -48,7 +48,6 @@ static char *x2s(uintmax_t x, bool alt_form, bool uppercase, char *s,
|
||||
static void
|
||||
wrtmessage(void *cbopaque, const char *s)
|
||||
{
|
||||
|
||||
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_write)
|
||||
/*
|
||||
* Use syscall(2) rather than write(2) when possible in order to avoid
|
||||
@@ -74,7 +73,6 @@ JEMALLOC_EXPORT void (*je_malloc_message)(void *, const char *s);
|
||||
void
|
||||
malloc_write(const char *s)
|
||||
{
|
||||
|
||||
if (je_malloc_message != NULL)
|
||||
je_malloc_message(NULL, s);
|
||||
else
|
||||
@@ -88,7 +86,6 @@ malloc_write(const char *s)
|
||||
int
|
||||
buferror(int err, char *buf, size_t buflen)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
|
||||
(LPSTR)buf, (DWORD)buflen, NULL);
|
||||
@@ -292,7 +289,6 @@ d2s(intmax_t x, char sign, char *s, size_t *slen_p)
|
||||
static char *
|
||||
o2s(uintmax_t x, bool alt_form, char *s, size_t *slen_p)
|
||||
{
|
||||
|
||||
s = u2s(x, 8, false, s, slen_p);
|
||||
if (alt_form && *s != '0') {
|
||||
s--;
|
||||
@@ -305,7 +301,6 @@ o2s(uintmax_t x, bool alt_form, char *s, size_t *slen_p)
|
||||
static char *
|
||||
x2s(uintmax_t x, bool alt_form, bool uppercase, char *s, size_t *slen_p)
|
||||
{
|
||||
|
||||
s = u2s(x, 16, uppercase, s, slen_p);
|
||||
if (alt_form) {
|
||||
s -= 2;
|
||||
|
@@ -5,7 +5,6 @@ void
|
||||
witness_init(witness_t *witness, const char *name, witness_rank_t rank,
|
||||
witness_comp_t *comp, void *opaque)
|
||||
{
|
||||
|
||||
witness->name = name;
|
||||
witness->rank = rank;
|
||||
witness->comp = comp;
|
||||
@@ -41,7 +40,6 @@ witness_lock_error_t *witness_lock_error = JEMALLOC_N(n_witness_lock_error);
|
||||
void
|
||||
witness_owner_error(const witness_t *witness)
|
||||
{
|
||||
|
||||
malloc_printf("<jemalloc>: Should own %s(%u)\n", witness->name,
|
||||
witness->rank);
|
||||
abort();
|
||||
@@ -59,7 +57,6 @@ witness_owner_error_t *witness_owner_error = JEMALLOC_N(n_witness_owner_error);
|
||||
void
|
||||
witness_not_owner_error(const witness_t *witness)
|
||||
{
|
||||
|
||||
malloc_printf("<jemalloc>: Should not own %s(%u)\n", witness->name,
|
||||
witness->rank);
|
||||
abort();
|
||||
@@ -97,7 +94,6 @@ witness_lockless_error_t *witness_lockless_error =
|
||||
void
|
||||
witnesses_cleanup(tsd_t *tsd)
|
||||
{
|
||||
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
|
||||
/* Do nothing. */
|
||||
@@ -106,14 +102,12 @@ witnesses_cleanup(tsd_t *tsd)
|
||||
void
|
||||
witness_prefork(tsd_t *tsd)
|
||||
{
|
||||
|
||||
tsd_witness_fork_set(tsd, true);
|
||||
}
|
||||
|
||||
void
|
||||
witness_postfork_parent(tsd_t *tsd)
|
||||
{
|
||||
|
||||
tsd_witness_fork_set(tsd, false);
|
||||
}
|
||||
|
||||
|
11
src/zone.c
11
src/zone.c
@@ -47,7 +47,6 @@ static void zone_force_unlock(malloc_zone_t *zone);
|
||||
static size_t
|
||||
zone_size(malloc_zone_t *zone, void *ptr)
|
||||
{
|
||||
|
||||
/*
|
||||
* There appear to be places within Darwin (such as setenv(3)) that
|
||||
* cause calls to this function with pointers that *no* zone owns. If
|
||||
@@ -63,14 +62,12 @@ zone_size(malloc_zone_t *zone, void *ptr)
|
||||
static void *
|
||||
zone_malloc(malloc_zone_t *zone, size_t size)
|
||||
{
|
||||
|
||||
return (je_malloc(size));
|
||||
}
|
||||
|
||||
static void *
|
||||
zone_calloc(malloc_zone_t *zone, size_t num, size_t size)
|
||||
{
|
||||
|
||||
return (je_calloc(num, size));
|
||||
}
|
||||
|
||||
@@ -87,7 +84,6 @@ zone_valloc(malloc_zone_t *zone, size_t size)
|
||||
static void
|
||||
zone_free(malloc_zone_t *zone, void *ptr)
|
||||
{
|
||||
|
||||
if (ivsalloc(tsdn_fetch(), ptr) != 0) {
|
||||
je_free(ptr);
|
||||
return;
|
||||
@@ -99,7 +95,6 @@ zone_free(malloc_zone_t *zone, void *ptr)
|
||||
static void *
|
||||
zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
|
||||
{
|
||||
|
||||
if (ivsalloc(tsdn_fetch(), ptr) != 0)
|
||||
return (je_realloc(ptr, size));
|
||||
|
||||
@@ -138,7 +133,6 @@ zone_free_definite_size(malloc_zone_t *zone, void *ptr, size_t size)
|
||||
static void *
|
||||
zone_destroy(malloc_zone_t *zone)
|
||||
{
|
||||
|
||||
/* This function should never be called. */
|
||||
not_reached();
|
||||
return (NULL);
|
||||
@@ -147,7 +141,6 @@ zone_destroy(malloc_zone_t *zone)
|
||||
static size_t
|
||||
zone_good_size(malloc_zone_t *zone, size_t size)
|
||||
{
|
||||
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
return (s2u(size));
|
||||
@@ -156,7 +149,6 @@ zone_good_size(malloc_zone_t *zone, size_t size)
|
||||
static void
|
||||
zone_force_lock(malloc_zone_t *zone)
|
||||
{
|
||||
|
||||
if (isthreaded)
|
||||
jemalloc_prefork();
|
||||
}
|
||||
@@ -164,7 +156,6 @@ zone_force_lock(malloc_zone_t *zone)
|
||||
static void
|
||||
zone_force_unlock(malloc_zone_t *zone)
|
||||
{
|
||||
|
||||
/*
|
||||
* Call jemalloc_postfork_child() rather than
|
||||
* jemalloc_postfork_parent(), because this function is executed by both
|
||||
@@ -179,7 +170,6 @@ zone_force_unlock(malloc_zone_t *zone)
|
||||
static void
|
||||
zone_init(void)
|
||||
{
|
||||
|
||||
jemalloc_zone.size = (void *)zone_size;
|
||||
jemalloc_zone.malloc = (void *)zone_malloc;
|
||||
jemalloc_zone.calloc = (void *)zone_calloc;
|
||||
@@ -297,7 +287,6 @@ JEMALLOC_ATTR(constructor)
|
||||
void
|
||||
zone_register(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* If something else replaced the system default zone allocator, don't
|
||||
* register jemalloc's.
|
||||
|
Reference in New Issue
Block a user