| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ | 5 #ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ |
| 6 #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ | 6 #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ |
| 7 | 7 |
| 8 #include "include/v8-profiler.h" | 8 #include "include/v8-profiler.h" |
| 9 #include "src/base/platform/time.h" | 9 #include "src/base/platform/time.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 : id(id), addr(addr), size(size), accessed(true) { } | 252 : id(id), addr(addr), size(size), accessed(true) { } |
| 253 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) | 253 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) |
| 254 : id(id), addr(addr), size(size), accessed(accessed) { } | 254 : id(id), addr(addr), size(size), accessed(accessed) { } |
| 255 SnapshotObjectId id; | 255 SnapshotObjectId id; |
| 256 Address addr; | 256 Address addr; |
| 257 unsigned int size; | 257 unsigned int size; |
| 258 bool accessed; | 258 bool accessed; |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 SnapshotObjectId next_id_; | 261 SnapshotObjectId next_id_; |
| 262 HashMap entries_map_; | 262 base::HashMap entries_map_; |
| 263 List<EntryInfo> entries_; | 263 List<EntryInfo> entries_; |
| 264 List<TimeInterval> time_intervals_; | 264 List<TimeInterval> time_intervals_; |
| 265 Heap* heap_; | 265 Heap* heap_; |
| 266 | 266 |
| 267 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 267 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 | 270 |
| 271 // A typedef for referencing anything that can be snapshotted living | 271 // A typedef for referencing anything that can be snapshotted living |
| 272 // in any kind of heap memory. | 272 // in any kind of heap memory. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 290 int Map(HeapThing thing); | 290 int Map(HeapThing thing); |
| 291 void Pair(HeapThing thing, int entry); | 291 void Pair(HeapThing thing, int entry); |
| 292 | 292 |
| 293 private: | 293 private: |
| 294 static uint32_t Hash(HeapThing thing) { | 294 static uint32_t Hash(HeapThing thing) { |
| 295 return ComputeIntegerHash( | 295 return ComputeIntegerHash( |
| 296 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)), | 296 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)), |
| 297 v8::internal::kZeroHashSeed); | 297 v8::internal::kZeroHashSeed); |
| 298 } | 298 } |
| 299 | 299 |
| 300 HashMap entries_; | 300 base::HashMap entries_; |
| 301 | 301 |
| 302 friend class HeapObjectsSet; | 302 friend class HeapObjectsSet; |
| 303 | 303 |
| 304 DISALLOW_COPY_AND_ASSIGN(HeapEntriesMap); | 304 DISALLOW_COPY_AND_ASSIGN(HeapEntriesMap); |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 | 307 |
| 308 class HeapObjectsSet { | 308 class HeapObjectsSet { |
| 309 public: | 309 public: |
| 310 HeapObjectsSet(); | 310 HeapObjectsSet(); |
| 311 void Clear(); | 311 void Clear(); |
| 312 bool Contains(Object* object); | 312 bool Contains(Object* object); |
| 313 void Insert(Object* obj); | 313 void Insert(Object* obj); |
| 314 const char* GetTag(Object* obj); | 314 const char* GetTag(Object* obj); |
| 315 void SetTag(Object* obj, const char* tag); | 315 void SetTag(Object* obj, const char* tag); |
| 316 bool is_empty() const { return entries_.occupancy() == 0; } | 316 bool is_empty() const { return entries_.occupancy() == 0; } |
| 317 | 317 |
| 318 private: | 318 private: |
| 319 HashMap entries_; | 319 base::HashMap entries_; |
| 320 | 320 |
| 321 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet); | 321 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet); |
| 322 }; | 322 }; |
| 323 | 323 |
| 324 | 324 |
| 325 class SnapshottingProgressReportingInterface { | 325 class SnapshottingProgressReportingInterface { |
| 326 public: | 326 public: |
| 327 virtual ~SnapshottingProgressReportingInterface() { } | 327 virtual ~SnapshottingProgressReportingInterface() { } |
| 328 virtual void ProgressStep() = 0; | 328 virtual void ProgressStep() = 0; |
| 329 virtual bool ProgressReport(bool force) = 0; | 329 virtual bool ProgressReport(bool force) = 0; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } | 514 } |
| 515 | 515 |
| 516 NativeGroupRetainedObjectInfo* FindOrAddGroupInfo(const char* label); | 516 NativeGroupRetainedObjectInfo* FindOrAddGroupInfo(const char* label); |
| 517 | 517 |
| 518 Isolate* isolate_; | 518 Isolate* isolate_; |
| 519 HeapSnapshot* snapshot_; | 519 HeapSnapshot* snapshot_; |
| 520 StringsStorage* names_; | 520 StringsStorage* names_; |
| 521 bool embedder_queried_; | 521 bool embedder_queried_; |
| 522 HeapObjectsSet in_groups_; | 522 HeapObjectsSet in_groups_; |
| 523 // RetainedObjectInfo* -> List<HeapObject*>* | 523 // RetainedObjectInfo* -> List<HeapObject*>* |
| 524 HashMap objects_by_info_; | 524 base::HashMap objects_by_info_; |
| 525 HashMap native_groups_; | 525 base::HashMap native_groups_; |
| 526 HeapEntriesAllocator* synthetic_entries_allocator_; | 526 HeapEntriesAllocator* synthetic_entries_allocator_; |
| 527 HeapEntriesAllocator* native_entries_allocator_; | 527 HeapEntriesAllocator* native_entries_allocator_; |
| 528 // Used during references extraction. | 528 // Used during references extraction. |
| 529 SnapshotFiller* filler_; | 529 SnapshotFiller* filler_; |
| 530 | 530 |
| 531 static HeapThing const kNativesRootObject; | 531 static HeapThing const kNativesRootObject; |
| 532 | 532 |
| 533 friend class GlobalHandlesExtractor; | 533 friend class GlobalHandlesExtractor; |
| 534 | 534 |
| 535 DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer); | 535 DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 void SerializeTraceNode(AllocationTraceNode* node); | 602 void SerializeTraceNode(AllocationTraceNode* node); |
| 603 void SerializeTraceNodeInfos(); | 603 void SerializeTraceNodeInfos(); |
| 604 void SerializeSamples(); | 604 void SerializeSamples(); |
| 605 void SerializeString(const unsigned char* s); | 605 void SerializeString(const unsigned char* s); |
| 606 void SerializeStrings(); | 606 void SerializeStrings(); |
| 607 | 607 |
| 608 static const int kEdgeFieldsCount; | 608 static const int kEdgeFieldsCount; |
| 609 static const int kNodeFieldsCount; | 609 static const int kNodeFieldsCount; |
| 610 | 610 |
| 611 HeapSnapshot* snapshot_; | 611 HeapSnapshot* snapshot_; |
| 612 HashMap strings_; | 612 base::HashMap strings_; |
| 613 int next_node_id_; | 613 int next_node_id_; |
| 614 int next_string_id_; | 614 int next_string_id_; |
| 615 OutputStreamWriter* writer_; | 615 OutputStreamWriter* writer_; |
| 616 | 616 |
| 617 friend class HeapSnapshotJSONSerializerEnumerator; | 617 friend class HeapSnapshotJSONSerializerEnumerator; |
| 618 friend class HeapSnapshotJSONSerializerIterator; | 618 friend class HeapSnapshotJSONSerializerIterator; |
| 619 | 619 |
| 620 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 620 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 621 }; | 621 }; |
| 622 | 622 |
| 623 | 623 |
| 624 } // namespace internal | 624 } // namespace internal |
| 625 } // namespace v8 | 625 } // namespace v8 |
| 626 | 626 |
| 627 #endif // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ | 627 #endif // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ |
| OLD | NEW |