mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 13:13:06 +00:00
Hide bin slab-locality query behind arena_locality_hint
bin_t is an arena implementation detail; tcache should not reach into it. Extract the slab-address lookup into bin.c as bin_current_slab_addr, and expose it to tcache only through arena_locality_hint(tsdn, arena, szind), which composes bin_choose + bin_current_slab_addr.
This commit is contained in:
13
src/bin.c
13
src/bin.c
@@ -330,3 +330,16 @@ bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||
}
|
||||
return arena_get_bin(arena, binind, binshard);
|
||||
}
|
||||
|
||||
void *
|
||||
bin_current_slab_addr(tsdn_t *tsdn, bin_t *bin) {
|
||||
malloc_mutex_lock(tsdn, &bin->lock);
|
||||
edata_t *slab = (bin->slabcur != NULL)
|
||||
? bin->slabcur
|
||||
: edata_heap_first(&bin->slabs_nonfull);
|
||||
assert(slab != NULL || edata_heap_empty(&bin->slabs_nonfull));
|
||||
void *ret = (slab != NULL) ? edata_addr_get(slab) : NULL;
|
||||
assert(ret != NULL || slab == NULL);
|
||||
malloc_mutex_unlock(tsdn, &bin->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user