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

Unified Diff: src/heap/heap.cc

Issue 1094613002: Add a flag to trace heap object stats on GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 29e875c11a1c41a8d68d83b8831fb61973e82908..c3d44098620cdaf01c19e8fd6905bc60b0bee92c 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -6253,12 +6253,57 @@ void Heap::ClearObjectStats(bool clear_last_time_stats) {
}
-static base::LazyMutex checkpoint_object_stats_mutex = LAZY_MUTEX_INITIALIZER;
+static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER;
+
+
+static void TraceObjectStat(const char* name, int count, int size) {
+ if (size > 0) {
+ PrintF("%40s\tcount= %6d\t size= %6d kb\n", name, count, size);
+ }
+}
+
+
+void Heap::TraceObjectStats() {
+ base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer());
+ int index;
+ int count;
+ int size;
+ int total_size = 0;
+#define TRACE_OBJECT_COUNT(name) \
+ count = static_cast<int>(object_counts_[name]); \
+ size = static_cast<int>(object_sizes_[name]) / KB; \
+ total_size += size; \
+ TraceObjectStat(#name, count, size);
+ INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT)
+#undef TRACE_OBJECT_COUNT
+#define TRACE_OBJECT_COUNT(name) \
+ index = FIRST_CODE_KIND_SUB_TYPE + Code::name; \
+ count = static_cast<int>(object_counts_[index]); \
+ size = static_cast<int>(object_sizes_[index]) / KB; \
+ TraceObjectStat("CODE_" #name, count, size);
+ CODE_KIND_LIST(TRACE_OBJECT_COUNT)
+#undef TRACE_OBJECT_COUNT
+#define TRACE_OBJECT_COUNT(name) \
+ index = FIRST_FIXED_ARRAY_SUB_TYPE + name; \
+ count = static_cast<int>(object_counts_[index]); \
+ size = static_cast<int>(object_sizes_[index]) / KB; \
+ TraceObjectStat("FIXED_ARRAY_" #name, count, size);
+ FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT)
+#undef TRACE_OBJECT_COUNT
+#define TRACE_OBJECT_COUNT(name) \
+ index = \
+ FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge; \
+ count = static_cast<int>(object_counts_[index]); \
+ size = static_cast<int>(object_sizes_[index]) / KB; \
+ TraceObjectStat("CODE_AGE_" #name, count, size);
+ CODE_AGE_LIST_COMPLETE(TRACE_OBJECT_COUNT)
+#undef TRACE_OBJECT_COUNT
+ PrintF("Total size= %d kb\n", total_size);
+}
void Heap::CheckpointObjectStats() {
- base::LockGuard<base::Mutex> lock_guard(
- checkpoint_object_stats_mutex.Pointer());
+ base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer());
Counters* counters = isolate()->counters();
#define ADJUST_LAST_TIME_OBJECT_COUNT(name) \
counters->count_of_##name()->Increment( \
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698