From f4e31eb86b7c9f691a3f04e51378ae9f5c98ff6d Mon Sep 17 00:00:00 2001 From: Slobodan Predolac Date: Tue, 26 May 2026 16:52:56 -0700 Subject: [PATCH] Remove cache bin dead stores --- include/jemalloc/internal/cache_bin.h | 3 +-- src/cache_bin.c | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/jemalloc/internal/cache_bin.h b/include/jemalloc/internal/cache_bin.h index 3a7a927d..e80b6a73 100644 --- a/include/jemalloc/internal/cache_bin.h +++ b/include/jemalloc/internal/cache_bin.h @@ -523,14 +523,13 @@ cache_bin_stash(cache_bin_t *bin, void *ptr) { /* Get the number of stashed pointers. */ JEMALLOC_ALWAYS_INLINE cache_bin_sz_t cache_bin_nstashed_get_internal(cache_bin_t *bin) { - cache_bin_sz_t ncached_max = cache_bin_ncached_max_get(bin); cache_bin_sz_t low_bits_low_bound = cache_bin_low_bits_low_bound_get( bin); cache_bin_sz_t n = cache_bin_diff( bin, low_bits_low_bound, bin->low_bits_full) / sizeof(void *); - assert(n <= ncached_max); + assert(n <= cache_bin_ncached_max_get(bin)); if (config_debug && n != 0) { /* Below are for assertions only. */ void **low_bound = cache_bin_low_bound_get(bin); diff --git a/src/cache_bin.c b/src/cache_bin.c index ec677948..d12ce05f 100644 --- a/src/cache_bin.c +++ b/src/cache_bin.c @@ -10,8 +10,8 @@ const uintptr_t disabled_bin = JUNK_ADDR; void cache_bin_info_init(cache_bin_info_t *info, cache_bin_sz_t ncached_max) { assert(ncached_max <= CACHE_BIN_NCACHED_MAX); - size_t stack_size = (size_t)ncached_max * sizeof(void *); - assert(stack_size < ((size_t)1 << (sizeof(cache_bin_sz_t) * 8))); + assert((size_t)ncached_max * sizeof(void *) + < ((size_t)1 << (sizeof(cache_bin_sz_t) * 8))); info->ncached_max = (cache_bin_sz_t)ncached_max; } @@ -94,9 +94,8 @@ cache_bin_init(cache_bin_t *bin, const cache_bin_info_t *info, void *alloc, bin->low_bits_full = (cache_bin_sz_t)(uintptr_t)full_position; bin->low_bits_empty = (cache_bin_sz_t)(uintptr_t)empty_position; cache_bin_info_init(&bin->bin_info, info->ncached_max); - cache_bin_sz_t free_spots = cache_bin_diff(bin, bin->low_bits_full, - (cache_bin_sz_t)(uintptr_t)bin->stack_head); - assert(free_spots == bin_stack_size); + assert(cache_bin_diff(bin, bin->low_bits_full, + (cache_bin_sz_t)(uintptr_t)bin->stack_head) == bin_stack_size); if (!cache_bin_disabled(bin)) { assert(cache_bin_ncached_get_local(bin) == 0); }