Remove binind field from arena_slab_data_t.
binind is now redundant; the containing extent_t's szind field always provides the same value.
This commit is contained in:
parent
e8921cf2eb
commit
f50d6009fe
@ -117,17 +117,9 @@ arena_aalloc(tsdn_t *tsdn, const void *ptr) {
|
|||||||
/* Return the size of the allocation pointed to by ptr. */
|
/* Return the size of the allocation pointed to by ptr. */
|
||||||
JEMALLOC_ALWAYS_INLINE size_t
|
JEMALLOC_ALWAYS_INLINE size_t
|
||||||
arena_salloc(tsdn_t *tsdn, const extent_t *extent, const void *ptr) {
|
arena_salloc(tsdn_t *tsdn, const extent_t *extent, const void *ptr) {
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
assert(ptr != NULL);
|
assert(ptr != NULL);
|
||||||
|
|
||||||
if (likely(extent_slab_get(extent))) {
|
return index2size(extent_szind_get(extent));
|
||||||
ret = index2size(extent_slab_data_get_const(extent)->binind);
|
|
||||||
} else {
|
|
||||||
ret = large_salloc(tsdn, extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE void
|
JEMALLOC_ALWAYS_INLINE void
|
||||||
@ -136,19 +128,17 @@ arena_dalloc(tsdn_t *tsdn, extent_t *extent, void *ptr, tcache_t *tcache,
|
|||||||
assert(!tsdn_null(tsdn) || tcache == NULL);
|
assert(!tsdn_null(tsdn) || tcache == NULL);
|
||||||
assert(ptr != NULL);
|
assert(ptr != NULL);
|
||||||
|
|
||||||
|
szind_t szind = extent_szind_get(extent);
|
||||||
if (likely(extent_slab_get(extent))) {
|
if (likely(extent_slab_get(extent))) {
|
||||||
/* Small allocation. */
|
/* Small allocation. */
|
||||||
if (likely(tcache != NULL)) {
|
if (likely(tcache != NULL)) {
|
||||||
szind_t binind = extent_slab_data_get(extent)->binind;
|
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
|
||||||
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, binind,
|
|
||||||
slow_path);
|
slow_path);
|
||||||
} else {
|
} else {
|
||||||
arena_dalloc_small(tsdn, extent_arena_get(extent),
|
arena_dalloc_small(tsdn, extent_arena_get(extent),
|
||||||
extent, ptr);
|
extent, ptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
szind_t szind = extent_szind_get(extent);
|
|
||||||
|
|
||||||
if (likely(tcache != NULL) && szind < nhbins) {
|
if (likely(tcache != NULL) && szind < nhbins) {
|
||||||
if (config_prof && unlikely(szind < NBINS)) {
|
if (config_prof && unlikely(szind < NBINS)) {
|
||||||
arena_dalloc_promoted(tsdn, extent, ptr,
|
arena_dalloc_promoted(tsdn, extent, ptr,
|
||||||
@ -173,7 +163,6 @@ arena_sdalloc(tsdn_t *tsdn, extent_t *extent, void *ptr, size_t size,
|
|||||||
if (likely(extent_slab_get(extent))) {
|
if (likely(extent_slab_get(extent))) {
|
||||||
/* Small allocation. */
|
/* Small allocation. */
|
||||||
if (likely(tcache != NULL)) {
|
if (likely(tcache != NULL)) {
|
||||||
assert(szind == extent_slab_data_get(extent)->binind);
|
|
||||||
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
|
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
|
||||||
slow_path);
|
slow_path);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
#define JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H
|
#define JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H
|
||||||
|
|
||||||
struct arena_slab_data_s {
|
struct arena_slab_data_s {
|
||||||
/* Index of bin this slab is associated with. */
|
|
||||||
szind_t binind;
|
|
||||||
|
|
||||||
/* Number of free regions in slab. */
|
/* Number of free regions in slab. */
|
||||||
unsigned nfree;
|
unsigned nfree;
|
||||||
|
|
||||||
|
10
src/arena.c
10
src/arena.c
@ -384,7 +384,7 @@ arena_slab_regind(extent_t *slab, szind_t binind, const void *ptr) {
|
|||||||
JEMALLOC_INLINE_C void
|
JEMALLOC_INLINE_C void
|
||||||
arena_slab_reg_dalloc(tsdn_t *tsdn, extent_t *slab,
|
arena_slab_reg_dalloc(tsdn_t *tsdn, extent_t *slab,
|
||||||
arena_slab_data_t *slab_data, void *ptr) {
|
arena_slab_data_t *slab_data, void *ptr) {
|
||||||
szind_t binind = slab_data->binind;
|
szind_t binind = extent_szind_get(slab);
|
||||||
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
||||||
size_t regind = arena_slab_regind(slab, binind, ptr);
|
size_t regind = arena_slab_regind(slab, binind, ptr);
|
||||||
|
|
||||||
@ -1181,7 +1181,6 @@ arena_slab_alloc(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
|||||||
|
|
||||||
/* Initialize slab internals. */
|
/* Initialize slab internals. */
|
||||||
arena_slab_data_t *slab_data = extent_slab_data_get(slab);
|
arena_slab_data_t *slab_data = extent_slab_data_get(slab);
|
||||||
slab_data->binind = binind;
|
|
||||||
slab_data->nfree = bin_info->nregs;
|
slab_data->nfree = bin_info->nregs;
|
||||||
bitmap_init(slab_data->bitmap, &bin_info->bitmap_info);
|
bitmap_init(slab_data->bitmap, &bin_info->bitmap_info);
|
||||||
|
|
||||||
@ -1511,7 +1510,7 @@ arena_dissociate_bin_slab(extent_t *slab, arena_bin_t *bin) {
|
|||||||
if (slab == bin->slabcur) {
|
if (slab == bin->slabcur) {
|
||||||
bin->slabcur = NULL;
|
bin->slabcur = NULL;
|
||||||
} else {
|
} else {
|
||||||
szind_t binind = extent_slab_data_get(slab)->binind;
|
szind_t binind = extent_szind_get(slab);
|
||||||
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1573,7 +1572,7 @@ static void
|
|||||||
arena_dalloc_bin_locked_impl(tsdn_t *tsdn, arena_t *arena, extent_t *slab,
|
arena_dalloc_bin_locked_impl(tsdn_t *tsdn, arena_t *arena, extent_t *slab,
|
||||||
void *ptr, bool junked) {
|
void *ptr, bool junked) {
|
||||||
arena_slab_data_t *slab_data = extent_slab_data_get(slab);
|
arena_slab_data_t *slab_data = extent_slab_data_get(slab);
|
||||||
szind_t binind = slab_data->binind;
|
szind_t binind = extent_szind_get(slab);
|
||||||
arena_bin_t *bin = &arena->bins[binind];
|
arena_bin_t *bin = &arena->bins[binind];
|
||||||
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
||||||
|
|
||||||
@ -1604,7 +1603,8 @@ arena_dalloc_bin_junked_locked(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
arena_dalloc_bin(tsdn_t *tsdn, arena_t *arena, extent_t *extent, void *ptr) {
|
arena_dalloc_bin(tsdn_t *tsdn, arena_t *arena, extent_t *extent, void *ptr) {
|
||||||
arena_bin_t *bin = &arena->bins[extent_slab_data_get(extent)->binind];
|
szind_t binind = extent_szind_get(extent);
|
||||||
|
arena_bin_t *bin = &arena->bins[binind];
|
||||||
|
|
||||||
malloc_mutex_lock(tsdn, &bin->lock);
|
malloc_mutex_lock(tsdn, &bin->lock);
|
||||||
arena_dalloc_bin_locked_impl(tsdn, arena, extent, ptr, false);
|
arena_dalloc_bin_locked_impl(tsdn, arena, extent, ptr, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user