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

Side by Side Diff: Source/wtf/PartitionAllocTest.cpp

Issue 183113003: PartitionAlloc: support in-place resize of directly mapped allocation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nits addressed Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 EXPECT_NE(ptr2, ptr); 685 EXPECT_NE(ptr2, ptr);
686 char* charPtr = static_cast<char*>(ptr); 686 char* charPtr = static_cast<char*>(ptr);
687 EXPECT_EQ('A', charPtr[0]); 687 EXPECT_EQ('A', charPtr[0]);
688 EXPECT_EQ('A', charPtr[size - 2]); 688 EXPECT_EQ('A', charPtr[size - 2]);
689 #ifndef NDEBUG 689 #ifndef NDEBUG
690 EXPECT_EQ(WTF::kUninitializedByte, static_cast<unsigned char>(charPtr[size - 1])); 690 EXPECT_EQ(WTF::kUninitializedByte, static_cast<unsigned char>(charPtr[size - 1]));
691 #endif 691 #endif
692 692
693 partitionFreeGeneric(genericAllocator.root(), ptr); 693 partitionFreeGeneric(genericAllocator.root(), ptr);
694 694
695 // Test that shrinking a direct mapped allocation happens in-place (even
696 // though the new size is smaller than kGenericMaxBucketed).
697 size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize;
698 ptr = partitionAllocGeneric(genericAllocator.root(), size);
699 size_t actualSize = partitionAllocGetSize(ptr);
700 ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMa xBucketed - 16 * WTF::kSystemPageSize);
701 EXPECT_EQ(ptr, ptr2);
702 EXPECT_EQ(actualSize - 32 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2 ));
703
704 // Test that a previously in-place shrunk direct mapped allocation can be
705 // expanded up again within its original size.
706 ptr = partitionReallocGeneric(genericAllocator.root(), ptr2, size - WTF::kSy stemPageSize);
707 EXPECT_EQ(ptr2, ptr);
708 EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr));
709
710 partitionFreeGeneric(genericAllocator.root(), ptr);
711
695 TestShutdown(); 712 TestShutdown();
696 } 713 }
697 714
698 // Tests the handing out of freelists for partial pages. 715 // Tests the handing out of freelists for partial pages.
699 TEST(WTF_PartitionAlloc, PartialPageFreelists) 716 TEST(WTF_PartitionAlloc, PartialPageFreelists)
700 { 717 {
701 TestSetup(); 718 TestSetup();
702 719
703 size_t bigSize = allocator.root()->maxAllocation - kExtraAllocSize; 720 size_t bigSize = allocator.root()->maxAllocation - kExtraAllocSize;
704 EXPECT_EQ(WTF::kSystemPageSize - WTF::kAllocationGranularity, bigSize + kExt raAllocSize); 721 EXPECT_EQ(WTF::kSystemPageSize - WTF::kAllocationGranularity, bigSize + kExt raAllocSize);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0)); 1169 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0));
1153 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1)); 1170 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1));
1154 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30)); 1171 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30));
1155 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31)); 1172 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31));
1156 #endif 1173 #endif
1157 } 1174 }
1158 1175
1159 } // namespace 1176 } // namespace
1160 1177
1161 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 1178 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
OLDNEW
« 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