From e212ddd0e0e73311f93e288eb80ba6a00fb19dc5 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Wed, 21 Jul 2021 16:14:03 +0100 Subject: [PATCH] Prepare for PAL address_bits --- src/pal/pal_concept.h | 3 ++- src/pal/pal_noalloc.h | 2 ++ src/pal/pal_posix.h | 12 ++++++++++++ src/pal/pal_windows.h | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pal/pal_concept.h b/src/pal/pal_concept.h index d8a328e..aff9354 100644 --- a/src/pal/pal_concept.h +++ b/src/pal/pal_concept.h @@ -26,11 +26,12 @@ namespace snmalloc }; /** - * PALs must advertise their page size + * PALs must advertise the size of the address space and their page size */ template concept ConceptPAL_static_sizes = requires() { + typename std::integral_constant; typename std::integral_constant; }; diff --git a/src/pal/pal_noalloc.h b/src/pal/pal_noalloc.h index 2c5c61a..a98add6 100644 --- a/src/pal/pal_noalloc.h +++ b/src/pal/pal_noalloc.h @@ -37,6 +37,8 @@ namespace snmalloc static constexpr size_t page_size = BasePAL::page_size; + static constexpr size_t address_bits = Aal::address_bits; + /** * Print a stack trace. */ diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index 93b9518..dd3932b 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -132,6 +132,18 @@ namespace snmalloc static constexpr size_t page_size = Aal::smallest_page_size; + /** + * Address bits are potentially mediated by some POSIX OSes, but generally + * default to the architecture's. + * + * Unlike the AALs, which are composited by explicitly delegating to their + * template parameters and so play a SFINAE-based game to achieve similar + * ends, for the PALPOSIX<> classes we instead use more traditional + * inheritance (e.g., PALLinux is subtype of PALPOSIX) and so we + * can just use that mechanism here, too. + */ + static constexpr size_t address_bits = Aal::address_bits; + static void print_stack_trace() { #ifdef SNMALLOC_BACKTRACE_HEADER diff --git a/src/pal/pal_windows.h b/src/pal/pal_windows.h index 98654d1..86286d0 100644 --- a/src/pal/pal_windows.h +++ b/src/pal/pal_windows.h @@ -62,6 +62,11 @@ namespace snmalloc static constexpr size_t page_size = 0x1000; + /** + * Windows always inherits its underlying architecture's full address range. + */ + static constexpr size_t address_bits = Aal::address_bits; + /** * Check whether the low memory state is still in effect. This is an * expensive operation and should not be on any fast paths.