| Index: Source/wtf/PartitionAllocTest.cpp
|
| diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp
|
| index fc1c1e85cc62df2e04d12ab8f5ae168445582ed4..3f20216dbae5ac1ad7e1d792834a3cddb9a15e70 100644
|
| --- a/Source/wtf/PartitionAllocTest.cpp
|
| +++ b/Source/wtf/PartitionAllocTest.cpp
|
| @@ -593,33 +593,39 @@ TEST(WTF_PartitionAlloc, GenericAllocGetSize)
|
| TestSetup();
|
|
|
| void* ptr;
|
| - size_t requestedSize, actualSize;
|
| + size_t requestedSize, actualSize, predictedSize;
|
|
|
| EXPECT_TRUE(partitionAllocSupportsGetSize());
|
|
|
| // Allocate something small.
|
| requestedSize = 511 - kExtraAllocSize;
|
| + predictedSize = partitionAllocPredictSize(genericAllocator.root(), requestedSize);
|
| ptr = partitionAllocGeneric(genericAllocator.root(), requestedSize);
|
| EXPECT_TRUE(ptr);
|
| actualSize = partitionAllocGetSize(ptr);
|
| + EXPECT_EQ(predictedSize, actualSize);
|
| EXPECT_LT(requestedSize, actualSize);
|
| partitionFreeGeneric(genericAllocator.root(), ptr);
|
|
|
| // Allocate a size that should be a perfect match for a bucket, because it
|
| // is an exact power of 2.
|
| requestedSize = (256 * 1024) - kExtraAllocSize;
|
| + predictedSize = partitionAllocPredictSize(genericAllocator.root(), requestedSize);
|
| ptr = partitionAllocGeneric(genericAllocator.root(), requestedSize);
|
| EXPECT_TRUE(ptr);
|
| actualSize = partitionAllocGetSize(ptr);
|
| + EXPECT_EQ(predictedSize, actualSize);
|
| EXPECT_EQ(requestedSize, actualSize);
|
| partitionFreeGeneric(genericAllocator.root(), ptr);
|
|
|
| // Allocate a size that is a system page smaller than a bucket. GetSize()
|
| // should return a larger size than we asked for now.
|
| requestedSize = (256 * 1024) - WTF::kSystemPageSize - kExtraAllocSize;
|
| + predictedSize = partitionAllocPredictSize(genericAllocator.root(), requestedSize);
|
| ptr = partitionAllocGeneric(genericAllocator.root(), requestedSize);
|
| EXPECT_TRUE(ptr);
|
| actualSize = partitionAllocGetSize(ptr);
|
| + EXPECT_EQ(predictedSize, actualSize);
|
| EXPECT_EQ(requestedSize + WTF::kSystemPageSize, actualSize);
|
| // Check that we can write at the end of the reported size too.
|
| char* charPtr = reinterpret_cast<char*>(ptr);
|
| @@ -628,12 +634,19 @@ TEST(WTF_PartitionAlloc, GenericAllocGetSize)
|
|
|
| // Allocate something very large, and uneven.
|
| requestedSize = 512 * 1024 * 1024 - 1;
|
| + predictedSize = partitionAllocPredictSize(genericAllocator.root(), requestedSize);
|
| ptr = partitionAllocGeneric(genericAllocator.root(), requestedSize);
|
| EXPECT_TRUE(ptr);
|
| actualSize = partitionAllocGetSize(ptr);
|
| + EXPECT_EQ(predictedSize, actualSize);
|
| EXPECT_LT(requestedSize, actualSize);
|
| partitionFreeGeneric(genericAllocator.root(), ptr);
|
|
|
| + // Too large allocation.
|
| + requestedSize = INT_MAX;
|
| + predictedSize = partitionAllocPredictSize(genericAllocator.root(), requestedSize);
|
| + EXPECT_EQ(requestedSize, predictedSize);
|
| +
|
| TestShutdown();
|
| }
|
|
|
|
|