diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 73a5844..91d1de1 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -1026,7 +1026,8 @@ namespace snmalloc void* p = remove_cache_friendly_offset(fl.take(entropy), sizeclass); if constexpr (zero_mem == YesZero) { - MemoryProvider::Pal::zero(p, sizeclass_to_size(sizeclass)); + pal_zero( + p, sizeclass_to_size(sizeclass)); } return p; } @@ -1138,7 +1139,7 @@ namespace snmalloc if constexpr (zero_mem == YesZero) { - MemoryProvider::Pal::zero(p, sizeclass_to_size(sizeclass)); + pal_zero(p, sizeclass_to_size(sizeclass)); } return p; } diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index ace16d0..e381db3 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -319,7 +319,7 @@ namespace snmalloc // The first page is already in "use" for the stack element, // this will need zeroing for a YesZero call. if constexpr (zero_mem == YesZero) - MemoryProvider::Pal::template zero(p, OS_PAGE_SIZE); + pal_zero(p, OS_PAGE_SIZE); // Notify we are using the rest of the allocation. // Passing zero_mem ensures the PAL provides zeroed pages if @@ -331,7 +331,7 @@ namespace snmalloc { // This is a superslab that has not been decommitted. if constexpr (zero_mem == YesZero) - MemoryProvider::Pal::template zero( + pal_zero( p, bits::align_up(size, OS_PAGE_SIZE)); else UNUSED(size); diff --git a/src/mem/mediumslab.h b/src/mem/mediumslab.h index dc39da4..585a67a 100644 --- a/src/mem/mediumslab.h +++ b/src/mem/mediumslab.h @@ -94,7 +94,7 @@ namespace snmalloc self->free--; if constexpr (zero_mem == YesZero) - PAL::zero(p, size); + pal_zero(p, size); else UNUSED(size); diff --git a/src/mem/metaslab.h b/src/mem/metaslab.h index e358fc2..bd90c53 100644 --- a/src/mem/metaslab.h +++ b/src/mem/metaslab.h @@ -181,9 +181,9 @@ namespace snmalloc if constexpr (zero_mem == YesZero) { if (rsize < PAGE_ALIGNED_SIZE) - PAL::zero(p, rsize); + pal_zero(p, rsize); else - PAL::template zero(p, rsize); + pal_zero(p, rsize); } else { diff --git a/src/pal/pal.h b/src/pal/pal.h index 2f58c7c..c11efec 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -69,6 +69,16 @@ namespace snmalloc // Used to keep Superslab metadata committed. static constexpr size_t OS_PAGE_SIZE = Pal::page_size; + /** + * A centralized, inlinable wrapper around PAL::zero. This will matter more + * when we introduce AuthPtr-s. + */ + template + static SNMALLOC_FAST_PATH void pal_zero(void* p, size_t sz) + { + PAL::template zero(p, sz); + } + static_assert( bits::is_pow2(OS_PAGE_SIZE), "OS_PAGE_SIZE must be a power of two"); static_assert(