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:
committed by
Nathaniel Wesley Filardo
parent
52a4b0c8d0
commit
554db3997d
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user