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

Side by Side Diff: src/heap-snapshot-generator.h

Issue 194503002: Remove SnapshotFillerInterface (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 30
31 #include "profile-generator-inl.h" 31 #include "profile-generator-inl.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 class AllocationTracker; 36 class AllocationTracker;
37 class AllocationTraceNode; 37 class AllocationTraceNode;
38 class HeapEntry; 38 class HeapEntry;
39 class HeapSnapshot; 39 class HeapSnapshot;
40 class SnapshotFiller;
40 41
41 class HeapGraphEdge BASE_EMBEDDED { 42 class HeapGraphEdge BASE_EMBEDDED {
42 public: 43 public:
43 enum Type { 44 enum Type {
44 kContextVariable = v8::HeapGraphEdge::kContextVariable, 45 kContextVariable = v8::HeapGraphEdge::kContextVariable,
45 kElement = v8::HeapGraphEdge::kElement, 46 kElement = v8::HeapGraphEdge::kElement,
46 kProperty = v8::HeapGraphEdge::kProperty, 47 kProperty = v8::HeapGraphEdge::kProperty,
47 kInternal = v8::HeapGraphEdge::kInternal, 48 kInternal = v8::HeapGraphEdge::kInternal,
48 kHidden = v8::HeapGraphEdge::kHidden, 49 kHidden = v8::HeapGraphEdge::kHidden,
49 kShortcut = v8::HeapGraphEdge::kShortcut, 50 kShortcut = v8::HeapGraphEdge::kShortcut,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void SetTag(Object* obj, const char* tag); 337 void SetTag(Object* obj, const char* tag);
337 bool is_empty() const { return entries_.occupancy() == 0; } 338 bool is_empty() const { return entries_.occupancy() == 0; }
338 339
339 private: 340 private:
340 HashMap entries_; 341 HashMap entries_;
341 342
342 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet); 343 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet);
343 }; 344 };
344 345
345 346
346 // An interface used to populate a snapshot with nodes and edges.
347 class SnapshotFillerInterface {
348 public:
349 virtual ~SnapshotFillerInterface() { }
350 virtual HeapEntry* AddEntry(HeapThing ptr,
351 HeapEntriesAllocator* allocator) = 0;
352 virtual HeapEntry* FindEntry(HeapThing ptr) = 0;
353 virtual HeapEntry* FindOrAddEntry(HeapThing ptr,
354 HeapEntriesAllocator* allocator) = 0;
355 virtual void SetIndexedReference(HeapGraphEdge::Type type,
356 int parent_entry,
357 int index,
358 HeapEntry* child_entry) = 0;
359 virtual void SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
360 int parent_entry,
361 HeapEntry* child_entry) = 0;
362 virtual void SetNamedReference(HeapGraphEdge::Type type,
363 int parent_entry,
364 const char* reference_name,
365 HeapEntry* child_entry) = 0;
366 virtual void SetNamedAutoIndexReference(HeapGraphEdge::Type type,
367 int parent_entry,
368 HeapEntry* child_entry) = 0;
369 };
370
371
372 class SnapshottingProgressReportingInterface { 347 class SnapshottingProgressReportingInterface {
373 public: 348 public:
374 virtual ~SnapshottingProgressReportingInterface() { } 349 virtual ~SnapshottingProgressReportingInterface() { }
375 virtual void ProgressStep() = 0; 350 virtual void ProgressStep() = 0;
376 virtual bool ProgressReport(bool force) = 0; 351 virtual bool ProgressReport(bool force) = 0;
377 }; 352 };
378 353
379 354
380 // An implementation of V8 heap graph extractor. 355 // An implementation of V8 heap graph extractor.
381 class V8HeapExplorer : public HeapEntriesAllocator { 356 class V8HeapExplorer : public HeapEntriesAllocator {
382 public: 357 public:
383 V8HeapExplorer(HeapSnapshot* snapshot, 358 V8HeapExplorer(HeapSnapshot* snapshot,
384 SnapshottingProgressReportingInterface* progress, 359 SnapshottingProgressReportingInterface* progress,
385 v8::HeapProfiler::ObjectNameResolver* resolver); 360 v8::HeapProfiler::ObjectNameResolver* resolver);
386 virtual ~V8HeapExplorer(); 361 virtual ~V8HeapExplorer();
387 virtual HeapEntry* AllocateEntry(HeapThing ptr); 362 virtual HeapEntry* AllocateEntry(HeapThing ptr);
388 void AddRootEntries(SnapshotFillerInterface* filler); 363 void AddRootEntries(SnapshotFiller* filler);
389 int EstimateObjectsCount(HeapIterator* iterator); 364 int EstimateObjectsCount(HeapIterator* iterator);
390 bool IterateAndExtractReferences(SnapshotFillerInterface* filler); 365 bool IterateAndExtractReferences(SnapshotFiller* filler);
391 void TagGlobalObjects(); 366 void TagGlobalObjects();
392 void TagCodeObject(Code* code); 367 void TagCodeObject(Code* code);
393 void TagBuiltinCodeObject(Code* code, const char* name); 368 void TagBuiltinCodeObject(Code* code, const char* name);
394 HeapEntry* AddEntry(Address address, 369 HeapEntry* AddEntry(Address address,
395 HeapEntry::Type type, 370 HeapEntry::Type type,
396 const char* name, 371 const char* name,
397 size_t size); 372 size_t size);
398 373
399 static String* GetConstructorName(JSObject* object); 374 static String* GetConstructorName(JSObject* object);
400 375
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 HeapEntry* GetEntry(Object* obj); 456 HeapEntry* GetEntry(Object* obj);
482 457
483 static inline HeapObject* GetNthGcSubrootObject(int delta); 458 static inline HeapObject* GetNthGcSubrootObject(int delta);
484 static inline int GetGcSubrootOrder(HeapObject* subroot); 459 static inline int GetGcSubrootOrder(HeapObject* subroot);
485 460
486 Heap* heap_; 461 Heap* heap_;
487 HeapSnapshot* snapshot_; 462 HeapSnapshot* snapshot_;
488 StringsStorage* names_; 463 StringsStorage* names_;
489 HeapObjectsMap* heap_object_map_; 464 HeapObjectsMap* heap_object_map_;
490 SnapshottingProgressReportingInterface* progress_; 465 SnapshottingProgressReportingInterface* progress_;
491 SnapshotFillerInterface* filler_; 466 SnapshotFiller* filler_;
492 HeapObjectsSet objects_tags_; 467 HeapObjectsSet objects_tags_;
493 HeapObjectsSet strong_gc_subroot_names_; 468 HeapObjectsSet strong_gc_subroot_names_;
494 HeapObjectsSet user_roots_; 469 HeapObjectsSet user_roots_;
495 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; 470 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
496 471
497 static HeapObject* const kGcRootsObject; 472 static HeapObject* const kGcRootsObject;
498 static HeapObject* const kFirstGcSubrootObject; 473 static HeapObject* const kFirstGcSubrootObject;
499 static HeapObject* const kLastGcSubrootObject; 474 static HeapObject* const kLastGcSubrootObject;
500 475
501 friend class IndexedReferencesExtractor; 476 friend class IndexedReferencesExtractor;
502 friend class GcSubrootsEnumerator; 477 friend class GcSubrootsEnumerator;
503 friend class RootsReferencesExtractor; 478 friend class RootsReferencesExtractor;
504 479
505 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); 480 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer);
506 }; 481 };
507 482
508 483
509 class NativeGroupRetainedObjectInfo; 484 class NativeGroupRetainedObjectInfo;
510 485
511 486
512 // An implementation of retained native objects extractor. 487 // An implementation of retained native objects extractor.
513 class NativeObjectsExplorer { 488 class NativeObjectsExplorer {
514 public: 489 public:
515 NativeObjectsExplorer(HeapSnapshot* snapshot, 490 NativeObjectsExplorer(HeapSnapshot* snapshot,
516 SnapshottingProgressReportingInterface* progress); 491 SnapshottingProgressReportingInterface* progress);
517 virtual ~NativeObjectsExplorer(); 492 virtual ~NativeObjectsExplorer();
518 void AddRootEntries(SnapshotFillerInterface* filler); 493 void AddRootEntries(SnapshotFiller* filler);
519 int EstimateObjectsCount(); 494 int EstimateObjectsCount();
520 bool IterateAndExtractReferences(SnapshotFillerInterface* filler); 495 bool IterateAndExtractReferences(SnapshotFiller* filler);
521 496
522 private: 497 private:
523 void FillRetainedObjects(); 498 void FillRetainedObjects();
524 void FillImplicitReferences(); 499 void FillImplicitReferences();
525 List<HeapObject*>* GetListMaybeDisposeInfo(v8::RetainedObjectInfo* info); 500 List<HeapObject*>* GetListMaybeDisposeInfo(v8::RetainedObjectInfo* info);
526 void SetNativeRootReference(v8::RetainedObjectInfo* info); 501 void SetNativeRootReference(v8::RetainedObjectInfo* info);
527 void SetRootNativeRootsReference(); 502 void SetRootNativeRootsReference();
528 void SetWrapperNativeReferences(HeapObject* wrapper, 503 void SetWrapperNativeReferences(HeapObject* wrapper,
529 v8::RetainedObjectInfo* info); 504 v8::RetainedObjectInfo* info);
530 void VisitSubtreeWrapper(Object** p, uint16_t class_id); 505 void VisitSubtreeWrapper(Object** p, uint16_t class_id);
(...skipping 19 matching lines...) Expand all
550 StringsStorage* names_; 525 StringsStorage* names_;
551 SnapshottingProgressReportingInterface* progress_; 526 SnapshottingProgressReportingInterface* progress_;
552 bool embedder_queried_; 527 bool embedder_queried_;
553 HeapObjectsSet in_groups_; 528 HeapObjectsSet in_groups_;
554 // RetainedObjectInfo* -> List<HeapObject*>* 529 // RetainedObjectInfo* -> List<HeapObject*>*
555 HashMap objects_by_info_; 530 HashMap objects_by_info_;
556 HashMap native_groups_; 531 HashMap native_groups_;
557 HeapEntriesAllocator* synthetic_entries_allocator_; 532 HeapEntriesAllocator* synthetic_entries_allocator_;
558 HeapEntriesAllocator* native_entries_allocator_; 533 HeapEntriesAllocator* native_entries_allocator_;
559 // Used during references extraction. 534 // Used during references extraction.
560 SnapshotFillerInterface* filler_; 535 SnapshotFiller* filler_;
561 536
562 static HeapThing const kNativesRootObject; 537 static HeapThing const kNativesRootObject;
563 538
564 friend class GlobalHandlesExtractor; 539 friend class GlobalHandlesExtractor;
565 540
566 DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer); 541 DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer);
567 }; 542 };
568 543
569 544
570 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { 545 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 friend class HeapSnapshotJSONSerializerEnumerator; 622 friend class HeapSnapshotJSONSerializerEnumerator;
648 friend class HeapSnapshotJSONSerializerIterator; 623 friend class HeapSnapshotJSONSerializerIterator;
649 624
650 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 625 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
651 }; 626 };
652 627
653 628
654 } } // namespace v8::internal 629 } } // namespace v8::internal
655 630
656 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ 631 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698