diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 66f4091..023b2c1 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -46,8 +46,7 @@ namespace snmalloc // Use flat map is under a single node. # define SNMALLOC_MAX_FLATPAGEMAP_SIZE PAGEMAP_NODE_SIZE #endif - static constexpr bool USE_FLATPAGEMAP = - (Pal::pal_features & PalFeatures::LazyCommit) || + static constexpr bool USE_FLATPAGEMAP = pal_supports() || (SNMALLOC_MAX_FLATPAGEMAP_SIZE >= sizeof(FlatPagemap)); @@ -1209,9 +1208,7 @@ namespace snmalloc else if constexpr (decommit_strategy == DecommitSuperLazy) { static_assert( - std::remove_reference_t:: - template pal_supports(), + pal_supports(), "A lazy decommit strategy cannot be implemented on platforms " "without low memory notifications"); } diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index 6d5ee5c..f36c1b5 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -175,15 +175,6 @@ namespace snmalloc return new (p) T(std::forward(args)...); } - /** - * Query whether the PAL supports a specific feature. - */ - template - constexpr static bool pal_supports() - { - return (PAL::pal_features & F) == F; - } - /** * Returns the number of low memory notifications that have been received * (over the lifetime of this process). If the underlying system does not @@ -192,7 +183,7 @@ namespace snmalloc SNMALLOC_FAST_PATH uint64_t low_memory_epoch() { - if constexpr (pal_supports()) + if constexpr (pal_supports()) { return PAL::low_memory_epoch(); } @@ -205,7 +196,7 @@ namespace snmalloc template void* reserve(size_t* size, size_t align) noexcept { - if constexpr (pal_supports()) + if constexpr (pal_supports()) { return PAL::template reserve(size, align); } diff --git a/src/pal/pal.h b/src/pal/pal.h index 7eb5a8f..799f859 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -50,4 +50,13 @@ namespace snmalloc { Pal::error(str); } + + /** + * Query whether the PAL supports a specific feature. + */ + template + constexpr static bool pal_supports() + { + return (PAL::pal_features & F) == F; + } } // namespace snmalloc diff --git a/src/pal/pal_consts.h b/src/pal/pal_consts.h index 40e50bb..b80c543 100644 --- a/src/pal/pal_consts.h +++ b/src/pal/pal_consts.h @@ -28,8 +28,8 @@ namespace snmalloc AlignedAllocation = (1 << 1), /** * This PAL natively supports lazy commit of pages. This means have large - * allocations and not touching them does not up memory usage. This is - * exposed in the P + * allocations and not touching them does not increase memory usage. This is + * exposed in the Pal. */ LazyCommit = (1 << 2), };