Move all decommit strategy into LargeAllocator
The code for decommit was distribured in the code base. Removing Decommit All means that it can logically reside in lthe arge allocator.
This commit is contained in:
@@ -1111,20 +1111,6 @@ namespace snmalloc
|
||||
{
|
||||
super_available.remove(super);
|
||||
|
||||
if constexpr (decommit_strategy == DecommitSuper)
|
||||
{
|
||||
large_allocator.memory_provider.notify_not_using(
|
||||
pointer_offset(super, OS_PAGE_SIZE),
|
||||
SUPERSLAB_SIZE - OS_PAGE_SIZE);
|
||||
}
|
||||
else if constexpr (decommit_strategy == DecommitSuperLazy)
|
||||
{
|
||||
static_assert(
|
||||
pal_supports<LowMemoryNotification, MemoryProvider>,
|
||||
"A lazy decommit strategy cannot be implemented on platforms "
|
||||
"without low memory notifications");
|
||||
}
|
||||
|
||||
chunkmap().clear_slab(super);
|
||||
large_allocator.dealloc(super, 0);
|
||||
stats().superslab_push();
|
||||
@@ -1208,12 +1194,6 @@ namespace snmalloc
|
||||
sc->remove(slab);
|
||||
}
|
||||
|
||||
if constexpr (decommit_strategy == DecommitSuper)
|
||||
{
|
||||
large_allocator.memory_provider.notify_not_using(
|
||||
pointer_offset(slab, OS_PAGE_SIZE), SUPERSLAB_SIZE - OS_PAGE_SIZE);
|
||||
}
|
||||
|
||||
chunkmap().clear_slab(slab);
|
||||
large_allocator.dealloc(slab, 0);
|
||||
stats().superslab_push();
|
||||
@@ -1261,19 +1241,13 @@ namespace snmalloc
|
||||
MEASURE_TIME(large_dealloc, 4, 16);
|
||||
|
||||
size_t size_bits = bits::next_pow2_bits(size);
|
||||
size_t rsize = bits::one_at_bit(size_bits);
|
||||
assert(rsize >= SUPERSLAB_SIZE);
|
||||
assert(bits::one_at_bit(size_bits) >= SUPERSLAB_SIZE);
|
||||
size_t large_class = size_bits - SUPERSLAB_BITS;
|
||||
|
||||
chunkmap().clear_large_size(p, size);
|
||||
|
||||
stats().large_dealloc(large_class);
|
||||
|
||||
// Cross-reference largealloc's alloc() decommitted condition.
|
||||
if ((decommit_strategy != DecommitNone) || (large_class > 0))
|
||||
large_allocator.memory_provider.notify_not_using(
|
||||
pointer_offset(p, OS_PAGE_SIZE), rsize - OS_PAGE_SIZE);
|
||||
|
||||
// Initialise in order to set the correct SlabKind.
|
||||
Largeslab* slab = static_cast<Largeslab*>(p);
|
||||
slab->init();
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace snmalloc
|
||||
bool decommitted =
|
||||
((decommit_strategy == DecommitSuperLazy) &&
|
||||
(static_cast<Baseslab*>(p)->get_kind() == Decommitted)) ||
|
||||
(large_class > 0) || (decommit_strategy != DecommitNone);
|
||||
(large_class > 0) || (decommit_strategy == DecommitSuper);
|
||||
|
||||
if (decommitted)
|
||||
{
|
||||
@@ -392,6 +392,24 @@ namespace snmalloc
|
||||
|
||||
void dealloc(void* p, size_t large_class)
|
||||
{
|
||||
if constexpr (decommit_strategy == DecommitSuperLazy)
|
||||
{
|
||||
static_assert(
|
||||
pal_supports<LowMemoryNotification, MemoryProvider>,
|
||||
"A lazy decommit strategy cannot be implemented on platforms "
|
||||
"without low memory notifications");
|
||||
}
|
||||
|
||||
// Cross-reference largealloc's alloc() decommitted condition.
|
||||
if ((decommit_strategy != DecommitNone)
|
||||
&& (large_class != 0 || decommit_strategy == DecommitSuper))
|
||||
{
|
||||
size_t rsize = bits::one_at_bit(SUPERSLAB_BITS) << large_class;
|
||||
|
||||
memory_provider.notify_not_using(
|
||||
pointer_offset(p, OS_PAGE_SIZE), rsize - OS_PAGE_SIZE);
|
||||
}
|
||||
|
||||
stats.superslab_push();
|
||||
memory_provider.large_stack[large_class].push(static_cast<Largeslab*>(p));
|
||||
memory_provider.lazy_decommit_if_needed();
|
||||
|
||||
Reference in New Issue
Block a user