From bf742cef84694c2fbbe1ffd96777eab59a618ef6 Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Mon, 14 Dec 2020 18:38:52 +0000 Subject: [PATCH] handle_dealloc_remote{,_slow}: use Remote's sizeclass information This removes a bunch of pointer math (which would need amplification) to find and read the sizeclass from slab headers. --- src/mem/alloc.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/mem/alloc.h b/src/mem/alloc.h index efaba52..a65df5b 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -875,11 +875,9 @@ namespace snmalloc #endif if (likely(super->get_kind() == Super)) { - Slab* slab = Metaslab::get_slab(p); - Metaslab& meta = super->get_meta(slab); if (likely(super->get_allocator() == public_state())) { - small_dealloc_offseted(super, p, meta.sizeclass); + small_dealloc_offseted(super, p, p->sizeclass()); return; } } @@ -891,27 +889,23 @@ namespace snmalloc Superslab* super = Superslab::get(p); if (likely(super->get_kind() == Medium)) { - Mediumslab* slab = Mediumslab::get(p); if (likely(super->get_allocator() == public_state())) { - sizeclass_t sizeclass = slab->get_sizeclass(); - void* start = remove_cache_friendly_offset(p, sizeclass); - medium_dealloc(slab, start, sizeclass); + void* start = remove_cache_friendly_offset(p, p->sizeclass()); + medium_dealloc(Mediumslab::get(p), start, p->sizeclass()); } else { // Queue for remote dealloc elsewhere. - remote.dealloc(p->trunc_target_id(), p, slab->get_sizeclass()); + remote.dealloc(p->trunc_target_id(), p, p->sizeclass()); } } else { SNMALLOC_ASSERT(likely(p->trunc_target_id() != get_trunc_id())); SNMALLOC_ASSERT(likely(super->get_allocator() != public_state())); - Slab* slab = Metaslab::get_slab(p); - Metaslab& meta = super->get_meta(slab); // Queue for remote dealloc elsewhere. - remote.dealloc(p->trunc_target_id(), p, meta.sizeclass); + remote.dealloc(p->trunc_target_id(), p, p->sizeclass()); } }