diff --git a/src/snmalloc/backend/standard_range.h b/src/snmalloc/backend/standard_range.h index d07c9a5..b9a2d5b 100644 --- a/src/snmalloc/backend/standard_range.h +++ b/src/snmalloc/backend/standard_range.h @@ -22,7 +22,7 @@ namespace snmalloc template< typename PAL, typename Pagemap, - typename Base = EmptyRange, + typename Base = EmptyRange<>, size_t MinSizeBits = MinBaseSizeBits()> struct StandardLocalState : BaseLocalStateConstants { diff --git a/src/snmalloc/backend_helpers/commitrange.h b/src/snmalloc/backend_helpers/commitrange.h index de67a13..2bbd7a5 100644 --- a/src/snmalloc/backend_helpers/commitrange.h +++ b/src/snmalloc/backend_helpers/commitrange.h @@ -18,9 +18,14 @@ namespace snmalloc static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; + using ChunkBounds = typename ParentRange::ChunkBounds; + static_assert( + ChunkBounds::address_space_control == + capptr::dimension::AddressSpaceControl::Full); + constexpr Type() = default; - capptr::Chunk alloc_range(size_t size) + CapPtr alloc_range(size_t size) { SNMALLOC_ASSERT_MSG( (size % PAL::page_size) == 0, @@ -33,7 +38,7 @@ namespace snmalloc return range; } - void dealloc_range(capptr::Chunk base, size_t size) + void dealloc_range(CapPtr base, size_t size) { SNMALLOC_ASSERT_MSG( (size % PAL::page_size) == 0, diff --git a/src/snmalloc/backend_helpers/empty_range.h b/src/snmalloc/backend_helpers/empty_range.h index 6507a01..c4eb160 100644 --- a/src/snmalloc/backend_helpers/empty_range.h +++ b/src/snmalloc/backend_helpers/empty_range.h @@ -3,6 +3,7 @@ namespace snmalloc { + template class EmptyRange { public: @@ -10,9 +11,11 @@ namespace snmalloc static constexpr bool ConcurrencySafe = true; + using ChunkBounds = B; + constexpr EmptyRange() = default; - capptr::Chunk alloc_range(size_t) + CapPtr alloc_range(size_t) { return nullptr; } diff --git a/src/snmalloc/backend_helpers/globalrange.h b/src/snmalloc/backend_helpers/globalrange.h index 3e01c3d..760ad21 100644 --- a/src/snmalloc/backend_helpers/globalrange.h +++ b/src/snmalloc/backend_helpers/globalrange.h @@ -11,7 +11,7 @@ namespace snmalloc */ struct GlobalRange { - template + template> class Type : public StaticParent { using StaticParent::parent; @@ -27,15 +27,17 @@ namespace snmalloc static constexpr bool ConcurrencySafe = true; + using ChunkBounds = typename ParentRange::ChunkBounds; + constexpr Type() = default; - capptr::Chunk alloc_range(size_t size) + CapPtr alloc_range(size_t size) { FlagLock lock(spin_lock); return parent.alloc_range(size); } - void dealloc_range(capptr::Chunk base, size_t size) + void dealloc_range(CapPtr base, size_t size) { FlagLock lock(spin_lock); parent.dealloc_range(base, size); diff --git a/src/snmalloc/backend_helpers/largebuddyrange.h b/src/snmalloc/backend_helpers/largebuddyrange.h index 7d31597..379cb5d 100644 --- a/src/snmalloc/backend_helpers/largebuddyrange.h +++ b/src/snmalloc/backend_helpers/largebuddyrange.h @@ -208,7 +208,7 @@ namespace snmalloc bits::one_at_bit(MIN_REFILL_SIZE_BITS); public: - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -341,6 +341,8 @@ namespace snmalloc static constexpr bool ConcurrencySafe = false; + using ChunkBounds = capptr::bounds::Chunk; + constexpr Type() = default; capptr::Chunk alloc_range(size_t size) diff --git a/src/snmalloc/backend_helpers/logrange.h b/src/snmalloc/backend_helpers/logrange.h index 9bc1d47..0a3f907 100644 --- a/src/snmalloc/backend_helpers/logrange.h +++ b/src/snmalloc/backend_helpers/logrange.h @@ -14,7 +14,7 @@ namespace snmalloc template struct LogRange { - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -24,9 +24,11 @@ namespace snmalloc static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; + using ChunkBounds = typename ParentRange::ChunkBounds; + constexpr Type() = default; - capptr::Chunk alloc_range(size_t size) + CapPtr alloc_range(size_t size) { #ifdef SNMALLOC_TRACING message<1024>("Call alloc_range({}) on {}", size, RangeName); @@ -39,7 +41,7 @@ namespace snmalloc return range; } - void dealloc_range(capptr::Chunk base, size_t size) + void dealloc_range(CapPtr base, size_t size) { #ifdef SNMALLOC_TRACING message<1024>( diff --git a/src/snmalloc/backend_helpers/pagemapregisterrange.h b/src/snmalloc/backend_helpers/pagemapregisterrange.h index 7201f8f..9a0019e 100644 --- a/src/snmalloc/backend_helpers/pagemapregisterrange.h +++ b/src/snmalloc/backend_helpers/pagemapregisterrange.h @@ -11,7 +11,7 @@ namespace snmalloc bool CanConsolidate = true> struct PagemapRegisterRange { - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -23,7 +23,9 @@ namespace snmalloc static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; - capptr::Chunk alloc_range(size_t size) + using ChunkBounds = typename ParentRange::ChunkBounds; + + CapPtr alloc_range(size_t size) { auto base = parent.alloc_range(size); diff --git a/src/snmalloc/backend_helpers/palrange.h b/src/snmalloc/backend_helpers/palrange.h index 0962e00..efa324e 100644 --- a/src/snmalloc/backend_helpers/palrange.h +++ b/src/snmalloc/backend_helpers/palrange.h @@ -14,6 +14,8 @@ namespace snmalloc // need to be changed. static constexpr bool ConcurrencySafe = true; + using ChunkBounds = capptr::bounds::Chunk; + constexpr PalRange() = default; capptr::Chunk alloc_range(size_t size) diff --git a/src/snmalloc/backend_helpers/smallbuddyrange.h b/src/snmalloc/backend_helpers/smallbuddyrange.h index fc42d6f..8e7de03 100644 --- a/src/snmalloc/backend_helpers/smallbuddyrange.h +++ b/src/snmalloc/backend_helpers/smallbuddyrange.h @@ -145,7 +145,7 @@ namespace snmalloc struct SmallBuddyRange { - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -187,6 +187,8 @@ namespace snmalloc static constexpr bool ConcurrencySafe = false; + using ChunkBounds = capptr::bounds::Chunk; + constexpr Type() = default; capptr::Chunk alloc_range(size_t size) diff --git a/src/snmalloc/backend_helpers/statsrange.h b/src/snmalloc/backend_helpers/statsrange.h index f38f6e9..8548be9 100644 --- a/src/snmalloc/backend_helpers/statsrange.h +++ b/src/snmalloc/backend_helpers/statsrange.h @@ -12,7 +12,7 @@ namespace snmalloc */ struct StatsRange { - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -25,9 +25,11 @@ namespace snmalloc static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; + using ChunkBounds = typename ParentRange::ChunkBounds; + constexpr Type() = default; - capptr::Chunk alloc_range(size_t size) + CapPtr alloc_range(size_t size) { auto result = parent.alloc_range(size); if (result != nullptr) @@ -43,7 +45,7 @@ namespace snmalloc return result; } - void dealloc_range(capptr::Chunk base, size_t size) + void dealloc_range(CapPtr base, size_t size) { current_usage -= size; parent.dealloc_range(base, size); diff --git a/src/snmalloc/backend_helpers/subrange.h b/src/snmalloc/backend_helpers/subrange.h index 03c7825..8d886a2 100644 --- a/src/snmalloc/backend_helpers/subrange.h +++ b/src/snmalloc/backend_helpers/subrange.h @@ -12,7 +12,7 @@ namespace snmalloc template struct SubRange { - template + template> class Type : public ContainsParent { using ContainsParent::parent; @@ -24,7 +24,9 @@ namespace snmalloc static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; - capptr::Chunk alloc_range(size_t sub_size) + using ChunkBounds = typename ParentRange::ChunkBounds; + + CapPtr alloc_range(size_t sub_size) { SNMALLOC_ASSERT(bits::is_pow2(sub_size));