Revision: 5888
Author: [email protected]
Date: Wed Nov 24 02:47:18 2010
Log: New Heap profiler: fix JSON serialization of aggregated profiles.
Serialization was failing due to unset dominator pointers.
TEST=test-heap-snapshot/AggregatedHeapSnapshotJSONSerialization
Review URL: http://codereview.chromium.org/5314003
http://code.google.com/p/v8/source/detail?r=5888
Modified:
/branches/bleeding_edge/src/heap-profiler.cc
/branches/bleeding_edge/src/profile-generator.cc
/branches/bleeding_edge/src/profile-generator.h
/branches/bleeding_edge/test/cctest/test-heap-profiler.cc
=======================================
--- /branches/bleeding_edge/src/heap-profiler.cc Thu Nov 18 02:38:25 2010
+++ /branches/bleeding_edge/src/heap-profiler.cc Wed Nov 24 02:47:18 2010
@@ -1064,6 +1064,8 @@
// Fill up references.
IterateRetainers<AllocatingRetainersIterator>(&entries_map);
+
+ snapshot->SetDominatorsToSelf();
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Tue Nov 23 01:52:52
2010
+++ /branches/bleeding_edge/src/profile-generator.cc Wed Nov 24 02:47:18
2010
@@ -1460,6 +1460,14 @@
}
}
}
+
+
+void HeapSnapshot::SetDominatorsToSelf() {
+ for (int i = 0; i < entries_.length(); ++i) {
+ HeapEntry* entry = entries_[i];
+ if (entry->dominator() == NULL) entry->set_dominator(entry);
+ }
+}
void HeapSnapshot::SetEntriesDominators() {
@@ -1473,10 +1481,7 @@
ordered_entries[i]->set_dominator(dominators[i]);
}
// For nodes unreachable from root, set dominator to itself.
- for (int i = 0; i < entries_.length(); ++i) {
- HeapEntry* entry = entries_[i];
- if (entry->dominator() == NULL) entry->set_dominator(entry);
- }
+ SetDominatorsToSelf();
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.h Tue Nov 23 01:52:52 2010
+++ /branches/bleeding_edge/src/profile-generator.h Wed Nov 24 02:47:18 2010
@@ -700,6 +700,7 @@
List<HeapEntry*>* GetSortedEntriesList();
template<class Visitor>
void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
+ void SetDominatorsToSelf();
void Print(int max_depth);
void PrintEntriesSize();
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Mon Nov 22
06:00:40 2010
+++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Wed Nov 24
02:47:18 2010
@@ -1177,5 +1177,20 @@
CHECK_GT(stream.size(), 0);
CHECK_EQ(0, stream.eos_signaled());
}
+
+
+// Must not crash in debug mode.
+TEST(AggregatedHeapSnapshotJSONSerialization) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ const v8::HeapSnapshot* snapshot =
+ v8::HeapProfiler::TakeSnapshot(
+ v8::String::New("agg"), v8::HeapSnapshot::kAggregated);
+ TestJSONStream stream;
+ snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON);
+ CHECK_GT(stream.size(), 0);
+ CHECK_EQ(1, stream.eos_signaled());
+}
#endif // ENABLE_LOGGING_AND_PROFILING
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev