mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Cache bin: Only take the relevant cache_bin_info_t
Previously, we took an array of cache_bin_info_ts and an index, and dereferenced ourselves. But infos for other cache_bins aren't relevant to any particular cache bin, so that should be the caller's job.
This commit is contained in:
committed by
David Goldblatt
parent
1b00d808d7
commit
e1dcc557d6
30
src/tcache.c
30
src/tcache.c
@@ -59,10 +59,10 @@ tcache_event_hard(tsd_t *tsd, tcache_t *tcache) {
|
||||
is_small = false;
|
||||
}
|
||||
|
||||
cache_bin_sz_t low_water = cache_bin_low_water_get(tbin, binind,
|
||||
tcache_bin_info);
|
||||
cache_bin_sz_t ncached = cache_bin_ncached_get(tbin, binind,
|
||||
tcache_bin_info);
|
||||
cache_bin_sz_t low_water = cache_bin_low_water_get(tbin,
|
||||
&tcache_bin_info[binind]);
|
||||
cache_bin_sz_t ncached = cache_bin_ncached_get(tbin,
|
||||
&tcache_bin_info[binind]);
|
||||
if (low_water > 0) {
|
||||
/*
|
||||
* Flush (ceiling) 3/4 of the objects below the low water mark.
|
||||
@@ -110,8 +110,8 @@ tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,
|
||||
|
||||
assert(tcache->arena != NULL);
|
||||
arena_tcache_fill_small(tsdn, arena, tcache, tbin, binind);
|
||||
ret = cache_bin_alloc_easy(tbin, tcache_success, binind,
|
||||
tcache_bin_info);
|
||||
ret = cache_bin_alloc_easy(tbin, tcache_success,
|
||||
&tcache_bin_info[binind]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -168,8 +168,8 @@ tcache_bin_flush_impl(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
|
||||
} else {
|
||||
assert(binind < nhbins);
|
||||
}
|
||||
cache_bin_sz_t ncached = cache_bin_ncached_get(tbin, binind,
|
||||
tcache_bin_info);
|
||||
cache_bin_sz_t ncached = cache_bin_ncached_get(tbin,
|
||||
&tcache_bin_info[binind]);
|
||||
assert((cache_bin_sz_t)rem <= ncached);
|
||||
arena_t *tcache_arena = tcache->arena;
|
||||
assert(tcache_arena != NULL);
|
||||
@@ -182,8 +182,8 @@ tcache_bin_flush_impl(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
|
||||
VARIABLE_ARRAY(edata_t *, item_edata, nflush + 1);
|
||||
CACHE_BIN_PTR_ARRAY_DECLARE(ptrs, nflush);
|
||||
|
||||
cache_bin_ptr_array_init_for_flush(&ptrs, tbin, nflush, binind,
|
||||
tcache_bin_info);
|
||||
cache_bin_ptr_array_init_for_flush(&ptrs, tbin, nflush,
|
||||
&tcache_bin_info[binind]);
|
||||
|
||||
/* Look up edata once per item. */
|
||||
if (config_opt_safety_checks) {
|
||||
@@ -348,7 +348,7 @@ tcache_bin_flush_impl(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
|
||||
|
||||
memmove(tbin->cur_ptr.ptr + (ncached - rem), tbin->cur_ptr.ptr, rem *
|
||||
sizeof(void *));
|
||||
cache_bin_ncached_set(tbin, binind, rem, tcache_bin_info);
|
||||
cache_bin_ncached_set(tbin, rem, &tcache_bin_info[binind]);
|
||||
if (tbin->cur_ptr.lowbits > tbin->low_water_position) {
|
||||
tbin->low_water_position = tbin->cur_ptr.lowbits;
|
||||
}
|
||||
@@ -453,8 +453,8 @@ tcache_bin_init(cache_bin_t *bin, szind_t ind, uintptr_t *stack_cur) {
|
||||
bin->low_water_position = bin->cur_ptr.lowbits;
|
||||
bin->full_position = (uint32_t)(uintptr_t)full_position;
|
||||
assert(bin->cur_ptr.lowbits - bin->full_position == bin_stack_size);
|
||||
assert(cache_bin_ncached_get(bin, ind, tcache_bin_info) == 0);
|
||||
assert(cache_bin_empty_position_get(bin, ind, tcache_bin_info)
|
||||
assert(cache_bin_ncached_get(bin, &tcache_bin_info[ind]) == 0);
|
||||
assert(cache_bin_empty_position_get(bin, &tcache_bin_info[ind])
|
||||
== empty_position);
|
||||
|
||||
return false;
|
||||
@@ -614,8 +614,8 @@ tcache_destroy(tsd_t *tsd, tcache_t *tcache, bool tsd_tcache) {
|
||||
if (tsd_tcache) {
|
||||
/* Release the avail array for the TSD embedded auto tcache. */
|
||||
cache_bin_t *bin = tcache_small_bin_get(tcache, 0);
|
||||
assert(cache_bin_ncached_get(bin, 0, tcache_bin_info) == 0);
|
||||
assert(cache_bin_empty_position_get(bin, 0, tcache_bin_info) ==
|
||||
assert(cache_bin_ncached_get(bin, &tcache_bin_info[0]) == 0);
|
||||
assert(cache_bin_empty_position_get(bin, &tcache_bin_info[0]) ==
|
||||
bin->cur_ptr.ptr);
|
||||
void *avail_array = (void *)((uintptr_t)bin->cur_ptr.ptr -
|
||||
tcache_bin_info[0].stack_size);
|
||||
|
||||
Reference in New Issue
Block a user