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

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

Issue 1153473011: For large (but not direct mapped) allocations, track the real allocation size. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More review feedback. Created 5 years, 6 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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 partitionFreeGeneric(genericAllocator.root(), ptr); 1466 partitionFreeGeneric(genericAllocator.root(), ptr);
1467 1467
1468 // Whilst we're here, allocate again and free with different ordering 1468 // Whilst we're here, allocate again and free with different ordering
1469 // to give a workout to our linked list code. 1469 // to give a workout to our linked list code.
1470 ptr = partitionAllocGeneric(genericAllocator.root(), sizeSmaller); 1470 ptr = partitionAllocGeneric(genericAllocator.root(), sizeSmaller);
1471 ptr2 = partitionAllocGeneric(genericAllocator.root(), sizeBigger); 1471 ptr2 = partitionAllocGeneric(genericAllocator.root(), sizeBigger);
1472 partitionFreeGeneric(genericAllocator.root(), ptr); 1472 partitionFreeGeneric(genericAllocator.root(), ptr);
1473 partitionFreeGeneric(genericAllocator.root(), ptr2); 1473 partitionFreeGeneric(genericAllocator.root(), ptr2);
1474 } 1474 }
1475 1475
1476 // This test checks large-but-not-quite-direct allocations.
1477 {
1478 void* ptr = partitionAllocGeneric(genericAllocator.root(), 65537);
1479
1480 {
1481 MockPartitionStatsDumper mockStatsDumperGeneric;
1482 partitionDumpStatsGeneric(genericAllocator.root(), "mock_generic_all ocator", &mockStatsDumperGeneric);
1483 EXPECT_TRUE(mockStatsDumperGeneric.IsMemoryAllocationRecorded());
1484
1485 size_t slotSize = 65536 + (65536 / WTF::kGenericNumBucketsPerOrder);
1486 const WTF::PartitionBucketMemoryStats* stats = mockStatsDumperGeneri c.GetBucketStats(slotSize);
1487 EXPECT_TRUE(stats);
1488 EXPECT_TRUE(stats->isValid);
1489 EXPECT_FALSE(stats->isDirectMap);
1490 EXPECT_EQ(slotSize, stats->bucketSlotSize);
1491 EXPECT_EQ(65536 + WTF::kSystemPageSize, stats->activeBytes);
1492 EXPECT_EQ(slotSize, stats->residentBytes);
1493 EXPECT_EQ(0u, stats->freeableBytes);
1494 EXPECT_EQ(1u, stats->numFullPages);
1495 EXPECT_EQ(0u, stats->numActivePages);
1496 EXPECT_EQ(0u, stats->numEmptyPages);
1497 EXPECT_EQ(0u, stats->numDecommittedPages);
1498 }
1499
1500 partitionFreeGeneric(genericAllocator.root(), ptr);
1501 }
1502
1476 TestShutdown(); 1503 TestShutdown();
1477 } 1504 }
1478 1505
1479 // Tests the API to purge freeable memory. 1506 // Tests the API to purge freeable memory.
1480 TEST(PartitionAllocTest, Purge) 1507 TEST(PartitionAllocTest, Purge)
1481 { 1508 {
1482 TestSetup(); 1509 TestSetup();
1483 1510
1484 void* ptr = partitionAllocGeneric(genericAllocator.root(), 2048 - kExtraAllo cSize); 1511 void* ptr = partitionAllocGeneric(genericAllocator.root(), 2048 - kExtraAllo cSize);
1485 partitionFreeGeneric(genericAllocator.root(), ptr); 1512 partitionFreeGeneric(genericAllocator.root(), ptr);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0u)); 1560 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0u));
1534 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1u)); 1561 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1u));
1535 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1u << 30)); 1562 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1u << 30));
1536 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1u << 31)); 1563 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1u << 31));
1537 #endif 1564 #endif
1538 } 1565 }
1539 1566
1540 } // namespace 1567 } // namespace
1541 1568
1542 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 1569 #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