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

Unified Diff: Source/platform/heap/Heap.h

Issue 723513002: Oilpan: Refactor the way we calculate heap statistics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 1ddbf13997cb481c55d4e248f51df8a825ba7559..bc051441b31f3da2b6d3a916cb3175fa99489f73 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -37,6 +37,7 @@
#include "platform/heap/Visitor.h"
#include "public/platform/WebThread.h"
#include "wtf/Assertions.h"
+#include "wtf/Atomics.h"
#include "wtf/HashCountedSet.h"
#include "wtf/LinkedHashSet.h"
#include "wtf/ListHashSet.h"
@@ -116,7 +117,6 @@ enum CallbackInvocationMode {
};
class CallbackStack;
-class HeapStats;
class PageMemory;
template<ThreadAffinity affinity> class ThreadLocalPersistents;
template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTrait<T>::Affinity > > class Persistent;
@@ -263,7 +263,7 @@ public:
bool isMarked();
void unmark();
- void getStatsForTesting(HeapStats&);
+ size_t objectPayloadSizeForTesting();
void mark(Visitor*);
void finalize();
void setDeadMark();
@@ -537,9 +537,9 @@ public:
Address end() { return payload() + payloadSize(); }
- void getStatsForTesting(HeapStats&);
+ size_t objectPayloadSizeForTesting();
void clearLiveAndMarkDead();
- void sweep(HeapStats*, ThreadHeap<Header>*);
+ void sweep(ThreadHeap<Header>*);
void clearObjectStartBitMap();
void finalize(Header*);
virtual void checkAndMarkPointer(Visitor*, Address) override;
@@ -706,7 +706,7 @@ public:
// Sweep this part of the Blink heap. This finalizes dead objects
// and builds freelists for all the unused memory.
- virtual void sweep(HeapStats*) = 0;
+ virtual void sweep() = 0;
virtual void postSweepProcessing() = 0;
virtual void clearFreeLists() = 0;
@@ -716,7 +716,7 @@ public:
#if ENABLE(ASSERT)
virtual bool isConsistentForSweeping() = 0;
#endif
- virtual void getStatsForTesting(HeapStats&) = 0;
+ virtual size_t objectPayloadSizeForTesting() = 0;
virtual void updateRemainingAllocationSize() = 0;
@@ -776,7 +776,7 @@ public:
virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override;
#endif
- virtual void sweep(HeapStats*) override;
+ virtual void sweep() override;
virtual void postSweepProcessing() override;
virtual void clearFreeLists() override;
@@ -786,12 +786,11 @@ public:
#if ENABLE(ASSERT)
virtual bool isConsistentForSweeping() override;
#endif
- virtual void getStatsForTesting(HeapStats&) override;
+ virtual size_t objectPayloadSizeForTesting() override;
virtual void updateRemainingAllocationSize() override;
ThreadState* threadState() { return m_threadState; }
- HeapStats& stats() { return m_threadState->stats(); }
void addToFreeList(Address address, size_t size)
{
@@ -845,8 +844,8 @@ private:
bool pagesAllocatedDuringSweepingContains(Address);
#endif
- void sweepNormalPages(HeapStats*);
- void sweepLargePages(HeapStats*);
+ void sweepNormalPages();
+ void sweepLargePages();
bool coalesce(size_t);
Address m_currentAllocationPoint;
@@ -967,7 +966,7 @@ public:
static String createBacktraceString();
#endif
- static void getStatsForTesting(HeapStats*);
+ static size_t objectPayloadSizeForTesting();
static void getHeapSpaceSize(uint64_t*, uint64_t*);
@@ -993,6 +992,15 @@ public:
static void addPageMemoryRegion(PageMemoryRegion*);
static void removePageMemoryRegion(PageMemoryRegion*);
+ static void increaseAllocatedObjectSize(size_t delta) { atomicAdd(&s_allocatedObjectSize, static_cast<long>(delta)); }
+ static void decreaseAllocatedObjectSize(size_t delta) { atomicSubtract(&s_allocatedObjectSize, static_cast<long>(delta)); }
+ static size_t allocatedObjectSize() { return s_allocatedObjectSize; }
+ static void increaseMarkedObjectSize(size_t delta) { atomicAdd(&s_markedObjectSize, static_cast<long>(delta)); }
+ static size_t markedObjectSize() { return s_markedObjectSize; }
+ static void increaseAllocatedSpace(size_t delta) { atomicAdd(&s_allocatedSpace, static_cast<long>(delta)); }
+ static void decreaseAllocatedSpace(size_t delta) { atomicSubtract(&s_allocatedSpace, static_cast<long>(delta)); }
+ static size_t allocatedSpace() { return s_allocatedSpace; }
+
private:
// A RegionTree is a simple binary search tree of PageMemoryRegions sorted
// by base addresses.
@@ -1013,6 +1021,9 @@ private:
RegionTree* m_right;
};
+ static void resetAllocatedObjectSize() { ASSERT(ThreadState::isAnyThreadInGC()); s_allocatedObjectSize = 0; }
+ static void resetMarkedObjectSize() { ASSERT(ThreadState::isAnyThreadInGC()); s_markedObjectSize = 0; }
+
static Visitor* s_markingVisitor;
static Vector<OwnPtr<WebThread>>* s_markingThreads;
static CallbackStack* s_markingStack;
@@ -1025,6 +1036,9 @@ private:
static FreePagePool* s_freePagePool;
static OrphanedPagePool* s_orphanedPagePool;
static RegionTree* s_regionTree;
+ static size_t s_allocatedSpace;
+ static size_t s_allocatedObjectSize;
+ static size_t s_markedObjectSize;
friend class ThreadState;
};
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698