Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index be833d48df1d3d438cf739bb075f529a3b73b55b..131b6afdda68f89849f4416e59320b4756a3aa33 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -670,6 +670,12 @@ void ThreadState::snapshot() |
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "ThreadState", this, json.release()); |
} |
+ |
+void ThreadState::incrementMarkedObjectsAge() |
+{ |
+ for (int i = 0; i < NumberOfHeaps; ++i) |
+ m_heaps[i]->incrementMarkedObjectsAge(); |
+} |
#endif |
void ThreadState::pushWeakPointerCallback(void* object, WeakPointerCallback callback) |
@@ -990,6 +996,25 @@ void ThreadState::preGC() |
void ThreadState::postGC(GCType gcType) |
{ |
ASSERT(isInGC()); |
+ |
+#if ENABLE(GC_PROFILING) |
+ // 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 |
+ // going to be freed. |
+ bool gcTracingEnabled; |
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); |
+ |
+ if (gcTracingEnabled) { |
+ bool disabledByDefaultGCTracingEnabled; |
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc"), &disabledByDefaultGCTracingEnabled); |
+ |
+ snapshot(); |
+ if (disabledByDefaultGCTracingEnabled) |
+ collectAndReportMarkSweepStats(); |
+ incrementMarkedObjectsAge(); |
+ } |
+#endif |
+ |
setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled); |
for (int i = 0; i < NumberOfHeaps; i++) |
m_heaps[i]->prepareForSweep(); |
@@ -1130,16 +1155,6 @@ void ThreadState::postGCProcessing() |
m_didV8GCAfterLastGC = false; |
-#if ENABLE(GC_PROFILING) |
- // 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 |
- // going to be freed. |
- bool gcTracingEnabled; |
- TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); |
- if (gcTracingEnabled) |
- snapshot(); |
-#endif |
- |
{ |
if (isMainThread()) |
ScriptForbiddenScope::enter(); |
@@ -1300,6 +1315,34 @@ void ThreadState::snapshotFreeList() |
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "FreeList", this, json.release()); |
} |
+ |
+void ThreadState::collectAndReportMarkSweepStats() const |
+{ |
+ if (!isMainThread()) |
haraken
2015/02/06 06:39:20
Why do we need to have the isMainThread check? Thr
Yuta Kitamura
2015/02/06 07:45:45
The reason is that data from non-main thread makes
haraken
2015/02/06 07:51:50
Thanks, makes sense.
keishi
2015/02/06 08:21:07
All records in the trace json file have tid fields
|
+ return; |
+ |
+ ClassAgeCountsMap markingClassAgeCounts; |
+ for (int i = 0; i < NumberOfHeaps; ++i) |
+ m_heaps[i]->countMarkedObjects(markingClassAgeCounts); |
+ reportMarkSweepStats("MarkingStats", markingClassAgeCounts); |
+ |
+ ClassAgeCountsMap sweepingClassAgeCounts; |
+ for (int i = 0; i < NumberOfHeaps; ++i) |
+ m_heaps[i]->countObjectsToSweep(sweepingClassAgeCounts); |
+ reportMarkSweepStats("SweepingStats", sweepingClassAgeCounts); |
+} |
+ |
+void ThreadState::reportMarkSweepStats(const char* statsName, const ClassAgeCountsMap& classAgeCounts) const |
+{ |
+ RefPtr<TracedValue> json = TracedValue::create(); |
+ for (ClassAgeCountsMap::const_iterator it = classAgeCounts.begin(), end = classAgeCounts.end(); it != end; ++it) { |
+ json->beginArray(it->key.ascii().data()); |
+ for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
+ json->pushInteger(it->value.ages[age]); |
+ json->endArray(); |
+ } |
+ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), statsName, this, json.release()); |
+} |
#endif |
} // namespace blink |