mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
BumpPtrAllocator: remove 'no slabs allocated yet' check
We already handle the no-slabs case when checking whether the current slab is large enough: if no slabs have been allocated, CurPtr and End are both 0. alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails. Differential Revision: http://reviews.llvm.org/D4943 llvm-svn: 215841
This commit is contained in:
parent
b81f06cd2c
commit
5a2722e909
@ -201,9 +201,6 @@ public:
|
|||||||
|
|
||||||
/// \brief Allocate space at the specified alignment.
|
/// \brief Allocate space at the specified alignment.
|
||||||
void *Allocate(size_t Size, size_t Alignment) {
|
void *Allocate(size_t Size, size_t Alignment) {
|
||||||
if (!CurPtr) // Start a new slab if we haven't allocated one already.
|
|
||||||
StartNewSlab();
|
|
||||||
|
|
||||||
// Keep track of how many bytes we've allocated.
|
// Keep track of how many bytes we've allocated.
|
||||||
BytesAllocated += Size;
|
BytesAllocated += Size;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ TEST(AllocatorTest, TestSmallSlabSize) {
|
|||||||
BumpPtrAllocator Alloc;
|
BumpPtrAllocator Alloc;
|
||||||
|
|
||||||
Alloc.Allocate(8000, 0);
|
Alloc.Allocate(8000, 0);
|
||||||
EXPECT_EQ(2U, Alloc.GetNumSlabs());
|
EXPECT_EQ(1U, Alloc.GetNumSlabs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no
|
// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no
|
||||||
|
Loading…
x
Reference in New Issue
Block a user