Index: Source/platform/heap/Heap.h |
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h |
index 6c4781dec79f3c8180ed80eb1a2ec8bec88f4669..71df8deb8a8a968b41ca0bd1cbf08ecaf6baadfe 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(); |
@@ -534,9 +534,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; |
@@ -703,7 +703,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; |
@@ -713,7 +713,7 @@ public: |
#if ENABLE(ASSERT) |
virtual bool isConsistentForSweeping() = 0; |
#endif |
- virtual void getStatsForTesting(HeapStats&) = 0; |
+ virtual size_t objectPayloadSizeForTesting() = 0; |
virtual void updateRemainingAllocationSize() = 0; |
@@ -773,7 +773,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; |
@@ -783,12 +783,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) |
{ |
@@ -841,8 +840,8 @@ private: |
bool pagesAllocatedDuringSweepingContains(Address); |
#endif |
- void sweepNormalPages(HeapStats*); |
- void sweepLargePages(HeapStats*); |
+ void sweepNormalPages(); |
+ void sweepLargePages(); |
bool coalesce(size_t); |
Address m_currentAllocationPoint; |
@@ -963,12 +962,7 @@ public: |
static String createBacktraceString(); |
#endif |
- // Collect heap stats for all threads attached to the Blink |
- // garbage collector. Should only be called during garbage |
- // collection where threads are known to be at safe points. |
- static void getStats(HeapStats*); |
- |
- static void getStatsForTesting(HeapStats*); |
+ static size_t objectPayloadSizeForTesting(); |
static void getHeapSpaceSize(uint64_t*, uint64_t*); |
@@ -994,6 +988,17 @@ public: |
static void addPageMemoryRegion(PageMemoryRegion*); |
static void removePageMemoryRegion(PageMemoryRegion*); |
+ static void resetAllocatedObjectSize() { s_allocatedObjectSize = 0; } |
sof
2014/11/14 12:44:20
Add a comment to make it clearer why this doesn't
haraken
2014/11/14 15:15:00
Added ASSERT(ThreadState::isAnyThreadInGC()).
sof
2014/11/14 16:37:21
An assert is even better. I suppose there isn't a
haraken
2014/11/17 01:05:02
Done.
|
+ static void increaseAllocatedObjectSize(size_t delta) { atomicAdd(&s_allocatedObjectSize, delta); } |
+ static void decreaseAllocatedObjectSize(size_t delta) { atomicSubtract(&s_allocatedObjectSize, delta); } |
+ static size_t allocatedObjectSize() { return s_allocatedObjectSize; } |
+ static void resetLiveObjectSize() { s_liveObjectSize = 0; } |
+ static void increaseLiveObjectSize(size_t delta) { atomicAdd(&s_liveObjectSize, delta); } |
+ static size_t liveObjectSize() { return s_liveObjectSize; } |
+ static void increaseAllocatedSpace(size_t delta) { atomicAdd(&s_allocatedSpace, delta); } |
+ static void decreaseAllocatedSpace(size_t delta) { atomicSubtract(&s_allocatedSpace, delta); } |
+ static size_t allocatedSpace() { return s_allocatedSpace; } |
+ |
private: |
// A RegionTree is a simple binary search tree of PageMemoryRegions sorted |
// by base addresses. |
@@ -1026,6 +1031,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_liveObjectSize; |
friend class ThreadState; |
}; |