OLD | NEW |
---|---|
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 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1981 isolate->global_handles()->RemoveObjectGroups(); | 1981 isolate->global_handles()->RemoveObjectGroups(); |
1982 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type); | 1982 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type); |
1983 // Record objects that are not in ObjectGroups, but have class ID. | 1983 // Record objects that are not in ObjectGroups, but have class ID. |
1984 GlobalHandlesExtractor extractor(this); | 1984 GlobalHandlesExtractor extractor(this); |
1985 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); | 1985 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); |
1986 embedder_queried_ = true; | 1986 embedder_queried_ = true; |
1987 } | 1987 } |
1988 | 1988 |
1989 void NativeObjectsExplorer::FillImplicitReferences() { | 1989 void NativeObjectsExplorer::FillImplicitReferences() { |
1990 Isolate* isolate = Isolate::Current(); | 1990 Isolate* isolate = Isolate::Current(); |
1991 List<ImplicitRefGroup*>* groups = | 1991 List<ObjectGroupConnection>* ref_groups = |
1992 isolate->global_handles()->implicit_ref_groups(); | 1992 isolate->global_handles()->implicit_ref_groups(); |
1993 for (int i = 0; i < groups->length(); ++i) { | 1993 List<ObjectGroupRepresentativeObject>* representative_objects = |
1994 ImplicitRefGroup* group = groups->at(i); | 1994 isolate->global_handles()->representative_objects(); |
1995 HeapObject* parent = *group->parent_; | 1995 |
1996 int parent_entry = | 1996 if (ref_groups->length() == 0) |
1997 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); | 1997 return; |
1998 ASSERT(parent_entry != HeapEntry::kNoEntry); | 1998 |
1999 Object*** children = group->children_; | 1999 ref_groups->Sort(); |
2000 for (size_t j = 0; j < group->length_; ++j) { | 2000 representative_objects->Sort(); |
2001 Object* child = *children[j]; | 2001 |
2002 HeapEntry* child_entry = | 2002 int representative_objects_index = 0; |
2003 filler_->FindOrAddEntry(child, native_entries_allocator_); | 2003 UniqueId current_group_id(0); |
2004 filler_->SetNamedReference( | 2004 size_t current_group_start = 0; |
2005 HeapGraphEdge::kInternal, | 2005 for (int i = 0; i <= ref_groups->length(); ++i) { |
2006 parent_entry, | 2006 if (i == 0) |
2007 "native", | 2007 current_group_id = ref_groups->at(i).id; |
2008 child_entry); | 2008 if (i == ref_groups->length() || current_group_id != ref_groups->at(i).id) { |
2009 // Group detected: objects in indices [current_group_start, i[. | |
2010 | |
2011 // Find the representative object for this group. | |
2012 while (representative_objects_index < representative_objects->length() && | |
2013 representative_objects->at(representative_objects_index).id < | |
2014 current_group_id) | |
2015 ++representative_objects_index; | |
2016 | |
2017 if (representative_objects_index < representative_objects->length() && | |
2018 representative_objects->at(representative_objects_index).id == | |
2019 current_group_id) { | |
2020 HeapObject* parent = | |
2021 *(representative_objects->at(representative_objects_index).object); | |
2022 | |
2023 int parent_entry = | |
2024 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); | |
2025 ASSERT(parent_entry != HeapEntry::kNoEntry); | |
2026 | |
2027 for (int j = current_group_start; j < i; ++j) { | |
2028 Object* child = *(ref_groups->at(j).object); | |
2029 HeapEntry* child_entry = | |
2030 filler_->FindOrAddEntry(child, native_entries_allocator_); | |
2031 filler_->SetNamedReference( | |
2032 HeapGraphEdge::kInternal, | |
2033 parent_entry, | |
2034 "native", | |
2035 child_entry); | |
2036 } | |
2037 } else { | |
2038 // This should not happen: representative object for a group was not | |
Michael Starzinger
2013/04/16 10:42:16
Add an "UNREACHABLE();" here.
marja
2013/04/16 12:28:37
Done.
| |
2039 // set! | |
2040 } | |
2041 if (i < ref_groups->length()) { | |
2042 current_group_id = ref_groups->at(i).id; | |
2043 current_group_start = i; | |
2044 } | |
2009 } | 2045 } |
2010 } | 2046 } |
2011 isolate->global_handles()->RemoveImplicitRefGroups(); | 2047 isolate->global_handles()->RemoveImplicitRefGroups(); |
2012 } | 2048 } |
2013 | 2049 |
2014 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( | 2050 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( |
2015 v8::RetainedObjectInfo* info) { | 2051 v8::RetainedObjectInfo* info) { |
2016 HashMap::Entry* entry = | 2052 HashMap::Entry* entry = |
2017 objects_by_info_.Lookup(info, InfoHash(info), true); | 2053 objects_by_info_.Lookup(info, InfoHash(info), true); |
2018 if (entry->value != NULL) { | 2054 if (entry->value != NULL) { |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2720 | 2756 |
2721 | 2757 |
2722 void HeapSnapshotJSONSerializer::SortHashMap( | 2758 void HeapSnapshotJSONSerializer::SortHashMap( |
2723 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2759 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
2724 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2760 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
2725 sorted_entries->Add(p); | 2761 sorted_entries->Add(p); |
2726 sorted_entries->Sort(SortUsingEntryValue); | 2762 sorted_entries->Sort(SortUsingEntryValue); |
2727 } | 2763 } |
2728 | 2764 |
2729 } } // namespace v8::internal | 2765 } } // namespace v8::internal |
OLD | NEW |