e8921cf2eb
Rather than storing usize only for large (and prof-promoted) allocations, store the size class index for allocations that reside within the extent, such that the size class index is valid for all extents that contain extant allocations, and invalid otherwise (mainly to make debugging simpler).
33 lines
906 B
C
33 lines
906 B
C
#include "test/jemalloc_test.h"
|
|
|
|
TEST_BEGIN(test_arena_slab_regind) {
|
|
szind_t binind;
|
|
|
|
for (binind = 0; binind < NBINS; binind++) {
|
|
size_t regind;
|
|
extent_t slab;
|
|
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
|
extent_init(&slab, NULL, mallocx(bin_info->slab_size,
|
|
MALLOCX_LG_ALIGN(LG_PAGE)), bin_info->slab_size, true,
|
|
binind, 0, extent_state_active, false, true);
|
|
assert_ptr_not_null(extent_addr_get(&slab),
|
|
"Unexpected malloc() failure");
|
|
for (regind = 0; regind < bin_info->nregs; regind++) {
|
|
void *reg = (void *)((uintptr_t)extent_addr_get(&slab) +
|
|
(bin_info->reg_size * regind));
|
|
assert_zu_eq(arena_slab_regind(&slab, binind, reg),
|
|
regind,
|
|
"Incorrect region index computed for size %zu",
|
|
bin_info->reg_size);
|
|
}
|
|
free(extent_addr_get(&slab));
|
|
}
|
|
}
|
|
TEST_END
|
|
|
|
int
|
|
main(void) {
|
|
return test(
|
|
test_arena_slab_regind);
|
|
}
|