LLVM 22.0.0git
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay > Class Template Reference

Allocate memory in an ever growing pool, as if by bump-pointer. More...

#include "llvm/Support/Allocator.h"

Inheritance diagram for llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >:
[legend]

Public Member Functions

 BumpPtrAllocatorImpl ()=default
template<typename T>
 BumpPtrAllocatorImpl (T &&Allocator)
 BumpPtrAllocatorImpl (BumpPtrAllocatorImpl &&Old)
 ~BumpPtrAllocatorImpl ()
BumpPtrAllocatorImploperator= (BumpPtrAllocatorImpl &&RHS)
void Reset ()
 Deallocate all but the current slab and reset the current pointer to the beginning of it, freeing all memory allocated so far.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate (size_t Size, Align Alignment)
 Allocate space at the specified alignment.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_NOINLINE void * AllocateSlow (size_t Size, size_t SizeToAllocate, Align Alignment)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate (size_t Size, size_t Alignment)
void Deallocate (const void *Ptr, size_t Size, size_t)
size_t GetNumSlabs () const
std::optional< int64_t > identifyObject (const void *Ptr)
int64_t identifyKnownObject (const void *Ptr)
 A wrapper around identifyObject that additionally asserts that the object is indeed within the allocator.
template<typename T>
int64_t identifyKnownAlignedObject (const void *Ptr)
 A wrapper around identifyKnownObject.
size_t getTotalMemory () const
size_t getBytesAllocated () const
void setRedZoneSize (size_t NewSize)
void PrintStats () const
Public Member Functions inherited from llvm::AllocatorBase< BumpPtrAllocatorImpl< MallocAllocator, 4096, 4096, 128 > >
void * Allocate (size_t Size, size_t Alignment)
 Allocate Size bytes of Alignment aligned memory.
void Deallocate (const void *Ptr, size_t Size, size_t Alignment)
 Deallocate Ptr to Size bytes of memory allocated by this allocator.

Friends

template<typename T>
class SpecificBumpPtrAllocator

Detailed Description

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
class llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >

Allocate memory in an ever growing pool, as if by bump-pointer.

This isn't strictly a bump-pointer allocator as it uses backing slabs of memory rather than relying on a boundless contiguous heap. However, it has bump-pointer semantics in that it is a monotonically growing pool of memory where every allocation is found by merely allocating the next N bytes in the slab, or the next N bytes in the next slab.

Note that this also has a threshold for forcing allocations above a certain size into their own slab.

The BumpPtrAllocatorImpl template defaults to using a MallocAllocator object, which wraps malloc, to allocate memory, but it can be changed to use a custom allocator.

The GrowthDelay specifies after how many allocated slabs the allocator increases the size of the slabs.

Definition at line 64 of file Allocator.h.

Constructor & Destructor Documentation

◆ BumpPtrAllocatorImpl() [1/3]

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::BumpPtrAllocatorImpl ( )
default

◆ BumpPtrAllocatorImpl() [2/3]

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
template<typename T>
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::BumpPtrAllocatorImpl ( T && Allocator)
inline

Definition at line 82 of file Allocator.h.

◆ BumpPtrAllocatorImpl() [3/3]

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::BumpPtrAllocatorImpl ( BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay > && Old)
inline

Definition at line 87 of file Allocator.h.

◆ ~BumpPtrAllocatorImpl()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::~BumpPtrAllocatorImpl ( )
inline

Definition at line 98 of file Allocator.h.

Member Function Documentation

◆ Allocate() [1/2]

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
LLVM_ATTRIBUTE_RETURNS_NONNULL void * llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate ( size_t Size,
Align Alignment )
inline

◆ Allocate() [2/2]

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
LLVM_ATTRIBUTE_RETURNS_NONNULL void * llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate ( size_t Size,
size_t Alignment )
inline

Definition at line 215 of file Allocator.h.

◆ AllocateSlow()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_NOINLINE void * llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::AllocateSlow ( size_t Size,
size_t SizeToAllocate,
Align Alignment )
inline

◆ Deallocate()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Deallocate ( const void * Ptr,
size_t Size,
size_t  )
inline

Definition at line 226 of file Allocator.h.

◆ getBytesAllocated()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
size_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::getBytesAllocated ( ) const
inline

Definition at line 298 of file Allocator.h.

◆ GetNumSlabs()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
size_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::GetNumSlabs ( ) const
inline

Definition at line 233 of file Allocator.h.

◆ getTotalMemory()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
size_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::getTotalMemory ( ) const
inline

Definition at line 289 of file Allocator.h.

◆ identifyKnownAlignedObject()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
template<typename T>
int64_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::identifyKnownAlignedObject ( const void * Ptr)
inline

A wrapper around identifyKnownObject.

Accepts type information about the object and produces a smaller identifier by relying on the alignment information. Note that sub-classes may have different alignment, so the most base class should be passed as template parameter in order to obtain correct results. For that reason automatic template parameter deduction is disabled.

Returns
An index uniquely and reproducibly identifying an input pointer Ptr in the given allocator. This identifier is different from the ones produced by identifyObject and identifyAlignedObject.

Definition at line 283 of file Allocator.h.

◆ identifyKnownObject()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
int64_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::identifyKnownObject ( const void * Ptr)
inline

A wrapper around identifyObject that additionally asserts that the object is indeed within the allocator.

Returns
An index uniquely and reproducibly identifying an input pointer Ptr in the given allocator.

Definition at line 266 of file Allocator.h.

Referenced by llvm::BumpPtrAllocatorImpl< MallocAllocator, 65536 >::identifyKnownAlignedObject().

◆ identifyObject()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
std::optional< int64_t > llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::identifyObject ( const void * Ptr)
inline
Returns
An index uniquely and reproducibly identifying an input pointer Ptr in the given allocator. The returned value is negative iff the object is inside a custom-size slab. Returns an empty optional if the pointer is not found in the allocator.

Definition at line 240 of file Allocator.h.

Referenced by llvm::BumpPtrAllocatorImpl< MallocAllocator, 65536 >::identifyKnownObject().

◆ operator=()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
BumpPtrAllocatorImpl & llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::operator= ( BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay > && RHS)
inline

Definition at line 103 of file Allocator.h.

◆ PrintStats()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::PrintStats ( ) const
inline

Definition at line 304 of file Allocator.h.

◆ Reset()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Reset ( )
inline

Deallocate all but the current slab and reset the current pointer to the beginning of it, freeing all memory allocated so far.

Definition at line 124 of file Allocator.h.

◆ setRedZoneSize()

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::setRedZoneSize ( size_t NewSize)
inline

Definition at line 300 of file Allocator.h.

◆ SpecificBumpPtrAllocator

template<typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128>
template<typename T>
friend class SpecificBumpPtrAllocator
friend

Definition at line 378 of file Allocator.h.


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