diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-08-28 01:02:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-08-28 01:02:21 +0000 |
commit | 7f9a887d3f64d1227b911c9180767d95dbba4c10 (patch) | |
tree | f87a029ca26678f9d5da5111781ba1f121220f62 /lib/Support | |
parent | a796d90c0ed7ebd5d58fced43c60afc2e9bf6225 (diff) | |
download | external_llvm-7f9a887d3f64d1227b911c9180767d95dbba4c10.zip external_llvm-7f9a887d3f64d1227b911c9180767d95dbba4c10.tar.gz external_llvm-7f9a887d3f64d1227b911c9180767d95dbba4c10.tar.bz2 |
[BumpPtrAllocator] Move DefaultSlabAllocator to a member of BumpPtrAllocator, instead of a static variable.
The problem with having DefaultSlabAllocator being a global static is that it is undefined if BumpPtrAllocator
will be usable during global initialization because it is not guaranteed that DefaultSlabAllocator will be
initialized before BumpPtrAllocator is created and used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189433 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Allocator.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 3c4191b..6e7a541 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -26,6 +26,10 @@ BumpPtrAllocator::BumpPtrAllocator(size_t size, size_t threshold, : SlabSize(size), SizeThreshold(std::min(size, threshold)), Allocator(allocator), CurSlab(0), BytesAllocated(0) { } +BumpPtrAllocator::BumpPtrAllocator(size_t size, size_t threshold) + : SlabSize(size), SizeThreshold(std::min(size, threshold)), + Allocator(DefaultSlabAllocator), CurSlab(0), BytesAllocated(0) { } + BumpPtrAllocator::~BumpPtrAllocator() { DeallocateSlabs(CurSlab); } @@ -167,9 +171,6 @@ void BumpPtrAllocator::PrintStats() const { << " (includes alignment, etc)\n"; } -MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator = - MallocSlabAllocator(); - SlabAllocator::~SlabAllocator() { } MallocSlabAllocator::~MallocSlabAllocator() { } |