localalloc::dealloc tweak size math for large objects

Avoid computing bits::next_pow2_bits(1 << n).  Even if the compiler can see
through enough of the algebra, it's surely more direct to just use n.

While here, slightly expand documentation about what's going on with the
"sizeclass" encoded into MetaEntry-s.
This commit is contained in:
Nathaniel Wesley Filardo
2021-10-17 18:03:39 +01:00
committed by Nathaniel Wesley Filardo
parent 52a4b0c8d0
commit 554db3997d
4 changed files with 40 additions and 5 deletions

View File

@@ -165,6 +165,16 @@ namespace snmalloc
return bits::one_at_bit(MIN_CHUNK_BITS + sizeclass);
}
/**
* For large allocations, the metaentry stores the raw log_2 of the size,
* which must be shifted into the index space of slab_sizeclass-es.
*/
inline static size_t
metaentry_chunk_sizeclass_to_slab_sizeclass(sizeclass_t sizeclass)
{
return sizeclass - MIN_CHUNK_BITS;
}
inline constexpr static uint16_t
sizeclass_to_slab_object_count(sizeclass_t sizeclass)
{