Chromium Code Reviews| 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 | 695 // Test that shrinking a direct mapped allocation happens in-place. |
| 696 // though the new size is smaller than kGenericMaxBucketed). | |
| 697 size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize; | 696 size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize; |
| 698 ptr = partitionAllocGeneric(genericAllocator.root(), size); | 697 ptr = partitionAllocGeneric(genericAllocator.root(), size); |
| 699 size_t actualSize = partitionAllocGetSize(ptr); | 698 size_t actualSize = partitionAllocGetSize(ptr); |
| 700 ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMa xBucketed - 16 * WTF::kSystemPageSize); | 699 ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMa xBucketed + 8 * WTF::kSystemPageSize); |
| 701 EXPECT_EQ(ptr, ptr2); | 700 EXPECT_EQ(ptr, ptr2); |
| 702 EXPECT_EQ(actualSize - 32 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2 )); | 701 EXPECT_EQ(actualSize - 8 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2) ); |
|
Tom Sepez
2014/04/29 20:27:02
It would be nice to have a test case that shows, s
| |
| 703 | 702 |
| 704 // Test that a previously in-place shrunk direct mapped allocation can be | 703 // Test that a previously in-place shrunk direct mapped allocation can be |
| 705 // expanded up again within its original size. | 704 // expanded up again within its original size. |
| 706 ptr = partitionReallocGeneric(genericAllocator.root(), ptr2, size - WTF::kSy stemPageSize); | 705 ptr = partitionReallocGeneric(genericAllocator.root(), ptr2, size - WTF::kSy stemPageSize); |
| 707 EXPECT_EQ(ptr2, ptr); | 706 EXPECT_EQ(ptr2, ptr); |
| 708 EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr)); | 707 EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr)); |
| 709 | 708 |
| 710 partitionFreeGeneric(genericAllocator.root(), ptr); | 709 partitionFreeGeneric(genericAllocator.root(), ptr); |
| 711 | 710 |
| 712 TestShutdown(); | 711 TestShutdown(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0)); | 1172 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0)); |
| 1174 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1)); | 1173 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1)); |
| 1175 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30)); | 1174 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30)); |
| 1176 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31)); | 1175 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31)); |
| 1177 #endif | 1176 #endif |
| 1178 } | 1177 } |
| 1179 | 1178 |
| 1180 } // namespace | 1179 } // namespace |
| 1181 | 1180 |
| 1182 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 1181 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| OLD | NEW |