15 #ifndef LLVM_SUPPORT_RECYCLER_H
16 #define LLVM_SUPPORT_RECYCLER_H
25 class BumpPtrAllocator;
58 llvm_unreachable(
"Recycler's ilist_traits shouldn't see a deleteNode call!");
66 template<class T, size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
78 assert(FreeList.empty() &&
"Non-empty recycler deleted!");
84 template<
class AllocatorType>
85 void clear(AllocatorType &Allocator) {
86 while (!FreeList.empty()) {
87 T *t =
reinterpret_cast<T *
>(FreeList.remove(FreeList.begin()));
88 Allocator.Deallocate(t);
98 FreeList.clearAndLeakNodesUnsafely();
101 template<
class SubClass,
class AllocatorType>
103 assert(
sizeof(SubClass) <= Size &&
104 "Recycler allocation size is less than object size!");
106 "Recycler allocation alignment is less than object alignment!");
107 return !FreeList.empty() ?
108 reinterpret_cast<SubClass *
>(FreeList.remove(FreeList.begin())) :
109 static_cast<SubClass *
>(Allocator.Allocate(Size,
Align));
112 template<
class AllocatorType>
114 return Allocate<T>(Allocator);
117 template<
class SubClass,
class AllocatorType>
119 FreeList.push_front(reinterpret_cast<RecyclerStruct *>(Element));
void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
static RecyclerStruct * getNext(const RecyclerStruct *t)
static void setNext(RecyclerStruct *t, RecyclerStruct *n)
void clear(BumpPtrAllocator &)
static void setPrev(RecyclerStruct *t, RecyclerStruct *p)
#define llvm_unreachable(msg)
static void destroySentinel(RecyclerStruct *)
static RecyclerStruct * getPrev(const RecyclerStruct *t)
SubClass * Allocate(AllocatorType &Allocator)
static void deleteNode(RecyclerStruct *)
RecyclerStruct * provideInitialHead() const
T * Allocate(AllocatorType &Allocator)
RecyclerStruct * ensureHead(RecyclerStruct *) const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
RecyclerStruct * createSentinel() const
void Deallocate(AllocatorType &, SubClass *Element)
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
void clear(AllocatorType &Allocator)
static void noteHead(RecyclerStruct *, RecyclerStruct *)