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

Unified Diff: Source/wtf/PartitionAlloc.cpp

Issue 1053793004: Add a UseCounter that measures the amount of memory used in PartitionAlloc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | « Source/web/WebKit.cpp ('k') | Source/wtf/Partitions.h » ('j') | 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 43fd01be3a08a82bcb8924c492edd71c1eff0245..43495bfe8b3550224bcabd1a67baf7b16934589f 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -328,18 +328,28 @@ static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root)
IMMEDIATE_CRASH();
}
+static void partitionIncreaseCommittedPages(PartitionRootBase* root, size_t len)
+{
+ root->totalSizeOfCommittedPages += len;
+ ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+}
+
+static void partitionDecreaseCommittedPages(PartitionRootBase* root, size_t len)
+{
+ root->totalSizeOfCommittedPages -= len;
+ ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+}
+
static ALWAYS_INLINE void partitionDecommitSystemPages(PartitionRootBase* root, void* addr, size_t len)
{
decommitSystemPages(addr, len);
- ASSERT(root->totalSizeOfCommittedPages >= len);
- root->totalSizeOfCommittedPages -= len;
+ partitionDecreaseCommittedPages(root, len);
}
static ALWAYS_INLINE void partitionRecommitSystemPages(PartitionRootBase* root, void* addr, size_t len)
{
recommitSystemPages(addr, len);
- root->totalSizeOfCommittedPages += len;
- ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+ partitionIncreaseCommittedPages(root, len);
}
static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root, int flags, uint16_t numPartitionPages)
@@ -354,8 +364,7 @@ static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root,
// allocation.
char* ret = root->nextPartitionPage;
root->nextPartitionPage += totalSize;
- root->totalSizeOfCommittedPages += totalSize;
- ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+ partitionIncreaseCommittedPages(root, totalSize);
return ret;
}
@@ -368,8 +377,7 @@ static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root,
return 0;
root->totalSizeOfSuperPages += kSuperPageSize;
- root->totalSizeOfCommittedPages += totalSize;
- ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+ partitionIncreaseCommittedPages(root, totalSize);
root->nextSuperPage = superPage + kSuperPageSize;
char* ret = superPage + kPartitionPageSize;
@@ -612,9 +620,8 @@ static ALWAYS_INLINE void* partitionDirectMap(PartitionRootBase* root, int flags
mapSize &= kPageAllocationGranularityBaseMask;
size_t committedPageSize = size + kSystemPageSize;
- root->totalSizeOfCommittedPages += committedPageSize;
root->totalSizeOfDirectMappedPages += committedPageSize;
- ASSERT(root->totalSizeOfCommittedPages <= root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages);
+ partitionIncreaseCommittedPages(root, committedPageSize);
// TODO: we may want to let the operating system place these allocations
// where it pleases. On 32-bit, this might limit address space
@@ -677,8 +684,7 @@ static ALWAYS_INLINE void partitionDirectUnmap(PartitionPage* page)
PartitionRootBase* root = partitionPageToRoot(page);
size_t uncommittedPageSize = page->bucket->slotSize + kSystemPageSize;
- ASSERT(root->totalSizeOfCommittedPages >= uncommittedPageSize);
- root->totalSizeOfCommittedPages -= uncommittedPageSize;
+ partitionDecreaseCommittedPages(root, uncommittedPageSize);
ASSERT(root->totalSizeOfDirectMappedPages >= uncommittedPageSize);
root->totalSizeOfDirectMappedPages -= uncommittedPageSize;
« no previous file with comments | « Source/web/WebKit.cpp ('k') | Source/wtf/Partitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698