OLD | NEW |
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 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 | 2819 |
2820 int NativeObjectsExplorer::EstimateObjectsCount() { | 2820 int NativeObjectsExplorer::EstimateObjectsCount() { |
2821 FillRetainedObjects(); | 2821 FillRetainedObjects(); |
2822 return objects_by_info_.occupancy(); | 2822 return objects_by_info_.occupancy(); |
2823 } | 2823 } |
2824 | 2824 |
2825 | 2825 |
2826 void NativeObjectsExplorer::FillRetainedObjects() { | 2826 void NativeObjectsExplorer::FillRetainedObjects() { |
2827 if (embedder_queried_) return; | 2827 if (embedder_queried_) return; |
2828 Isolate* isolate = Isolate::Current(); | 2828 Isolate* isolate = Isolate::Current(); |
| 2829 const GCType major_gc_type = kGCTypeMarkSweepCompact; |
2829 // Record objects that are joined into ObjectGroups. | 2830 // Record objects that are joined into ObjectGroups. |
2830 isolate->heap()->CallGlobalGCPrologueCallback(); | 2831 isolate->heap()->CallGCPrologueCallbacks(major_gc_type); |
2831 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups(); | 2832 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups(); |
2832 for (int i = 0; i < groups->length(); ++i) { | 2833 for (int i = 0; i < groups->length(); ++i) { |
2833 ObjectGroup* group = groups->at(i); | 2834 ObjectGroup* group = groups->at(i); |
2834 if (group->info_ == NULL) continue; | 2835 if (group->info_ == NULL) continue; |
2835 List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info_); | 2836 List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info_); |
2836 for (size_t j = 0; j < group->length_; ++j) { | 2837 for (size_t j = 0; j < group->length_; ++j) { |
2837 HeapObject* obj = HeapObject::cast(*group->objects_[j]); | 2838 HeapObject* obj = HeapObject::cast(*group->objects_[j]); |
2838 list->Add(obj); | 2839 list->Add(obj); |
2839 in_groups_.Insert(obj); | 2840 in_groups_.Insert(obj); |
2840 } | 2841 } |
2841 group->info_ = NULL; // Acquire info object ownership. | 2842 group->info_ = NULL; // Acquire info object ownership. |
2842 } | 2843 } |
2843 isolate->global_handles()->RemoveObjectGroups(); | 2844 isolate->global_handles()->RemoveObjectGroups(); |
2844 isolate->heap()->CallGlobalGCEpilogueCallback(); | 2845 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type); |
2845 // Record objects that are not in ObjectGroups, but have class ID. | 2846 // Record objects that are not in ObjectGroups, but have class ID. |
2846 GlobalHandlesExtractor extractor(this); | 2847 GlobalHandlesExtractor extractor(this); |
2847 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); | 2848 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); |
2848 embedder_queried_ = true; | 2849 embedder_queried_ = true; |
2849 } | 2850 } |
2850 | 2851 |
2851 void NativeObjectsExplorer::FillImplicitReferences() { | 2852 void NativeObjectsExplorer::FillImplicitReferences() { |
2852 Isolate* isolate = Isolate::Current(); | 2853 Isolate* isolate = Isolate::Current(); |
2853 List<ImplicitRefGroup*>* groups = | 2854 List<ImplicitRefGroup*>* groups = |
2854 isolate->global_handles()->implicit_ref_groups(); | 2855 isolate->global_handles()->implicit_ref_groups(); |
2855 for (int i = 0; i < groups->length(); ++i) { | 2856 for (int i = 0; i < groups->length(); ++i) { |
2856 ImplicitRefGroup* group = groups->at(i); | 2857 ImplicitRefGroup* group = groups->at(i); |
2857 HeapObject* parent = *group->parent_; | 2858 HeapObject* parent = *group->parent_; |
2858 int parent_entry = | 2859 int parent_entry = |
2859 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); | 2860 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); |
2860 ASSERT(parent_entry != HeapEntry::kNoEntry); | 2861 ASSERT(parent_entry != HeapEntry::kNoEntry); |
2861 Object*** children = group->children_; | 2862 Object*** children = group->children_; |
2862 for (size_t j = 0; j < group->length_; ++j) { | 2863 for (size_t j = 0; j < group->length_; ++j) { |
2863 Object* child = *children[j]; | 2864 Object* child = *children[j]; |
2864 HeapEntry* child_entry = | 2865 HeapEntry* child_entry = |
2865 filler_->FindOrAddEntry(child, native_entries_allocator_); | 2866 filler_->FindOrAddEntry(child, native_entries_allocator_); |
2866 filler_->SetNamedReference( | 2867 filler_->SetNamedReference( |
2867 HeapGraphEdge::kInternal, | 2868 HeapGraphEdge::kInternal, |
2868 parent_entry, | 2869 parent_entry, |
2869 "native", | 2870 "native", |
2870 child_entry); | 2871 child_entry); |
2871 } | 2872 } |
2872 } | 2873 } |
| 2874 isolate->global_handles()->RemoveImplicitRefGroups(); |
2873 } | 2875 } |
2874 | 2876 |
2875 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( | 2877 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( |
2876 v8::RetainedObjectInfo* info) { | 2878 v8::RetainedObjectInfo* info) { |
2877 HashMap::Entry* entry = | 2879 HashMap::Entry* entry = |
2878 objects_by_info_.Lookup(info, InfoHash(info), true); | 2880 objects_by_info_.Lookup(info, InfoHash(info), true); |
2879 if (entry->value != NULL) { | 2881 if (entry->value != NULL) { |
2880 info->Dispose(); | 2882 info->Dispose(); |
2881 } else { | 2883 } else { |
2882 entry->value = new List<HeapObject*>(4); | 2884 entry->value = new List<HeapObject*>(4); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3580 | 3582 |
3581 | 3583 |
3582 void HeapSnapshotJSONSerializer::SortHashMap( | 3584 void HeapSnapshotJSONSerializer::SortHashMap( |
3583 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3585 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3584 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3586 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3585 sorted_entries->Add(p); | 3587 sorted_entries->Add(p); |
3586 sorted_entries->Sort(SortUsingEntryValue); | 3588 sorted_entries->Sort(SortUsingEntryValue); |
3587 } | 3589 } |
3588 | 3590 |
3589 } } // namespace v8::internal | 3591 } } // namespace v8::internal |
OLD | NEW |