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:
Matthew Parkinson
2020-01-29 12:17:16 +00:00
parent 2e4b289991
commit 2e289573c8
2 changed files with 20 additions and 28 deletions

View File

@@ -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();