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

Side by Side Diff: src/profile-generator.cc

Issue 10128006: Show names for the strong roots in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId)); 1729 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId));
1730 1730
1731 1731
1732 V8HeapExplorer::V8HeapExplorer( 1732 V8HeapExplorer::V8HeapExplorer(
1733 HeapSnapshot* snapshot, 1733 HeapSnapshot* snapshot,
1734 SnapshottingProgressReportingInterface* progress) 1734 SnapshottingProgressReportingInterface* progress)
1735 : heap_(Isolate::Current()->heap()), 1735 : heap_(Isolate::Current()->heap()),
1736 snapshot_(snapshot), 1736 snapshot_(snapshot),
1737 collection_(snapshot_->collection()), 1737 collection_(snapshot_->collection()),
1738 progress_(progress), 1738 progress_(progress),
1739 filler_(NULL) { 1739 filler_(NULL),
1740 gc_subroot_names_(HeapEntriesMap::HeapThingsMatch) {
1740 } 1741 }
1741 1742
1742 1743
1743 V8HeapExplorer::~V8HeapExplorer() { 1744 V8HeapExplorer::~V8HeapExplorer() {
1744 } 1745 }
1745 1746
1746 1747
1747 HeapEntry* V8HeapExplorer::AllocateEntry( 1748 HeapEntry* V8HeapExplorer::AllocateEntry(
1748 HeapThing ptr, int children_count, int retainers_count) { 1749 HeapThing ptr, int children_count, int retainers_count) {
1749 return AddEntry( 1750 return AddEntry(
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 HeapGraphEdge::kElement, 2647 HeapGraphEdge::kElement,
2647 kGcRootsObject, snapshot_->gc_roots(), 2648 kGcRootsObject, snapshot_->gc_roots(),
2648 GetNthGcSubrootObject(tag), snapshot_->gc_subroot(tag)); 2649 GetNthGcSubrootObject(tag), snapshot_->gc_subroot(tag));
2649 } 2650 }
2650 2651
2651 2652
2652 void V8HeapExplorer::SetGcSubrootReference( 2653 void V8HeapExplorer::SetGcSubrootReference(
2653 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child_obj) { 2654 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child_obj) {
2654 HeapEntry* child_entry = GetEntry(child_obj); 2655 HeapEntry* child_entry = GetEntry(child_obj);
2655 if (child_entry != NULL) { 2656 if (child_entry != NULL) {
2656 filler_->SetIndexedAutoIndexReference( 2657 const char* name = GetGcSubrootName(child_obj);
2657 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement, 2658 if (name != NULL) {
2658 GetNthGcSubrootObject(tag), snapshot_->gc_subroot(tag), 2659 filler_->SetNamedReference(
2659 child_obj, child_entry); 2660 HeapGraphEdge::kInternal,
2661 GetNthGcSubrootObject(tag), snapshot_->gc_subroot(tag),
2662 name,
2663 child_obj, child_entry);
2664 } else {
2665 filler_->SetIndexedAutoIndexReference(
2666 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement,
2667 GetNthGcSubrootObject(tag), snapshot_->gc_subroot(tag),
2668 child_obj, child_entry);
2669 }
2660 } 2670 }
2661 } 2671 }
2662 2672
2663 2673
2674 const char* V8HeapExplorer::GetGcSubrootName(Object* object) {
2675 if (gc_subroot_names_.occupancy() == 0) {
2676 HashMap::Entry* entry;
2677 Object* obj;
2678 #define NAME_ENTRY(name) \
2679 obj = heap_->name(); \
2680 if (obj != NULL) { \
2681 entry = gc_subroot_names_.Lookup(obj, HeapEntriesMap::Hash(obj), true); \
2682 entry->value = const_cast<char*>(#name); \
2683 }
2684 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name)
2685 STRONG_ROOT_LIST(ROOT_NAME)
2686 #undef ROOT_NAME
2687 #define STRUCT_MAP_NAME(NAME, Name, name) NAME_ENTRY(name##_map)
2688 STRUCT_LIST(STRUCT_MAP_NAME)
2689 #undef STRUCT_MAP_NAME
2690 #define SYMBOL_NAME(name, str) NAME_ENTRY(name)
2691 SYMBOL_LIST(SYMBOL_NAME)
2692 #undef SYMBOL_NAME
2693 #undef NAME_ENTRY
2694 CHECK(gc_subroot_names_.occupancy() > 0);
2695 CHECK(gc_subroot_names_.occupancy() <= Heap::kStrongRootListLength);
2696 }
2697 HashMap::Entry* entry = gc_subroot_names_.Lookup(
2698 object, HeapEntriesMap::Hash(object), false);
2699 return entry != NULL ? reinterpret_cast<const char*>(entry->value) : NULL;
2700 }
2701
2702
2664 void V8HeapExplorer::TagObject(Object* obj, const char* tag) { 2703 void V8HeapExplorer::TagObject(Object* obj, const char* tag) {
2665 if (obj->IsHeapObject() && 2704 if (obj->IsHeapObject() &&
2666 !obj->IsOddball() && 2705 !obj->IsOddball() &&
2667 obj != heap_->raw_unchecked_empty_byte_array() && 2706 obj != heap_->raw_unchecked_empty_byte_array() &&
2668 obj != heap_->raw_unchecked_empty_fixed_array() && 2707 obj != heap_->raw_unchecked_empty_fixed_array() &&
2669 obj != heap_->raw_unchecked_empty_descriptor_array()) { 2708 obj != heap_->raw_unchecked_empty_descriptor_array()) {
2670 objects_tags_.SetTag(obj, tag); 2709 objects_tags_.SetTag(obj, tag);
2671 } 2710 }
2672 } 2711 }
2673 2712
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 3938
3900 3939
3901 void HeapSnapshotJSONSerializer::SortHashMap( 3940 void HeapSnapshotJSONSerializer::SortHashMap(
3902 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3941 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3903 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3942 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3904 sorted_entries->Add(p); 3943 sorted_entries->Add(p);
3905 sorted_entries->Sort(SortUsingEntryValue); 3944 sorted_entries->Sort(SortUsingEntryValue);
3906 } 3945 }
3907 3946
3908 } } // namespace v8::internal 3947 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698