Chromium Code Reviews| Index: Source/wtf/PartitionAlloc.cpp |
| diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp |
| index a63a684c51980189aed9ab281b326c9f54d06ac4..f4fbdea72ba879b56c125489fad8f68134534a00 100644 |
| --- a/Source/wtf/PartitionAlloc.cpp |
| +++ b/Source/wtf/PartitionAlloc.cpp |
| @@ -112,6 +112,7 @@ static void parititonAllocBaseInit(PartitionRootBase* root) |
| spinLockUnlock(&PartitionRootBase::gInitializedLock); |
| root->initialized = true; |
| + root->totalSizeOfNonFreePages = 0; |
|
Chris Evans
2014/06/06 18:30:50
I think we should name this totalSizeOfCommittedPa
kouhei (in TOK)
2014/06/09 05:48:22
Done.
|
| root->totalSizeOfSuperPages = 0; |
| root->nextSuperPage = 0; |
| root->nextPartitionPage = 0; |
| @@ -314,6 +315,7 @@ 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->totalSizeOfNonFreePages += 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 |
| @@ -675,7 +677,9 @@ void* partitionAllocSlowPath(PartitionRootBase* root, int flags, size_t size, Pa |
| ASSERT(newPage->freeCacheIndex == -1); |
| bucket->freePagesHead = newPage->nextPage; |
| void* addr = partitionPageToPointer(newPage); |
| - recommitSystemPages(addr, newPage->bucket->numSystemPagesPerSlotSpan * kSystemPageSize); |
| + size_t commitSize = newPage->bucket->numSystemPagesPerSlotSpan * kSystemPageSize; |
| + recommitSystemPages(addr, commitSize); |
| + root->totalSizeOfNonFreePages += commitSize; |
|
Chris Evans
2014/06/06 18:30:50
I think this is the right model: adjusting the
H
kouhei (in TOK)
2014/06/09 05:48:22
Done. I added partition{Re,De}commitPages wrapper
|
| } else { |
| // Third. If we get here, we need a brand new page. |
| size_t numPartitionPages = partitionBucketPartitionPages(bucket); |
| @@ -710,6 +714,10 @@ static ALWAYS_INLINE void partitionFreePage(PartitionPage* page) |
| static ALWAYS_INLINE void partitionRegisterEmptyPage(PartitionPage* page) |
| { |
| PartitionRootBase* root = partitionPageToRoot(page); |
| + size_t pageSize = page->bucket->numSystemPagesPerSlotSpan * kSystemPageSize; |
| + ASSERT(root->totalSizeOfNonFreePages > pageSize); |
| + root->totalSizeOfNonFreePages -= pageSize; |
|
Chris Evans
2014/06/06 18:30:50
I do not think this is the correct place to do thi
kouhei (in TOK)
2014/06/09 05:48:22
Removed this, and moved counter decrement into par
|
| + |
| // If the page is already registered as empty, give it another life. |
| if (page->freeCacheIndex != -1) { |
| ASSERT(page->freeCacheIndex >= 0); |
| @@ -757,7 +765,7 @@ void partitionFreeSlowPath(PartitionPage* page) |
| partitionDirectUnmap(page); |
| return; |
| } |
| - // If it's the current page, attempt to change it. We'd prefer to leave |
| + // If it's the current active page, attempt to change it. We'd prefer to leave |
| // the page empty as a gentle force towards defragmentation. |
| if (LIKELY(page == bucket->activePagesHead) && page->nextPage) { |
| if (partitionSetNewActivePage(page->nextPage)) { |