Chromium Code Reviews| 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; |