Chromium Code Reviews| Index: Source/platform/heap/ThreadState.cpp |
| diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
| index 0a29fb295bc67d7cb8c0d61452c16041a11a0b2a..15ff1f7b015cc7f13351cfefd824ce1f168dbd6e 100644 |
| --- a/Source/platform/heap/ThreadState.cpp |
| +++ b/Source/platform/heap/ThreadState.cpp |
| @@ -40,7 +40,7 @@ |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebThread.h" |
| #include "wtf/ThreadingPrimitives.h" |
| -#if ENABLE(GC_PROFILE_HEAP) |
| +#if ENABLE(GC_PROFILE_HEAP) || ENABLE(GC_PROFILE_FREE_LIST) |
| #include "platform/TracedValue.h" |
| #endif |
| @@ -619,6 +619,53 @@ const GCInfo* ThreadState::findGCInfo(Address address) |
| } |
| #endif |
| +#if ENABLE(GC_PROFILE_FREE_LIST) |
| + |
| +void ThreadState::snapshotFreeListIfNecessary() |
|
keishi
2015/01/27 08:59:00
Call when a snapshot could be recorded to the trac
|
| +{ |
| + //bool gcTracingEnabled; |
| + //TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); |
| + //if (!gcTracingEnabled) |
| + // return; |
| + const double kRecordInterval = 0.010; // seconds |
| + static double nextRecordTime = monotonicallyIncreasingTime() + kRecordInterval; |
| + if (monotonicallyIncreasingTime() > nextRecordTime) { |
| + snapshotFreeList(); |
| + nextRecordTime = monotonicallyIncreasingTime() + kRecordInterval; |
| + } |
| +} |
| + |
| +void ThreadState::snapshotFreeList() |
|
keishi
2015/01/27 08:59:00
Records the stats from the heap.
|
| +{ |
| + RefPtr<TracedValue> json = TracedValue::create(); |
| + |
| +#define SNAPSHOT_FREE_LIST(HeapType) \ |
| + { \ |
| + json->beginDictionary(); \ |
| + json->setString("name", #HeapType); \ |
| + m_heaps[HeapType##Heap]->snapshotFreeList(json.get()); \ |
| + json->endDictionary(); \ |
| + json->beginDictionary(); \ |
| + json->setString("name", #HeapType"NonFinalized"); \ |
| + m_heaps[HeapType##HeapNonFinalized]->snapshotFreeList(json.get()); \ |
| + json->endDictionary(); \ |
| + } |
| + json->beginArray("heaps"); |
| + SNAPSHOT_FREE_LIST(General1); |
| + SNAPSHOT_FREE_LIST(General2); |
| + SNAPSHOT_FREE_LIST(General3); |
| + SNAPSHOT_FREE_LIST(General4); |
| + SNAPSHOT_FREE_LIST(VectorBacking); |
| + SNAPSHOT_FREE_LIST(HashTableBacking); |
| + FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST); |
| + json->endArray(); |
| +#undef SNAPSHOT_FREE_LIST |
| + |
| + TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "FreeList", this, json.release()); |
| +} |
| + |
| +#endif |
| + |
| #if ENABLE(GC_PROFILE_HEAP) |
| size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcinfo) |
| { |
| @@ -1015,7 +1062,7 @@ void ThreadState::performPendingSweep() |
| { |
| if (!sweepRequested()) |
| return; |
| - |
| + Heap::reportSweepingStats(); |
|
keishi
2015/01/27 08:59:00
Report stats on the objects that will be sweeped.
|
| #if ENABLE(GC_PROFILE_HEAP) |
| // We snapshot the heap prior to sweeping to get numbers for both resources |
| // that have been allocated since the last GC and for resources that are |
| @@ -1090,6 +1137,9 @@ void ThreadState::performPendingSweep() |
| TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); |
| ScriptForbiddenScope::exit(); |
| } |
| +#if ENABLE(GC_PROFILE_FREE_LIST) |
| + snapshotFreeListIfNecessary(); |
| +#endif |
| } |
| void ThreadState::addInterruptor(Interruptor* interruptor) |