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

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

Issue 9316092: Heap profiler should report implicit references (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 10 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 | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 group->info_ = NULL; // Acquire info object ownership. 2775 group->info_ = NULL; // Acquire info object ownership.
2776 } 2776 }
2777 isolate->global_handles()->RemoveObjectGroups(); 2777 isolate->global_handles()->RemoveObjectGroups();
2778 isolate->heap()->CallGlobalGCEpilogueCallback(); 2778 isolate->heap()->CallGlobalGCEpilogueCallback();
2779 // Record objects that are not in ObjectGroups, but have class ID. 2779 // Record objects that are not in ObjectGroups, but have class ID.
2780 GlobalHandlesExtractor extractor(this); 2780 GlobalHandlesExtractor extractor(this);
2781 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); 2781 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor);
2782 embedder_queried_ = true; 2782 embedder_queried_ = true;
2783 } 2783 }
2784 2784
2785 void NativeObjectsExplorer::FillImplicitReferences() {
2786 Isolate* isolate = Isolate::Current();
2787 List<ImplicitRefGroup*>* groups =
2788 isolate->global_handles()->implicit_ref_groups();
2789 for (int i = 0; i < groups->length(); ++i) {
2790 ImplicitRefGroup* group = groups->at(i);
2791 HeapObject* parent = *group->parent_;
2792 HeapEntry* parent_entry = filler_->FindOrAddEntry(parent, this);
2793 ASSERT(parent_entry != NULL);
2794 Object*** children = group->children_;
2795 for (size_t j = 0; j < group->length_; ++j) {
2796 Object* child = *children[j];
2797 HeapEntry* child_entry = filler_->FindOrAddEntry(child, this);
2798 filler_->SetNamedReference(
2799 HeapGraphEdge::kInternal,
2800 parent, parent_entry,
2801 "native",
2802 child, child_entry);
2803 }
2804 }
2805 }
2785 2806
2786 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( 2807 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo(
2787 v8::RetainedObjectInfo* info) { 2808 v8::RetainedObjectInfo* info) {
2788 HashMap::Entry* entry = 2809 HashMap::Entry* entry =
2789 objects_by_info_.Lookup(info, InfoHash(info), true); 2810 objects_by_info_.Lookup(info, InfoHash(info), true);
2790 if (entry->value != NULL) { 2811 if (entry->value != NULL) {
2791 info->Dispose(); 2812 info->Dispose();
2792 } else { 2813 } else {
2793 entry->value = new List<HeapObject*>(4); 2814 entry->value = new List<HeapObject*>(4);
2794 } 2815 }
2795 return reinterpret_cast<List<HeapObject*>* >(entry->value); 2816 return reinterpret_cast<List<HeapObject*>* >(entry->value);
2796 } 2817 }
2797 2818
2798 2819
2799 bool NativeObjectsExplorer::IterateAndExtractReferences( 2820 bool NativeObjectsExplorer::IterateAndExtractReferences(
2800 SnapshotFillerInterface* filler) { 2821 SnapshotFillerInterface* filler) {
2801 if (EstimateObjectsCount() <= 0) return true;
2802 filler_ = filler; 2822 filler_ = filler;
2803 FillRetainedObjects(); 2823 FillRetainedObjects();
2804 for (HashMap::Entry* p = objects_by_info_.Start(); 2824 FillImplicitReferences();
2805 p != NULL; 2825 if (EstimateObjectsCount() > 0) {
2806 p = objects_by_info_.Next(p)) { 2826 for (HashMap::Entry* p = objects_by_info_.Start();
2807 v8::RetainedObjectInfo* info = 2827 p != NULL;
2808 reinterpret_cast<v8::RetainedObjectInfo*>(p->key); 2828 p = objects_by_info_.Next(p)) {
2809 SetNativeRootReference(info); 2829 v8::RetainedObjectInfo* info =
2810 List<HeapObject*>* objects = 2830 reinterpret_cast<v8::RetainedObjectInfo*>(p->key);
2811 reinterpret_cast<List<HeapObject*>* >(p->value); 2831 SetNativeRootReference(info);
2812 for (int i = 0; i < objects->length(); ++i) { 2832 List<HeapObject*>* objects =
2813 SetWrapperNativeReferences(objects->at(i), info); 2833 reinterpret_cast<List<HeapObject*>* >(p->value);
2834 for (int i = 0; i < objects->length(); ++i) {
2835 SetWrapperNativeReferences(objects->at(i), info);
2836 }
2814 } 2837 }
2838 SetRootNativeRootsReference();
2815 } 2839 }
2816 SetRootNativeRootsReference();
2817 filler_ = NULL; 2840 filler_ = NULL;
2818 return true; 2841 return true;
2819 } 2842 }
2820 2843
2821 2844
2822 class NativeGroupRetainedObjectInfo : public v8::RetainedObjectInfo { 2845 class NativeGroupRetainedObjectInfo : public v8::RetainedObjectInfo {
2823 public: 2846 public:
2824 explicit NativeGroupRetainedObjectInfo(const char* label) 2847 explicit NativeGroupRetainedObjectInfo(const char* label)
2825 : disposed_(false), 2848 : disposed_(false),
2826 hash_(reinterpret_cast<intptr_t>(label)), 2849 hash_(reinterpret_cast<intptr_t>(label)),
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
3667 3690
3668 3691
3669 void HeapSnapshotJSONSerializer::SortHashMap( 3692 void HeapSnapshotJSONSerializer::SortHashMap(
3670 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3693 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3671 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3694 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3672 sorted_entries->Add(p); 3695 sorted_entries->Add(p);
3673 sorted_entries->Sort(SortUsingEntryValue); 3696 sorted_entries->Sort(SortUsingEntryValue);
3674 } 3697 }
3675 3698
3676 } } // namespace v8::internal 3699 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698