From b9a99d459349148d3ac349066e143f17f185b43c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 15 Apr 2014 09:44:09 +0000 Subject: [Allocator] Finally, finish nuking the redundant code that led me here by removing the MallocSlabAllocator entirely and just using MallocAllocator directly. This makes all off these allocators expose and utilize the same core interface. The only ugly part of this is that it exposes the fact that the JIT allocator has no real handling of alignment, any more than the malloc allocator does. =/ It would be nice to fix both of these to support alignments, and then to leverage that in the BumpPtrAllocator to do less over allocation in order to manually align pointers. But, that's another patch for another day. This patch has no functional impact, it just removes the somewhat meaningless wrapper around MallocAllocator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206267 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Allocator.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 5565c1ccf1..742812d75f 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -135,19 +135,6 @@ public: void PrintStats() const {} }; -/// MallocSlabAllocator - The default slab allocator for the bump allocator -/// is an adapter class for MallocAllocator that just forwards the method -/// calls and translates the arguments. -class MallocSlabAllocator { - /// Allocator - The underlying allocator that we forward to. - /// - MallocAllocator Allocator; - -public: - void *Allocate(size_t Size) { return Allocator.Allocate(Size, 0); } - void Deallocate(void *Slab, size_t Size) { Allocator.Deallocate(Slab, Size); } -}; - namespace detail { // We call out to an external function to actually print the message as the @@ -167,10 +154,10 @@ void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, /// 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 MallocSlabAllocator +/// 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. -template class BumpPtrAllocatorImpl : public AllocatorBase< @@ -241,7 +228,7 @@ public: // If Size is really big, allocate a separate slab for it. size_t PaddedSize = Size + Alignment - 1; if (PaddedSize > SizeThreshold) { - void *NewSlab = Allocator.Allocate(PaddedSize); + void *NewSlab = Allocator.Allocate(PaddedSize, 0); CustomSizedSlabs.push_back(std::make_pair(NewSlab, PaddedSize)); Ptr = alignPtr((char *)NewSlab, Alignment); @@ -319,7 +306,7 @@ private: void StartNewSlab() { size_t AllocatedSlabSize = computeSlabSize(Slabs.size()); - void *NewSlab = Allocator.Allocate(AllocatedSlabSize); + void *NewSlab = Allocator.Allocate(AllocatedSlabSize, 0); Slabs.push_back(NewSlab); CurPtr = (char *)(NewSlab); End = ((char *)NewSlab) + AllocatedSlabSize; -- cgit v1.2.3