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

Unified Diff: Source/wtf/PartitionAlloc.cpp

Issue 180293003: Simplify partitionReallocGeneric() implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAlloc.cpp
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
index 9a18bd4ab0fdce43efa1bc6563fe59f1dc8c3fbd..2621cd415104b03e7860c465d9989aa7ab49db5b 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -775,26 +775,21 @@ void* partitionReallocGeneric(PartitionRootGeneric* root, void* ptr, size_t newS
return 0;
}
- // TODO: note that tcmalloc will "ignore" a downsizing realloc() unless the
Chris Evans 2014/02/26 00:22:52 This TODO is not TO-DONE :) so I'm not sure why it
Jens Widell 2014/02/26 05:45:44 Sorry about that; quite sloppy of me. Will restore
- // new size is a significant percentage smaller. We could do the same if we
- // determine it is a win.
- void* realPtr = partitionCookieFreePointerAdjust(ptr);
- ASSERT(partitionPointerIsValid(realPtr));
- PartitionPage* oldPage = partitionPointerToPage(realPtr);
- PartitionBucket* oldBucket = oldPage->bucket;
-
- size_t allocSize = partitionCookieSizeAdjustAdd(newSize);
- PartitionBucket* newBucket = partitionGenericSizeToBucket(root, allocSize);
-
- // TODO: for a downsize on a direct mapped allocation, we really should
Chris Evans 2014/02/26 00:22:52 This TODO is also not TO-DONE. So we might want to
- // just de-commit the correct number of pages off the end.
- if (oldBucket == newBucket)
+ ASSERT(partitionPointerIsValid(partitionCookieFreePointerAdjust(ptr)));
+
+ size_t actualNewSize = partitionAllocActualSize(root, newSize);
Chris Evans 2014/02/26 00:22:52 Don't we need partitionCookieSizeAdjustAdd() aroun
Jens Widell 2014/02/26 05:45:44 We don't need it for the comparison to actualOldSi
+ size_t actualOldSize = partitionAllocGetSize(ptr);
+
+ if (actualNewSize == actualOldSize) {
+ // Trying to allocate a block of size newSize would give us a block of
+ // the same size as the one we've already got, so no point in doing
+ // anything here.
return ptr;
+ }
// This realloc cannot be resized in-place. Sadness.
void* ret = partitionAllocGeneric(root, newSize);
- size_t copySize = oldPage->bucket->slotSize;
- copySize = partitionCookieSizeAdjustSubtract(copySize);
+ size_t copySize = actualOldSize;
Chris Evans 2014/02/26 00:22:52 I think the loss of the partitionCookieSizeAdjustS
Jens Widell 2014/02/26 05:45:44 I don't see it. This function is now only using "p
if (newSize < copySize)
copySize = newSize;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698