| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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) |
| OLD | NEW |