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

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 883233003: Oilpan: Add free list profiler. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Change type of m_cumulativeAllocationSize to size_t. Created 5 years, 10 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/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 9bf8d7f1126397c00bfae27bae7fca6b16671a87..06240f27c3fa2cd1fca976e675ae58c09c5ab827 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -56,6 +56,10 @@ extern "C" void* __libc_stack_end; // NOLINT
#include <sanitizer/msan_interface.h>
#endif
+#if ENABLE(GC_PROFILING)
+#include <limits>
+#endif
+
#if OS(FREEBSD)
#include <pthread_np.h>
#endif
@@ -312,6 +316,9 @@ ThreadState::ThreadState()
#if defined(ADDRESS_SANITIZER)
, m_asanFakeStack(__asan_get_current_fake_stack())
#endif
+#if ENABLE(GC_PROFILING)
+ , m_nextFreeListSnapshotTime(-std::numeric_limits<double>::infinity())
+#endif
{
checkThread();
ASSERT(!**s_threadSpecific);
@@ -1088,6 +1095,10 @@ void ThreadState::postGCProcessing()
setGCState(Sweeping);
completeSweep();
#endif
+
+#if ENABLE(GC_PROFILING)
+ snapshotFreeListIfNecessary();
+#endif
}
void ThreadState::addInterruptor(Interruptor* interruptor)
@@ -1166,6 +1177,46 @@ const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
threadAttachMutex().unlock();
return nullptr;
}
+
+void ThreadState::snapshotFreeListIfNecessary()
+{
+ bool enabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc"), &enabled);
+ if (!enabled)
+ return;
+
+ static const double recordIntervalSeconds = 0.010;
+ double now = monotonicallyIncreasingTime();
+ if (now > m_nextFreeListSnapshotTime) {
+ snapshotFreeList();
+ m_nextFreeListSnapshotTime = now + recordIntervalSeconds;
+ }
+}
+
+void ThreadState::snapshotFreeList()
+{
+ RefPtr<TracedValue> json = TracedValue::create();
+
+#define SNAPSHOT_FREE_LIST(HeapType) \
+ { \
+ json->beginDictionary(); \
+ json->setString("name", #HeapType); \
+ m_heaps[HeapType##Heap]->snapshotFreeList(*json); \
+ json->endDictionary(); \
+ }
+
+ json->beginArray("heaps");
+ SNAPSHOT_FREE_LIST(General);
+ SNAPSHOT_FREE_LIST(VectorBacking);
+ SNAPSHOT_FREE_LIST(InlineVectorBacking);
+ SNAPSHOT_FREE_LIST(HashTableBacking);
+ FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST);
+ json->endArray();
+
+#undef SNAPSHOT_FREE_LIST
+
+ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "FreeList", this, json.release());
+}
#endif
} // namespace blink
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698