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

Unified Diff: Source/wtf/PartitionAlloc.h

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
Index: Source/wtf/PartitionAlloc.h
diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h
index 0153c6c9202b312cf16df8c1aa966b9d88bbaafd..d7a4b01255b17a0ab0f8b40996b224245efa167a 100644
--- a/Source/wtf/PartitionAlloc.h
+++ b/Source/wtf/PartitionAlloc.h
@@ -276,6 +276,9 @@ struct PartitionSuperPageExtentEntry {
PartitionSuperPageExtentEntry* next;
};
+// This callback can be called on any thread.
Chris Evans 2015/04/06 04:39:53 Nit: also document that it's illegal to re-enter P
haraken 2015/04/06 06:14:14 Done.
+typedef void (*NotifyCommittedMemoryChangedFunction)();
+
struct WTF_EXPORT PartitionRootBase {
size_t totalSizeOfCommittedPages;
size_t totalSizeOfSuperPages;
@@ -292,6 +295,7 @@ struct WTF_EXPORT PartitionRootBase {
PartitionPage* globalEmptyPageRing[kMaxFreeableSpans];
int16_t globalEmptyPageRingIndex;
uintptr_t invertedSelf;
+ NotifyCommittedMemoryChangedFunction notifyCommittedMemoryChangedFunction;
static int gInitializedLock;
static bool gInitialized;
@@ -329,9 +333,9 @@ enum PartitionAllocFlags {
PartitionAllocReturnNull = 1 << 0,
};
-WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t maxAllocation);
+WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t maxAllocation, NotifyCommittedMemoryChangedFunction);
WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*);
-WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*);
+WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*, NotifyCommittedMemoryChangedFunction);
WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*);
WTF_EXPORT NEVER_INLINE void* partitionAllocSlowPath(PartitionRootBase*, int, size_t, PartitionBucket*);
@@ -667,7 +671,10 @@ class SizeSpecificPartitionAllocator {
public:
static const size_t kMaxAllocation = N - kAllocationGranularity;
static const size_t kNumBuckets = N / kAllocationGranularity;
- void init() { partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocation); }
+ void init(NotifyCommittedMemoryChangedFunction notifyCommittedMemoryChangedFunction = nullptr)
+ {
+ partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocation, notifyCommittedMemoryChangedFunction);
+ }
bool shutdown() { return partitionAllocShutdown(&m_partitionRoot); }
ALWAYS_INLINE PartitionRoot* root() { return &m_partitionRoot; }
private:
@@ -677,7 +684,10 @@ private:
class PartitionAllocatorGeneric {
public:
- void init() { partitionAllocGenericInit(&m_partitionRoot); }
+ void init(NotifyCommittedMemoryChangedFunction notifyCommittedMemoryChangedFunction = nullptr)
+ {
+ partitionAllocGenericInit(&m_partitionRoot, notifyCommittedMemoryChangedFunction);
+ }
bool shutdown() { return partitionAllocGenericShutdown(&m_partitionRoot); }
ALWAYS_INLINE PartitionRootGeneric* root() { return &m_partitionRoot; }
private:

Powered by Google App Engine
This is Rietveld 408576698