LLVM  6.0.0svn
Public Member Functions | Friends | List of all members
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > 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 >:
Inheritance graph
[legend]
Collaboration diagram for llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >:
Collaboration graph
[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. More...
 
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate (size_t Size, size_t Alignment)
 Allocate space at the specified alignment. More...
 
void Deallocate (const void *Ptr, size_t Size)
 
size_t GetNumSlabs () const
 
size_t getTotalMemory () const
 
size_t getBytesAllocated () const
 
void setRedZoneSize (size_t NewSize)
 
void PrintStats () const
 
- Public Member Functions inherited from llvm::AllocatorBase< BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > >
void * Allocate (size_t Size, size_t Alignment)
 Allocate Size bytes of Alignment aligned memory. More...
 
TAllocate (size_t Num=1)
 Allocate space for a sequence of objects without constructing them. More...
 
void Deallocate (const void *Ptr, size_t Size)
 Deallocate Ptr to Size bytes of memory allocated by this allocator. More...
 
std::enable_if< !std::is_same< typename std::remove_cv< T >::type, void >::value, void >::type Deallocate (T *Ptr, size_t Num=1)
 Deallocate space for a sequence of objects without constructing them. More...
 

Friends

template<typename T >
class SpecificBumpPtrAllocator
 

Detailed Description

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

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.

Definition at line 138 of file Allocator.h.

Constructor & Destructor Documentation

◆ BumpPtrAllocatorImpl() [1/3]

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

◆ BumpPtrAllocatorImpl() [2/3]

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

Definition at line 150 of file Allocator.h.

◆ BumpPtrAllocatorImpl() [3/3]

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

Definition at line 155 of file Allocator.h.

◆ ~BumpPtrAllocatorImpl()

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

Definition at line 166 of file Allocator.h.

Member Function Documentation

◆ Allocate()

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

◆ Deallocate()

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

◆ getBytesAllocated()

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

Definition at line 293 of file Allocator.h.

◆ GetNumSlabs()

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

Definition at line 282 of file Allocator.h.

◆ getTotalMemory()

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

Definition at line 284 of file Allocator.h.

◆ operator=()

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

Definition at line 171 of file Allocator.h.

◆ PrintStats()

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

Definition at line 299 of file Allocator.h.

◆ Reset()

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

◆ setRedZoneSize()

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

Friends And Related Function Documentation

◆ SpecificBumpPtrAllocator

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

Definition at line 373 of file Allocator.h.


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