Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1978)

Unified Diff: Source/wtf/PartitionAllocTest.cpp

Issue 254103003: PartitionAlloc: Make in-place realloc() less likely to happen (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: extended test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAllocTest.cpp
diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp
index 9cbdce5652d9ac9c43b7046b41ae7c556f8bf633..f555e385e7ef5bebeb5d11be3ceeb379d0450f92 100644
--- a/Source/wtf/PartitionAllocTest.cpp
+++ b/Source/wtf/PartitionAllocTest.cpp
@@ -692,14 +692,13 @@ TEST(PartitionAllocTest, Realloc)
partitionFreeGeneric(genericAllocator.root(), ptr);
- // Test that shrinking a direct mapped allocation happens in-place (even
- // though the new size is smaller than kGenericMaxBucketed).
+ // Test that shrinking a direct mapped allocation happens in-place.
size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize;
ptr = partitionAllocGeneric(genericAllocator.root(), size);
size_t actualSize = partitionAllocGetSize(ptr);
- ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMaxBucketed - 16 * WTF::kSystemPageSize);
+ ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMaxBucketed + 8 * WTF::kSystemPageSize);
EXPECT_EQ(ptr, ptr2);
- EXPECT_EQ(actualSize - 32 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2));
+ EXPECT_EQ(actualSize - 8 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2));
// Test that a previously in-place shrunk direct mapped allocation can be
// expanded up again within its original size.
@@ -707,7 +706,12 @@ TEST(PartitionAllocTest, Realloc)
EXPECT_EQ(ptr2, ptr);
EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr));
- partitionFreeGeneric(genericAllocator.root(), ptr);
+ // Test that a direct mapped allocation is performed not in-place when the
+ // new size is small enough.
+ ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kSystemPageSize);
+ EXPECT_NE(ptr, ptr2);
+
+ partitionFreeGeneric(genericAllocator.root(), ptr2);
TestShutdown();
}
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698