OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 HeapSnapshotsCollection* collection_; | 969 HeapSnapshotsCollection* collection_; |
970 // Mapping from HeapObject* pointers to HeapEntry* pointers. | 970 // Mapping from HeapObject* pointers to HeapEntry* pointers. |
971 HeapEntriesMap entries_; | 971 HeapEntriesMap entries_; |
972 SnapshotFillerInterface* filler_; | 972 SnapshotFillerInterface* filler_; |
973 | 973 |
974 friend class IndexedReferencesExtractor; | 974 friend class IndexedReferencesExtractor; |
975 | 975 |
976 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); | 976 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); |
977 }; | 977 }; |
978 | 978 |
| 979 class OutputStreamWriter; |
| 980 |
| 981 class HeapSnapshotJSONSerializer { |
| 982 public: |
| 983 explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot) |
| 984 : snapshot_(snapshot), |
| 985 nodes_(ObjectsMatch), |
| 986 strings_(ObjectsMatch), |
| 987 next_node_id_(1), |
| 988 next_string_id_(1), |
| 989 writer_(NULL) { |
| 990 } |
| 991 void Serialize(v8::OutputStream* stream); |
| 992 |
| 993 private: |
| 994 INLINE(static bool ObjectsMatch(void* key1, void* key2)) { |
| 995 return key1 == key2; |
| 996 } |
| 997 |
| 998 INLINE(static uint32_t ObjectHash(const void* key)) { |
| 999 return static_cast<int32_t>(reinterpret_cast<intptr_t>(key)); |
| 1000 } |
| 1001 |
| 1002 void EnumerateNodes(); |
| 1003 int GetNodeId(HeapEntry* entry); |
| 1004 int GetStringId(const char* s); |
| 1005 void SerializeEdge(HeapGraphEdge* edge); |
| 1006 void SerializeNode(HeapEntry* entry); |
| 1007 void SerializeNodes(); |
| 1008 void SerializeSnapshot(); |
| 1009 void SerializeString(const unsigned char* s); |
| 1010 void SerializeStrings(); |
| 1011 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); |
| 1012 |
| 1013 HeapSnapshot* snapshot_; |
| 1014 HashMap nodes_; |
| 1015 HashMap strings_; |
| 1016 int next_node_id_; |
| 1017 int next_string_id_; |
| 1018 OutputStreamWriter* writer_; |
| 1019 |
| 1020 friend class HeapSnapshotJSONSerializerEnumerator; |
| 1021 friend class HeapSnapshotJSONSerializerIterator; |
| 1022 |
| 1023 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 1024 }; |
| 1025 |
979 } } // namespace v8::internal | 1026 } } // namespace v8::internal |
980 | 1027 |
981 #endif // ENABLE_LOGGING_AND_PROFILING | 1028 #endif // ENABLE_LOGGING_AND_PROFILING |
982 | 1029 |
983 #endif // V8_PROFILE_GENERATOR_H_ | 1030 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |