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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 14175005: New GC related APIs: Implicit references. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Code review (mstarzinger) + test update Created 7 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
« no previous file with comments | « src/global-handles.cc ('k') | src/mark-compact.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 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
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<ObjectGroupRepresentative>* 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
2039 // set!
2040 UNREACHABLE();
2041 }
2042 if (i < ref_groups->length()) {
2043 current_group_id = ref_groups->at(i).id;
2044 current_group_start = i;
2045 }
2009 } 2046 }
2010 } 2047 }
2011 isolate->global_handles()->RemoveImplicitRefGroups(); 2048 isolate->global_handles()->RemoveImplicitRefGroups();
2012 } 2049 }
2013 2050
2014 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( 2051 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo(
2015 v8::RetainedObjectInfo* info) { 2052 v8::RetainedObjectInfo* info) {
2016 HashMap::Entry* entry = 2053 HashMap::Entry* entry =
2017 objects_by_info_.Lookup(info, InfoHash(info), true); 2054 objects_by_info_.Lookup(info, InfoHash(info), true);
2018 if (entry->value != NULL) { 2055 if (entry->value != NULL) {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 2757
2721 2758
2722 void HeapSnapshotJSONSerializer::SortHashMap( 2759 void HeapSnapshotJSONSerializer::SortHashMap(
2723 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2760 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2724 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2761 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2725 sorted_entries->Add(p); 2762 sorted_entries->Add(p);
2726 sorted_entries->Sort(SortUsingEntryValue); 2763 sorted_entries->Sort(SortUsingEntryValue);
2727 } 2764 }
2728 2765
2729 } } // namespace v8::internal 2766 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698