backend ranges: hide object_range behind accessor

This allows us to have a single Pipe-line of ranges where we can, nevertheless,
jump over the small buddy allocator when making large allocations.  This, in
turn, will let us differentiate the types coming from the small end and the
large "tap" on this Pipe-line.
This commit is contained in:
Nathaniel Wesley Filardo
2022-05-31 09:29:28 +01:00
committed by Nathaniel Filardo
parent aa61b59a8f
commit 83ac7c691e
3 changed files with 22 additions and 9 deletions

View File

@@ -84,7 +84,7 @@ namespace snmalloc
return {nullptr, nullptr};
}
auto p = local_state.object_range.alloc_range(size);
auto p = local_state.get_object_range()->alloc_range(size);
#ifdef SNMALLOC_TRACING
message<1024>("Alloc chunk: {} ({})", p.unsafe_ptr(), size);
@@ -146,7 +146,7 @@ namespace snmalloc
// the chunk. On CHERI platforms this will need to be stored in the
// SlabMetadata or similar.
auto chunk = capptr::Chunk<void>::unsafe_from(alloc.unsafe_ptr());
local_state.object_range.dealloc_range(chunk, size);
local_state.get_object_range()->dealloc_range(chunk, size);
}
template<bool potentially_out_of_range = false>

View File

@@ -103,13 +103,18 @@ namespace snmalloc
Pagemap>,
SmallBuddyRange>;
public:
using Stats = StatsCombiner<CentralObjectRange, CentralMetaRange>;
ObjectRange object_range;
MetaRange meta_range;
public:
using Stats = StatsCombiner<CentralObjectRange, CentralMetaRange>;
ObjectRange* get_object_range()
{
return &object_range;
}
MetaRange& get_meta_range()
{
return meta_range;

View File

@@ -44,23 +44,31 @@ namespace snmalloc
static constexpr size_t page_size_bits =
bits::next_pow2_bits_const(PAL::page_size);
public:
// Source for object allocations and metadata
// Use buddy allocators to cache locally.
using ObjectRange = Pipe<
using LargeObjectRange = Pipe<
Stats,
LargeBuddyRange<
LocalCacheSizeBits,
LocalCacheSizeBits,
Pagemap,
page_size_bits>,
SmallBuddyRange>;
page_size_bits>>;
private:
using ObjectRange = Pipe<LargeObjectRange, SmallBuddyRange>;
ObjectRange object_range;
public:
// Expose a global range for the initial allocation of meta-data.
using GlobalMetaRange = Pipe<ObjectRange, GlobalRange>;
// Where we get user allocations from.
ObjectRange object_range;
LargeObjectRange* get_object_range()
{
return object_range.template ancestor<LargeObjectRange>();
}
// Where we get meta-data allocations from.
ObjectRange& get_meta_range()