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

Side by Side Diff: third_party/WebKit/Source/wtf/allocator/PartitionAlloc.cpp

Issue 1992873004: Replace all occurrences of RELEASE_ASSERT in wtf with CHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Specialized dchecks in utils.h. Created 4 years, 7 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // TODO: we end up using a lot of system pages for very small sizes. For 73 // TODO: we end up using a lot of system pages for very small sizes. For
74 // example, we'll use 12 system pages for slot size 24. The slot size is 74 // example, we'll use 12 system pages for slot size 24. The slot size is
75 // so small that the waste would be tiny with just 4, or 1, system pages. 75 // so small that the waste would be tiny with just 4, or 1, system pages.
76 // Later, we can investigate whether there are anti-fragmentation benefits 76 // Later, we can investigate whether there are anti-fragmentation benefits
77 // to using fewer system pages. 77 // to using fewer system pages.
78 double bestWasteRatio = 1.0f; 78 double bestWasteRatio = 1.0f;
79 uint16_t bestPages = 0; 79 uint16_t bestPages = 0;
80 if (size > kMaxSystemPagesPerSlotSpan * kSystemPageSize) { 80 if (size > kMaxSystemPagesPerSlotSpan * kSystemPageSize) {
81 ASSERT(!(size % kSystemPageSize)); 81 ASSERT(!(size % kSystemPageSize));
82 bestPages = static_cast<uint16_t>(size / kSystemPageSize); 82 bestPages = static_cast<uint16_t>(size / kSystemPageSize);
83 RELEASE_ASSERT(bestPages < (1 << 8)); 83 CHECK_LT(bestPages, 1 << 8);
84 return static_cast<uint8_t>(bestPages); 84 return static_cast<uint8_t>(bestPages);
85 } 85 }
86 ASSERT(size <= kMaxSystemPagesPerSlotSpan * kSystemPageSize); 86 ASSERT(size <= kMaxSystemPagesPerSlotSpan * kSystemPageSize);
87 for (uint16_t i = kNumSystemPagesPerPartitionPage - 1; i <= kMaxSystemPagesP erSlotSpan; ++i) { 87 for (uint16_t i = kNumSystemPagesPerPartitionPage - 1; i <= kMaxSystemPagesP erSlotSpan; ++i) {
88 size_t pageSize = kSystemPageSize * i; 88 size_t pageSize = kSystemPageSize * i;
89 size_t numSlots = pageSize / size; 89 size_t numSlots = pageSize / size;
90 size_t waste = pageSize - (numSlots * size); 90 size_t waste = pageSize - (numSlots * size);
91 // Leaving a page unfaulted is not free; the page will occupy an empty p age table entry. 91 // Leaving a page unfaulted is not free; the page will occupy an empty p age table entry.
92 // Make a simple attempt to account for that. 92 // Make a simple attempt to account for that.
93 size_t numRemainderPages = i & (kNumSystemPagesPerPartitionPage - 1); 93 size_t numRemainderPages = i & (kNumSystemPagesPerPartitionPage - 1);
94 size_t numUnfaultedPages = numRemainderPages ? (kNumSystemPagesPerPartit ionPage - numRemainderPages) : 0; 94 size_t numUnfaultedPages = numRemainderPages ? (kNumSystemPagesPerPartit ionPage - numRemainderPages) : 0;
95 waste += sizeof(void*) * numUnfaultedPages; 95 waste += sizeof(void*) * numUnfaultedPages;
96 double wasteRatio = (double) waste / (double) pageSize; 96 double wasteRatio = (double) waste / (double) pageSize;
97 if (wasteRatio < bestWasteRatio) { 97 if (wasteRatio < bestWasteRatio) {
98 bestWasteRatio = wasteRatio; 98 bestWasteRatio = wasteRatio;
99 bestPages = i; 99 bestPages = i;
100 } 100 }
101 } 101 }
102 ASSERT(bestPages > 0); 102 ASSERT(bestPages > 0);
103 RELEASE_ASSERT(bestPages <= kMaxSystemPagesPerSlotSpan); 103 CHECK_LE(bestPages, kMaxSystemPagesPerSlotSpan);
104 return static_cast<uint8_t>(bestPages); 104 return static_cast<uint8_t>(bestPages);
105 } 105 }
106 106
107 static void partitionAllocBaseInit(PartitionRootBase* root) 107 static void partitionAllocBaseInit(PartitionRootBase* root)
108 { 108 {
109 ASSERT(!root->initialized); 109 ASSERT(!root->initialized);
110 { 110 {
111 SpinLock::Guard guard(PartitionRootBase::gInitializedLock); 111 SpinLock::Guard guard(PartitionRootBase::gInitializedLock);
112 if (!PartitionRootBase::gInitialized) { 112 if (!PartitionRootBase::gInitialized) {
113 PartitionRootBase::gInitialized = true; 113 PartitionRootBase::gInitialized = true;
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 1002
1003 // Shrink by decommitting unneeded pages and making them inaccessible. 1003 // Shrink by decommitting unneeded pages and making them inaccessible.
1004 size_t decommitSize = currentSize - newSize; 1004 size_t decommitSize = currentSize - newSize;
1005 partitionDecommitSystemPages(root, charPtr + newSize, decommitSize); 1005 partitionDecommitSystemPages(root, charPtr + newSize, decommitSize);
1006 setSystemPagesInaccessible(charPtr + newSize, decommitSize); 1006 setSystemPagesInaccessible(charPtr + newSize, decommitSize);
1007 } else if (newSize <= partitionPageToDirectMapExtent(page)->mapSize) { 1007 } else if (newSize <= partitionPageToDirectMapExtent(page)->mapSize) {
1008 // Grow within the actually allocated memory. Just need to make the 1008 // Grow within the actually allocated memory. Just need to make the
1009 // pages accessible again. 1009 // pages accessible again.
1010 size_t recommitSize = newSize - currentSize; 1010 size_t recommitSize = newSize - currentSize;
1011 bool ret = setSystemPagesAccessible(charPtr + currentSize, recommitSize) ; 1011 bool ret = setSystemPagesAccessible(charPtr + currentSize, recommitSize) ;
1012 RELEASE_ASSERT(ret); 1012 CHECK(ret);
1013 partitionRecommitSystemPages(root, charPtr + currentSize, recommitSize); 1013 partitionRecommitSystemPages(root, charPtr + currentSize, recommitSize);
1014 1014
1015 #if ENABLE(ASSERT) 1015 #if ENABLE(ASSERT)
1016 memset(charPtr + currentSize, kUninitializedByte, recommitSize); 1016 memset(charPtr + currentSize, kUninitializedByte, recommitSize);
1017 #endif 1017 #endif
1018 } else { 1018 } else {
1019 // We can't perform the realloc in-place. 1019 // We can't perform the realloc in-place.
1020 // TODO: support this too when possible. 1020 // TODO: support this too when possible.
1021 return false; 1021 return false;
1022 } 1022 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 partitionStats.totalDiscardableBytes += memoryStats[i].discardableBy tes; 1402 partitionStats.totalDiscardableBytes += memoryStats[i].discardableBy tes;
1403 if (!isLightDump) 1403 if (!isLightDump)
1404 partitionStatsDumper->partitionsDumpBucketStats(partitionName, & memoryStats[i]); 1404 partitionStatsDumper->partitionsDumpBucketStats(partitionName, & memoryStats[i]);
1405 } 1405 }
1406 } 1406 }
1407 partitionStatsDumper->partitionDumpTotals(partitionName, &partitionStats); 1407 partitionStatsDumper->partitionDumpTotals(partitionName, &partitionStats);
1408 } 1408 }
1409 1409
1410 } // namespace WTF 1410 } // namespace WTF
1411 1411
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698