PartitionAlloc: Update totalSizeOf.* counters when allocation succeeds

This CL corrects the counter values in the cases of allocation failure.

Review URL: https://codereview.chromium.org/710963002

git-svn-id: svn://svn.chromium.org/blink/trunk@185026 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1d65fac8
......@@ -320,22 +320,25 @@ static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root,
ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPageEnd) % kPartitionPageSize));
RELEASE_ASSERT(numPartitionPages <= kNumPartitionPagesPerSuperPage);
size_t totalSize = kPartitionPageSize * numPartitionPages;
root->totalSizeOfCommittedPages += totalSize;
size_t numPartitionPagesLeft = (root->nextPartitionPageEnd - root->nextPartitionPage) >> kPartitionPageShift;
if (LIKELY(numPartitionPagesLeft >= numPartitionPages)) {
// In this case, we can still hand out pages from the current super page
// allocation.
char* ret = root->nextPartitionPage;
root->nextPartitionPage += totalSize;
root->totalSizeOfCommittedPages += totalSize;
return ret;
}
// Need a new super page.
root->totalSizeOfSuperPages += kSuperPageSize;
char* requestedAddress = root->nextSuperPage;
char* superPage = reinterpret_cast<char*>(allocPages(requestedAddress, kSuperPageSize, kSuperPageSize));
if (UNLIKELY(!superPage))
return 0;
root->totalSizeOfSuperPages += kSuperPageSize;
root->totalSizeOfCommittedPages += totalSize;
root->nextSuperPage = superPage + kSuperPageSize;
char* ret = superPage + kPartitionPageSize;
root->nextPartitionPage = ret + totalSize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment