Chromium Code Reviews| Index: Source/wtf/PartitionAllocTest.cpp |
| diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp |
| index 531fcd4f70a4547e4d6ee1ace34097ab26b30527..9b151ca3e41cbf76db005deb00e5c20f968f3e54 100644 |
| --- a/Source/wtf/PartitionAllocTest.cpp |
| +++ b/Source/wtf/PartitionAllocTest.cpp |
| @@ -692,6 +692,23 @@ TEST(WTF_PartitionAlloc, Realloc) |
| partitionFreeGeneric(genericAllocator.root(), ptr); |
| + // Test that shrinking a direct mapped allocation happens in-place. |
| + size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize; |
| + EXPECT_TRUE(WTF::partitionSizeIsDirectMapped(size)); |
|
Chris Evans
2014/03/05 07:57:04
We can avoid making this a public API by getting t
|
| + ptr = partitionAllocGeneric(genericAllocator.root(), size); |
| + size_t actualSize = partitionAllocGetSize(ptr); |
| + ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, size - 2 * WTF::kSystemPageSize); |
| + EXPECT_EQ(ptr, ptr2); |
| + EXPECT_EQ(actualSize - 2 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2)); |
| + |
| + // Test that a previously in-place shrunk direct mapped allocation can be |
| + // expanded up again within its original size. |
| + ptr = partitionReallocGeneric(genericAllocator.root(), ptr2, size - WTF::kSystemPageSize); |
| + EXPECT_EQ(ptr2, ptr); |
| + EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr)); |
| + |
| + partitionFreeGeneric(genericAllocator.root(), ptr); |
| + |
| TestShutdown(); |
| } |