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

Unified Diff: src/profile-generator.h

Issue 3311028: Implement heap snapshots serialization into JSON. API is designed (Closed)
Patch Set: Comments addressed Created 10 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
« no previous file with comments | « src/api.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index c6d6f4cbc63fdd8d2cffb4b4b8bcb61302d22015..e5d7f2d622424146beeb1a86f40d009d2df8f4c9 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -976,6 +976,53 @@ class HeapSnapshotGenerator {
DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator);
};
+class OutputStreamWriter;
+
+class HeapSnapshotJSONSerializer {
+ public:
+ explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot)
+ : snapshot_(snapshot),
+ nodes_(ObjectsMatch),
+ strings_(ObjectsMatch),
+ next_node_id_(1),
+ next_string_id_(1),
+ writer_(NULL) {
+ }
+ void Serialize(v8::OutputStream* stream);
+
+ private:
+ INLINE(static bool ObjectsMatch(void* key1, void* key2)) {
+ return key1 == key2;
+ }
+
+ INLINE(static uint32_t ObjectHash(const void* key)) {
+ return static_cast<int32_t>(reinterpret_cast<intptr_t>(key));
+ }
+
+ void EnumerateNodes();
+ int GetNodeId(HeapEntry* entry);
+ int GetStringId(const char* s);
+ void SerializeEdge(HeapGraphEdge* edge);
+ void SerializeNode(HeapEntry* entry);
+ void SerializeNodes();
+ void SerializeSnapshot();
+ void SerializeString(const unsigned char* s);
+ void SerializeStrings();
+ void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries);
+
+ HeapSnapshot* snapshot_;
+ HashMap nodes_;
+ HashMap strings_;
+ int next_node_id_;
+ int next_string_id_;
+ OutputStreamWriter* writer_;
+
+ friend class HeapSnapshotJSONSerializerEnumerator;
+ friend class HeapSnapshotJSONSerializerIterator;
+
+ DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
+};
+
} } // namespace v8::internal
#endif // ENABLE_LOGGING_AND_PROFILING
« no previous file with comments | « src/api.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698