| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ | 28 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 29 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ | 29 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 30 | 30 |
| 31 #include "profile-generator-inl.h" |
| 32 |
| 31 namespace v8 { | 33 namespace v8 { |
| 32 namespace internal { | 34 namespace internal { |
| 33 | 35 |
| 34 class HeapEntry; | 36 class HeapEntry; |
| 35 class HeapSnapshot; | 37 class HeapSnapshot; |
| 36 | 38 |
| 37 class HeapGraphEdge BASE_EMBEDDED { | 39 class HeapGraphEdge BASE_EMBEDDED { |
| 38 public: | 40 public: |
| 39 enum Type { | 41 enum Type { |
| 40 kContextVariable = v8::HeapGraphEdge::kContextVariable, | 42 kContextVariable = v8::HeapGraphEdge::kContextVariable, |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 bool is_tracking_objects() { return is_tracking_objects_; } | 296 bool is_tracking_objects() { return is_tracking_objects_; } |
| 295 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { | 297 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { |
| 296 return ids_.PushHeapObjectsStats(stream); | 298 return ids_.PushHeapObjectsStats(stream); |
| 297 } | 299 } |
| 298 void StartHeapObjectsTracking() { is_tracking_objects_ = true; } | 300 void StartHeapObjectsTracking() { is_tracking_objects_ = true; } |
| 299 void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); } | 301 void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); } |
| 300 | 302 |
| 301 HeapSnapshot* NewSnapshot(const char* name, unsigned uid); | 303 HeapSnapshot* NewSnapshot(const char* name, unsigned uid); |
| 302 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 304 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
| 303 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 305 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
| 304 HeapSnapshot* GetSnapshot(unsigned uid); | |
| 305 void RemoveSnapshot(HeapSnapshot* snapshot); | 306 void RemoveSnapshot(HeapSnapshot* snapshot); |
| 306 | 307 |
| 307 StringsStorage* names() { return &names_; } | 308 StringsStorage* names() { return &names_; } |
| 308 TokenEnumerator* token_enumerator() { return token_enumerator_; } | |
| 309 | 309 |
| 310 SnapshotObjectId FindObjectId(Address object_addr) { | 310 SnapshotObjectId FindObjectId(Address object_addr) { |
| 311 return ids_.FindEntry(object_addr); | 311 return ids_.FindEntry(object_addr); |
| 312 } | 312 } |
| 313 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { | 313 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { |
| 314 return ids_.FindOrAddEntry(object_addr, object_size); | 314 return ids_.FindOrAddEntry(object_addr, object_size); |
| 315 } | 315 } |
| 316 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 316 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
| 317 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 317 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } |
| 318 SnapshotObjectId last_assigned_id() const { | 318 SnapshotObjectId last_assigned_id() const { |
| 319 return ids_.last_assigned_id(); | 319 return ids_.last_assigned_id(); |
| 320 } | 320 } |
| 321 size_t GetUsedMemorySize() const; | 321 size_t GetUsedMemorySize() const; |
| 322 | 322 |
| 323 private: | 323 private: |
| 324 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { | |
| 325 return key1 == key2; | |
| 326 } | |
| 327 | |
| 328 bool is_tracking_objects_; // Whether tracking object moves is needed. | 324 bool is_tracking_objects_; // Whether tracking object moves is needed. |
| 329 List<HeapSnapshot*> snapshots_; | 325 List<HeapSnapshot*> snapshots_; |
| 330 // Mapping from snapshots' uids to HeapSnapshot* pointers. | |
| 331 HashMap snapshots_uids_; | |
| 332 StringsStorage names_; | 326 StringsStorage names_; |
| 333 TokenEnumerator* token_enumerator_; | |
| 334 // Mapping from HeapObject addresses to objects' uids. | 327 // Mapping from HeapObject addresses to objects' uids. |
| 335 HeapObjectsMap ids_; | 328 HeapObjectsMap ids_; |
| 336 | 329 |
| 337 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); | 330 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); |
| 338 }; | 331 }; |
| 339 | 332 |
| 340 | 333 |
| 341 // A typedef for referencing anything that can be snapshotted living | 334 // A typedef for referencing anything that can be snapshotted living |
| 342 // in any kind of heap memory. | 335 // in any kind of heap memory. |
| 343 typedef void* HeapThing; | 336 typedef void* HeapThing; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 static HeapObject* const kInternalRootObject; | 440 static HeapObject* const kInternalRootObject; |
| 448 | 441 |
| 449 private: | 442 private: |
| 450 HeapEntry* AddEntry(HeapObject* object); | 443 HeapEntry* AddEntry(HeapObject* object); |
| 451 HeapEntry* AddEntry(HeapObject* object, | 444 HeapEntry* AddEntry(HeapObject* object, |
| 452 HeapEntry::Type type, | 445 HeapEntry::Type type, |
| 453 const char* name); | 446 const char* name); |
| 454 const char* GetSystemEntryName(HeapObject* object); | 447 const char* GetSystemEntryName(HeapObject* object); |
| 455 | 448 |
| 456 void ExtractReferences(HeapObject* obj); | 449 void ExtractReferences(HeapObject* obj); |
| 457 void ExtractJSGlobalProxyReferences(JSGlobalProxy* proxy); | 450 void ExtractJSGlobalProxyReferences(int entry, JSGlobalProxy* proxy); |
| 458 void ExtractJSObjectReferences(int entry, JSObject* js_obj); | 451 void ExtractJSObjectReferences(int entry, JSObject* js_obj); |
| 459 void ExtractStringReferences(int entry, String* obj); | 452 void ExtractStringReferences(int entry, String* obj); |
| 460 void ExtractContextReferences(int entry, Context* context); | 453 void ExtractContextReferences(int entry, Context* context); |
| 461 void ExtractMapReferences(int entry, Map* map); | 454 void ExtractMapReferences(int entry, Map* map); |
| 462 void ExtractSharedFunctionInfoReferences(int entry, | 455 void ExtractSharedFunctionInfoReferences(int entry, |
| 463 SharedFunctionInfo* shared); | 456 SharedFunctionInfo* shared); |
| 464 void ExtractScriptReferences(int entry, Script* script); | 457 void ExtractScriptReferences(int entry, Script* script); |
| 465 void ExtractAccessorPairReferences(int entry, AccessorPair* accessors); | 458 void ExtractAccessorPairReferences(int entry, AccessorPair* accessors); |
| 466 void ExtractCodeCacheReferences(int entry, CodeCache* code_cache); | 459 void ExtractCodeCacheReferences(int entry, CodeCache* code_cache); |
| 467 void ExtractCodeReferences(int entry, Code* code); | 460 void ExtractCodeReferences(int entry, Code* code); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 static inline HeapObject* GetNthGcSubrootObject(int delta); | 518 static inline HeapObject* GetNthGcSubrootObject(int delta); |
| 526 static inline int GetGcSubrootOrder(HeapObject* subroot); | 519 static inline int GetGcSubrootOrder(HeapObject* subroot); |
| 527 | 520 |
| 528 Heap* heap_; | 521 Heap* heap_; |
| 529 HeapSnapshot* snapshot_; | 522 HeapSnapshot* snapshot_; |
| 530 HeapSnapshotsCollection* collection_; | 523 HeapSnapshotsCollection* collection_; |
| 531 SnapshottingProgressReportingInterface* progress_; | 524 SnapshottingProgressReportingInterface* progress_; |
| 532 SnapshotFillerInterface* filler_; | 525 SnapshotFillerInterface* filler_; |
| 533 HeapObjectsSet objects_tags_; | 526 HeapObjectsSet objects_tags_; |
| 534 HeapObjectsSet strong_gc_subroot_names_; | 527 HeapObjectsSet strong_gc_subroot_names_; |
| 528 HeapObjectsSet user_roots_; |
| 535 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; | 529 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; |
| 536 | 530 |
| 537 static HeapObject* const kGcRootsObject; | 531 static HeapObject* const kGcRootsObject; |
| 538 static HeapObject* const kFirstGcSubrootObject; | 532 static HeapObject* const kFirstGcSubrootObject; |
| 539 static HeapObject* const kLastGcSubrootObject; | 533 static HeapObject* const kLastGcSubrootObject; |
| 540 | 534 |
| 541 friend class IndexedReferencesExtractor; | 535 friend class IndexedReferencesExtractor; |
| 542 friend class GcSubrootsEnumerator; | 536 friend class GcSubrootsEnumerator; |
| 543 friend class RootsReferencesExtractor; | 537 friend class RootsReferencesExtractor; |
| 544 | 538 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 friend class HeapSnapshotJSONSerializerIterator; | 677 friend class HeapSnapshotJSONSerializerIterator; |
| 684 | 678 |
| 685 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 679 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 686 }; | 680 }; |
| 687 | 681 |
| 688 | 682 |
| 689 } } // namespace v8::internal | 683 } } // namespace v8::internal |
| 690 | 684 |
| 691 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 685 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 692 | 686 |
| OLD | NEW |