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

Unified Diff: src/heap/object-stats.cc

Issue 2379823004: [Tracing] Integrate GC object statistics with tracing. (Closed)
Patch Set: Created 4 years, 3 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
« src/heap/mark-compact.cc ('K') | « src/heap/object-stats.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/object-stats.cc
diff --git a/src/heap/object-stats.cc b/src/heap/object-stats.cc
index dd2adc3d9223a7c1961abaa8b2c9a9445fe2de23..4bc94bafe82dade2fc1637e6b855fc6d796bec06 100644
--- a/src/heap/object-stats.cc
+++ b/src/heap/object-stats.cc
@@ -42,6 +42,16 @@ V8_NOINLINE static void PrintJSONArray(size_t* array, const int len) {
PrintF(" ]");
}
+V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array,
fmeawad 2016/09/30 00:44:05 I think you should merge the print and dump functi
Michael Lippautz 2016/09/30 09:09:44 Please merge the printing and dumping where possib
lpy 2016/09/30 18:21:58 I am not sure if we should, PrintF will end up cal
+ const int len) {
+ stream << "[";
+ for (int i = 0; i < len; i++) {
+ stream << array[i];
+ if (i != (len - 1)) stream << ",";
+ }
+ stream << "]";
+}
+
void ObjectStats::PrintJSON(const char* key) {
double time = isolate()->time_millis_since_init();
int gc_count = heap()->gc_count();
@@ -102,6 +112,60 @@ void ObjectStats::PrintJSON(const char* key) {
#undef FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER
#undef CODE_AGE_WRAPPER
#undef PRINT_INSTANCE_TYPE_DATA
+#undef PRINT_KEY_AND_ID
+}
+
+void ObjectStats::Dump(std::stringstream& stream) {
+ double time = isolate()->time_millis_since_init();
+ int gc_count = heap()->gc_count();
+
+ stream << "{";
+ stream << "\"isolate\":\"" << reinterpret_cast<void*>(isolate()) << "\",";
+ stream << "\"id\":" << gc_count << ",";
+ stream << "\"time\":" << time << ",";
+ stream << "\"bucket_sizes\":[";
+ for (int i = 0; i < kNumberOfBuckets; i++) {
+ stream << (1 << (kFirstBucketShift + i));
+ if (i != (kNumberOfBuckets - 1)) stream << ",";
+ }
+ stream << "],";
+ stream << "\"type_data\":{";
+
+#define PRINT_INSTANCE_TYPE_DATA(name, index) \
+ stream << "\"" << name << "\":{"; \
+ stream << "\"type\":" << static_cast<int>(index) << ","; \
+ stream << "\"overall\":" << object_sizes_[index] << ","; \
+ stream << "\"count\":" << object_counts_[index] << ","; \
+ stream << "\"over_allocated\":" << over_allocated_[index] << ","; \
+ stream << "\"histogram\":"; \
+ DumpJSONArray(stream, size_histogram_[index], kNumberOfBuckets); \
+ stream << ",\"over_allocated_histogram\":"; \
+ DumpJSONArray(stream, over_allocated_histogram_[index], kNumberOfBuckets); \
+ stream << "},";
+
+#define INSTANCE_TYPE_WRAPPER(name) PRINT_INSTANCE_TYPE_DATA(#name, name)
+#define CODE_KIND_WRAPPER(name) \
+ PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \
+ FIRST_CODE_KIND_SUB_TYPE + Code::name)
+#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
+ PRINT_INSTANCE_TYPE_DATA("*FIXED_ARRAY_" #name, \
+ FIRST_FIXED_ARRAY_SUB_TYPE + name)
+#define CODE_AGE_WRAPPER(name) \
+ PRINT_INSTANCE_TYPE_DATA( \
+ "*CODE_AGE_" #name, \
+ FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge)
+
+ INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER);
+ CODE_KIND_LIST(CODE_KIND_WRAPPER);
+ FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER);
+ CODE_AGE_LIST_COMPLETE(CODE_AGE_WRAPPER);
+ stream << "\"END\":{}}}";
+
+#undef INSTANCE_TYPE_WRAPPER
+#undef CODE_KIND_WRAPPER
+#undef FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER
+#undef CODE_AGE_WRAPPER
+#undef PRINT_INSTANCE_TYPE_DATA
}
void ObjectStats::CheckpointObjectStats() {
« src/heap/mark-compact.cc ('K') | « src/heap/object-stats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698