OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_HEAP_PROFILER_H_ | 5 #ifndef VM_HEAP_PROFILER_H_ |
6 #define VM_HEAP_PROFILER_H_ | 6 #define VM_HEAP_PROFILER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 kBoolean = 4, | 67 kBoolean = 4, |
68 kChar = 5, | 68 kChar = 5, |
69 kFloat = 6, | 69 kFloat = 6, |
70 kDouble = 7, | 70 kDouble = 7, |
71 kByte = 8, | 71 kByte = 8, |
72 kShort = 9, | 72 kShort = 9, |
73 kInt = 10, | 73 kInt = 10, |
74 kLong = 11 | 74 kLong = 11 |
75 }; | 75 }; |
76 | 76 |
| 77 // Object ids for fake classes. |
| 78 // |
| 79 // While not necessary to describe Dart programs, third party tools |
| 80 // expect these types. These tools also interpret id values as raw |
| 81 // addresses so we space them by 8 to not look like compressed oops. |
| 82 enum FakeClass { |
| 83 kJavaLangClass = 1, |
| 84 kJavaLangClassLoader = 9, |
| 85 kJavaLangObject = 17, |
| 86 kJavaLangString = 25, |
| 87 kArrayObject = 33, |
| 88 kArrayBoolean = 41, |
| 89 kArrayChar = 49, |
| 90 kArrayFloat = 57, |
| 91 kArrayDouble = 65, |
| 92 kArrayByte = 73, |
| 93 kArrayShort = 81, |
| 94 kArrayInt = 89, |
| 95 kArrayLong = 97 |
| 96 }; |
| 97 |
77 static const int kObjectIdSize = sizeof(uint64_t); // NOLINT | 98 static const int kObjectIdSize = sizeof(uint64_t); // NOLINT |
78 | 99 |
79 HeapProfiler(Dart_FileWriteCallback callback, void* stream); | 100 HeapProfiler(Dart_FileWriteCallback callback, void* stream); |
80 ~HeapProfiler(); | 101 ~HeapProfiler(); |
81 | 102 |
82 // Writes a root to the heap dump. | 103 // Writes a root to the heap dump. |
83 void WriteRoot(const RawObject* raw_obj); | 104 void WriteRoot(const RawObject* raw_obj); |
84 | 105 |
85 // Writes a object to the heap dump. | 106 // Writes a object to the heap dump. |
86 void WriteObject(const RawObject* raw_obj); | 107 void WriteObject(const RawObject* raw_obj); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 233 |
213 // Invokes the write callback. | 234 // Invokes the write callback. |
214 void Write(const void* data, intptr_t size); | 235 void Write(const void* data, intptr_t size); |
215 | 236 |
216 // Writes the binary hprof header to the output stream. | 237 // Writes the binary hprof header to the output stream. |
217 void WriteHeader(); | 238 void WriteHeader(); |
218 | 239 |
219 // Writes a record to the output stream. | 240 // Writes a record to the output stream. |
220 void WriteRecord(const Record& record); | 241 void WriteRecord(const Record& record); |
221 | 242 |
222 | |
223 // Writes a string in utf-8 record to the output stream. | 243 // Writes a string in utf-8 record to the output stream. |
224 void WriteStringInUtf8(const char* c_string); | 244 void WriteStringInUtf8(const char* c_string); |
225 void WriteStringInUtf8(const RawString* raw_string); | 245 void WriteStringInUtf8(const RawString* raw_string); |
226 | 246 |
227 | |
228 // Writes a load class record to the output stream. | 247 // Writes a load class record to the output stream. |
229 void WriteLoadClass(const RawClass* raw_class); | 248 void WriteLoadClass(const RawClass* raw_class); |
| 249 void WriteFakeLoadClass(FakeClass fake_class, const char* class_name); |
230 | 250 |
231 // Writes an empty stack trace to the output stream. | 251 // Writes an empty stack trace to the output stream. |
232 void WriteStackTrace(); | 252 void WriteStackTrace(); |
233 | 253 |
234 // Writes a heap summary record to the output stream. | 254 // Writes a heap summary record to the output stream. |
235 void WriteHeapSummary(uint32_t total_live_bytes, | 255 void WriteHeapSummary(uint32_t total_live_bytes, |
236 uint32_t total_live_instances, | 256 uint32_t total_live_instances, |
237 uint64_t total_bytes_allocated, | 257 uint64_t total_bytes_allocated, |
238 uint64_t total_instances_allocated); | 258 uint64_t total_instances_allocated); |
239 | 259 |
240 // Writes a heap dump record to the output stream. | 260 // Writes a heap dump record to the output stream. |
241 void WriteHeapDump(); | 261 void WriteHeapDump(); |
242 | 262 |
243 // Writes a sub-record to the heap dump record. | 263 // Writes a sub-record to the heap dump record. |
244 void WriteClassDump(const RawClass* raw_class); | 264 void WriteClassDump(const RawClass* raw_class); |
| 265 void WriteFakeClassDump(FakeClass fake_class, FakeClass fake_super_class); |
245 void WriteInstanceDump(const RawObject* raw_obj); | 266 void WriteInstanceDump(const RawObject* raw_obj); |
246 void WriteObjectArrayDump(const RawArray* raw_array); | 267 void WriteObjectArrayDump(const RawArray* raw_array); |
247 void WritePrimitiveArrayDump(const RawByteArray* raw_byte_array, | 268 void WritePrimitiveArrayDump(const RawByteArray* raw_byte_array, |
248 uint8_t tag, | 269 uint8_t tag, |
249 const void* data); | 270 const void* data); |
250 | 271 |
251 static const RawClass* GetClass(const RawObject* raw_obj); | 272 static const RawClass* GetClass(const RawObject* raw_obj); |
252 static const RawClass* GetSuperClass(const RawClass* raw_class); | 273 static const RawClass* GetSuperClass(const RawClass* raw_class); |
253 | 274 |
254 Dart_FileWriteCallback write_callback_; | 275 Dart_FileWriteCallback write_callback_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 virtual void VisitObject(RawObject* obj); | 327 virtual void VisitObject(RawObject* obj); |
307 | 328 |
308 private: | 329 private: |
309 HeapProfiler* profiler_; | 330 HeapProfiler* profiler_; |
310 DISALLOW_COPY_AND_ASSIGN(HeapProfilerObjectVisitor); | 331 DISALLOW_COPY_AND_ASSIGN(HeapProfilerObjectVisitor); |
311 }; | 332 }; |
312 | 333 |
313 } // namespace dart | 334 } // namespace dart |
314 | 335 |
315 #endif // VM_HEAP_PROFILER_H_ | 336 #endif // VM_HEAP_PROFILER_H_ |
OLD | NEW |