OLD | NEW |
---|---|
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 Loading... | |
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", | |
mnaganov (inactive)
2012/02/03 13:57:19
Does this look descriptive enough? If implicit ref
yurys
2012/02/03 14:09:26
For now it seems good enough. We cannot assume tha
| |
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(); |
2824 FillImplicitReferences(); | |
2825 if (EstimateObjectsCount() <= 0) { | |
mnaganov (inactive)
2012/02/03 13:57:19
Let's rewrite this as follows to avoid cleanup cod
yurys
2012/02/03 14:09:26
Done.
| |
2826 filler_ = NULL; | |
2827 return true; | |
2828 } | |
2804 for (HashMap::Entry* p = objects_by_info_.Start(); | 2829 for (HashMap::Entry* p = objects_by_info_.Start(); |
2805 p != NULL; | 2830 p != NULL; |
2806 p = objects_by_info_.Next(p)) { | 2831 p = objects_by_info_.Next(p)) { |
2807 v8::RetainedObjectInfo* info = | 2832 v8::RetainedObjectInfo* info = |
2808 reinterpret_cast<v8::RetainedObjectInfo*>(p->key); | 2833 reinterpret_cast<v8::RetainedObjectInfo*>(p->key); |
2809 SetNativeRootReference(info); | 2834 SetNativeRootReference(info); |
2810 List<HeapObject*>* objects = | 2835 List<HeapObject*>* objects = |
2811 reinterpret_cast<List<HeapObject*>* >(p->value); | 2836 reinterpret_cast<List<HeapObject*>* >(p->value); |
2812 for (int i = 0; i < objects->length(); ++i) { | 2837 for (int i = 0; i < objects->length(); ++i) { |
2813 SetWrapperNativeReferences(objects->at(i), info); | 2838 SetWrapperNativeReferences(objects->at(i), info); |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3667 | 3692 |
3668 | 3693 |
3669 void HeapSnapshotJSONSerializer::SortHashMap( | 3694 void HeapSnapshotJSONSerializer::SortHashMap( |
3670 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3695 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3671 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3696 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3672 sorted_entries->Add(p); | 3697 sorted_entries->Add(p); |
3673 sorted_entries->Sort(SortUsingEntryValue); | 3698 sorted_entries->Sort(SortUsingEntryValue); |
3674 } | 3699 } |
3675 | 3700 |
3676 } } // namespace v8::internal | 3701 } } // namespace v8::internal |
OLD | NEW |