class BumpPtrAllocatorImpl
Declaration
template <typename AllocatorT = llvm::MallocAllocator,
size_t SlabSize = 4096,
size_t SizeThreshold = SlabSize>
class BumpPtrAllocatorImpl { /* full declaration omitted */ };
Description
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.
Declared at: llvm/include/llvm/Support/Allocator.h:141
Templates
- AllocatorT = llvm::MallocAllocator
- size_t SlabSize = 4096
- size_t SizeThreshold = SlabSize
Method Overview
- public void * Allocate(size_t Size, llvm::Align Alignment)
- public inline void * Allocate(size_t Size, size_t Alignment)
- public BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>()
- public BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>(BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold> && Old)
- public template <typename T> BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>(T && Allocator)
- public void Deallocate(const void * Ptr, size_t Size)
- public size_t GetNumSlabs() const
- public void PrintStats() const
- public void Reset()
- public size_t getBytesAllocated() const
- public size_t getTotalMemory() const
- public template <typename T>int64_t identifyKnownAlignedObject(const void * Ptr)
- public int64_t identifyKnownObject(const void * Ptr)
- public llvm::Optional<int64_t> identifyObject(const void * Ptr)
- public void setRedZoneSize(size_t NewSize)
- public ~BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>()
Methods
¶void* Allocate(size_t Size, llvm::Align Alignment)
void* Allocate(size_t Size, llvm::Align Alignment)
Description
Allocate space at the specified alignment.
Declared at: llvm/include/llvm/Support/Allocator.h:215
Parameters
- size_t Size
- llvm::Align Alignment
¶inline void* Allocate(size_t Size,
size_t Alignment)
inline void* Allocate(size_t Size,
size_t Alignment)
Declared at: llvm/include/llvm/Support/Allocator.h:271
Parameters
- size_t Size
- size_t Alignment
¶BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>()
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>()
Declared at: llvm/include/llvm/Support/Allocator.h:150
¶BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>(
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>&& Old)
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>(
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>&& Old)
Declared at: llvm/include/llvm/Support/Allocator.h:158
Parameters
- BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>&& Old
¶template <typename T>
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>(T&& Allocator)
template <typename T>
BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>(T&& Allocator)
Declared at: llvm/include/llvm/Support/Allocator.h:153
Templates
- T
Parameters
- T&& Allocator
¶void Deallocate(const void* Ptr, size_t Size)
void Deallocate(const void* Ptr, size_t Size)
Declared at: llvm/include/llvm/Support/Allocator.h:282
Parameters
- const void* Ptr
- size_t Size
¶size_t GetNumSlabs() const
size_t GetNumSlabs() const
Declared at: llvm/include/llvm/Support/Allocator.h:289
¶void PrintStats() const
void PrintStats() const
Declared at: llvm/include/llvm/Support/Allocator.h:360
¶void Reset()
void Reset()
Description
Deallocate all but the current slab and reset the current pointer to the beginning of it, freeing all memory allocated so far.
Declared at: llvm/include/llvm/Support/Allocator.h:195
¶size_t getBytesAllocated() const
size_t getBytesAllocated() const
Declared at: llvm/include/llvm/Support/Allocator.h:354
¶size_t getTotalMemory() const
size_t getTotalMemory() const
Declared at: llvm/include/llvm/Support/Allocator.h:345
¶template <typename T>
int64_t identifyKnownAlignedObject(
const void* Ptr)
template <typename T>
int64_t identifyKnownAlignedObject(
const void* Ptr)
Description
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.
Declared at: llvm/include/llvm/Support/Allocator.h:339
Templates
- T
Parameters
- const void* Ptr
Returns
An index uniquely and reproducibly identifying an input pointer \p Ptr in the given allocator. This identifier is different from the ones produced by identifyObject and identifyAlignedObject.
¶int64_t identifyKnownObject(const void* Ptr)
int64_t identifyKnownObject(const void* Ptr)
Description
A wrapper around identifyObject that additionally asserts that the object is indeed within the allocator.
Declared at: llvm/include/llvm/Support/Allocator.h:322
Parameters
- const void* Ptr
Returns
An index uniquely and reproducibly identifying an input pointer \p Ptr in the given allocator.
¶llvm::Optional<int64_t> identifyObject(
const void* Ptr)
llvm::Optional<int64_t> identifyObject(
const void* Ptr)
Declared at: llvm/include/llvm/Support/Allocator.h:296
Parameters
- const void* Ptr
Returns
An index uniquely and reproducibly identifying an input pointer \p 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.
¶void setRedZoneSize(size_t NewSize)
void setRedZoneSize(size_t NewSize)
Declared at: llvm/include/llvm/Support/Allocator.h:356
Parameters
- size_t NewSize
¶~BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>()
~BumpPtrAllocatorImpl<AllocatorT,
SlabSize,
SizeThreshold>()
Declared at: llvm/include/llvm/Support/Allocator.h:169