Broom 1.0.0
A thread-local C++ Garbage Collector
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
broom::FreeListAllocator Class Reference

#include <allocator.h>

Inheritance diagram for broom::FreeListAllocator:
Inheritance graph
[legend]
Collaboration diagram for broom::FreeListAllocator:
Collaboration graph
[legend]

Public Member Functions

 FreeListAllocator (size_t space_size=kDefaultSpaceSize, size_t large_space_size=kDefaultLargeSpaceSize, size_t large_space_threshold=kDefaultLargeSpaceThreshold)
 
virtual ~FreeListAllocator ()
 
virtual bool Grow (size_t requested_size, MemorySpace **space_to_update) override
 
virtual voidAllocate (size_t requested_size) override
 
virtual void Dispose (void *definitely_uintptr) override
 
virtual size_t LargeSpaceThreshold () const override
 
virtual const voidGetBasePointerOfMaybeInnerPointer (const void *maybe_inner) const override
 
- Public Member Functions inherited from broom::Allocator
virtual ~Allocator ()=default
 
MemoryPressure CalculateMemoryPressure () const
 

Protected Types

using FreeList = absl::btree_multiset< MemoryRegion, MemoryRegion::SetCompare >
 

Protected Member Functions

FreeList::iterator FindExactRegion (FreeList &free_list, const MemoryRegion region)
 
voidSplitFreeListEntry (FreeList &free_list, FreeList::iterator &pos, size_t requested_size)
 
voidTryAllocateFromFreeListImpl (FreeList &free_list, size_t requested_size)
 
voidTryAllocateFromLargeFreeList (size_t requested_size)
 
voidTryAllocateFromFreeList (size_t requested_size)
 
voidTryAllocateExactOrFindNext (FreeList &free_list, FreeList::iterator &pos, size_t requested_size)
 
void AddOrCoalesceLargeFreeList (const MemoryRegion current, const MemoryRegion previous, const MemoryRegion next, const MemoryRegion coalesced)
 
void AddOrCoalesceFreeList (const MemoryRegion current, const MemoryRegion previous, const MemoryRegion next, const MemoryRegion coalesced)
 
void AddOrCoalesceFreeListImpl (FreeList &free_list, const MemoryRegion current, const MemoryRegion previous, const MemoryRegion next, const MemoryRegion coalesced)
 
void FillSpaceAndAddToFreeList (FreeList *list, MemorySpace *space)
 
voidAllocateRawPointer (size_t requested_size)
 
void DisposeRawPointer (void *definitely_pointer)
 
- Protected Member Functions inherited from broom::Allocator
 Allocator ()=default
 

Static Protected Member Functions

static constexpr size_t MaximumAllocationSize ()
 
static constexpr size_t GetRealAllocationSize (size_t requested_size)
 
- Static Protected Member Functions inherited from broom::Allocator
static void PinBasePointer (const void *pointer, uint32_t how_many)
 
static void UnpinBasePointer (const void *pointer)
 
static bool IsPinnedBasePointer (const void *pointer)
 
static size_t SpaceMask (size_t space_size)
 

Protected Attributes

std::vector< MemorySpacespaces_
 
std::vector< MemorySpacelarge_spaces_
 
size_t space_size_
 
size_t large_space_size_
 
size_t large_space_threshold_
 
MemorySpacecurrent_space_ = nullptr
 
MemorySpacecurrent_large_space_ = nullptr
 
FreeList free_list_
 
FreeList large_free_list_
 
- Protected Attributes inherited from broom::Allocator
AllocatorStatistics stats_
 

Static Protected Attributes

static constexpr const size_t kLargeSpaceThreshold = 1 * MB
 

Additional Inherited Members

- Static Public Attributes inherited from broom::Allocator
static constexpr const int kFrontMetadataSize
 
static constexpr const int kBackMetadataSize = sizeof(AllocatorBackMetadata)
 
static constexpr const int kTotalMetadataSize
 
static constexpr const size_t kDefaultSpaceSize = 2 * MB
 
static constexpr const size_t kDefaultLargeSpaceSize = 64 * MB
 
static constexpr const size_t kDefaultLargeSpaceThreshold = 1 * MB
 
static constexpr const MemoryPermissions kDefaultPermissions
 
static constexpr const size_t kGiantMappingSize = kDefaultLargeSpaceSize
 

Detailed Description

Definition at line 309 of file allocator.h.

Member Typedef Documentation

◆ FreeList

Definition at line 336 of file allocator.h.

Constructor & Destructor Documentation

◆ FreeListAllocator()

broom::FreeListAllocator::FreeListAllocator ( size_t  space_size = kDefaultSpaceSize,
size_t  large_space_size = kDefaultLargeSpaceSize,
size_t  large_space_threshold = kDefaultLargeSpaceThreshold 
)
inlineexplicit

Definition at line 311 of file allocator.h.

◆ ~FreeListAllocator()

broom::FreeListAllocator::~FreeListAllocator ( )
virtual

Definition at line 10 of file allocator-inl.h.

Member Function Documentation

◆ AddOrCoalesceFreeList()

void broom::FreeListAllocator::AddOrCoalesceFreeList ( const MemoryRegion  current,
const MemoryRegion  previous,
const MemoryRegion  next,
const MemoryRegion  coalesced 
)
protected

Definition at line 329 of file allocator-inl.h.

◆ AddOrCoalesceFreeListImpl()

void broom::FreeListAllocator::AddOrCoalesceFreeListImpl ( FreeList free_list,
const MemoryRegion  current,
const MemoryRegion  previous,
const MemoryRegion  next,
const MemoryRegion  coalesced 
)
protected

Definition at line 359 of file allocator-inl.h.

◆ AddOrCoalesceLargeFreeList()

void broom::FreeListAllocator::AddOrCoalesceLargeFreeList ( const MemoryRegion  current,
const MemoryRegion  previous,
const MemoryRegion  next,
const MemoryRegion  coalesced 
)
protected

Definition at line 322 of file allocator-inl.h.

◆ Allocate()

void * broom::FreeListAllocator::Allocate ( size_t  requested_size)
overridevirtual

Implements broom::Allocator.

Definition at line 285 of file allocator-inl.h.

◆ AllocateRawPointer()

void * broom::FreeListAllocator::AllocateRawPointer ( size_t  requested_size)
protected

Definition at line 237 of file allocator-inl.h.

◆ Dispose()

void broom::FreeListAllocator::Dispose ( void definitely_uintptr)
overridevirtual

Implements broom::Allocator.

Definition at line 613 of file allocator-inl.h.

◆ DisposeRawPointer()

void broom::FreeListAllocator::DisposeRawPointer ( void definitely_pointer)
protected

Definition at line 471 of file allocator-inl.h.

◆ FillSpaceAndAddToFreeList()

void broom::FreeListAllocator::FillSpaceAndAddToFreeList ( FreeList list,
MemorySpace space 
)
protected

Definition at line 200 of file allocator-inl.h.

◆ FindExactRegion()

FreeList::iterator broom::FreeListAllocator::FindExactRegion ( FreeList free_list,
const MemoryRegion  region 
)
inlineprotected

Definition at line 346 of file allocator.h.

◆ GetBasePointerOfMaybeInnerPointer()

const void * broom::FreeListAllocator::GetBasePointerOfMaybeInnerPointer ( const void maybe_inner) const
overridevirtual

Implements broom::Allocator.

Definition at line 624 of file allocator-inl.h.

◆ GetRealAllocationSize()

static constexpr size_t broom::FreeListAllocator::GetRealAllocationSize ( size_t  requested_size)
inlinestaticconstexprprotected

Definition at line 390 of file allocator.h.

◆ Grow()

bool broom::FreeListAllocator::Grow ( size_t  requested_size,
MemorySpace **  space_to_update 
)
overridevirtual

Implements broom::Allocator.

Definition at line 22 of file allocator-inl.h.

◆ LargeSpaceThreshold()

virtual size_t broom::FreeListAllocator::LargeSpaceThreshold ( ) const
inlineoverridevirtual

Implements broom::Allocator.

Definition at line 328 of file allocator.h.

◆ MaximumAllocationSize()

static constexpr size_t broom::FreeListAllocator::MaximumAllocationSize ( )
inlinestaticconstexprprotected

Definition at line 385 of file allocator.h.

◆ SplitFreeListEntry()

void * broom::FreeListAllocator::SplitFreeListEntry ( FreeList free_list,
FreeList::iterator &  pos,
size_t  requested_size 
)
protected

Definition at line 121 of file allocator-inl.h.

◆ TryAllocateExactOrFindNext()

void * broom::FreeListAllocator::TryAllocateExactOrFindNext ( FreeList free_list,
FreeList::iterator &  pos,
size_t  requested_size 
)
protected

Definition at line 155 of file allocator-inl.h.

◆ TryAllocateFromFreeList()

void * broom::FreeListAllocator::TryAllocateFromFreeList ( size_t  requested_size)
protected

Definition at line 194 of file allocator-inl.h.

◆ TryAllocateFromFreeListImpl()

void * broom::FreeListAllocator::TryAllocateFromFreeListImpl ( FreeList free_list,
size_t  requested_size 
)
protected

Definition at line 178 of file allocator-inl.h.

◆ TryAllocateFromLargeFreeList()

void * broom::FreeListAllocator::TryAllocateFromLargeFreeList ( size_t  requested_size)
protected

Definition at line 190 of file allocator-inl.h.

Member Data Documentation

◆ current_large_space_

MemorySpace* broom::FreeListAllocator::current_large_space_ = nullptr
protected

Definition at line 404 of file allocator.h.

◆ current_space_

MemorySpace* broom::FreeListAllocator::current_space_ = nullptr
protected

Definition at line 403 of file allocator.h.

◆ free_list_

FreeList broom::FreeListAllocator::free_list_
protected

Definition at line 405 of file allocator.h.

◆ kLargeSpaceThreshold

constexpr const size_t broom::FreeListAllocator::kLargeSpaceThreshold = 1 * MB
staticconstexprprotected

Definition at line 384 of file allocator.h.

◆ large_free_list_

FreeList broom::FreeListAllocator::large_free_list_
protected

Definition at line 406 of file allocator.h.

◆ large_space_size_

size_t broom::FreeListAllocator::large_space_size_
protected

Definition at line 401 of file allocator.h.

◆ large_space_threshold_

size_t broom::FreeListAllocator::large_space_threshold_
protected

Definition at line 402 of file allocator.h.

◆ large_spaces_

std::vector<MemorySpace> broom::FreeListAllocator::large_spaces_
protected

Definition at line 399 of file allocator.h.

◆ space_size_

size_t broom::FreeListAllocator::space_size_
protected

Definition at line 400 of file allocator.h.

◆ spaces_

std::vector<MemorySpace> broom::FreeListAllocator::spaces_
protected

Definition at line 398 of file allocator.h.


The documentation for this class was generated from the following files: