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

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

Issue 14294009: Revert the commits adding new GC-related APIs. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: remove test 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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 return objects_by_info_.occupancy(); 1933 return objects_by_info_.occupancy();
1934 } 1934 }
1935 1935
1936 1936
1937 void NativeObjectsExplorer::FillRetainedObjects() { 1937 void NativeObjectsExplorer::FillRetainedObjects() {
1938 if (embedder_queried_) return; 1938 if (embedder_queried_) return;
1939 Isolate* isolate = Isolate::Current(); 1939 Isolate* isolate = Isolate::Current();
1940 const GCType major_gc_type = kGCTypeMarkSweepCompact; 1940 const GCType major_gc_type = kGCTypeMarkSweepCompact;
1941 // Record objects that are joined into ObjectGroups. 1941 // Record objects that are joined into ObjectGroups.
1942 isolate->heap()->CallGCPrologueCallbacks(major_gc_type); 1942 isolate->heap()->CallGCPrologueCallbacks(major_gc_type);
1943 1943 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups();
1944 List<ObjectGroupConnection>* groups = 1944 for (int i = 0; i < groups->length(); ++i) {
1945 isolate->global_handles()->object_groups(); 1945 ObjectGroup* group = groups->at(i);
1946 List<ObjectGroupRetainerInfo>* infos = 1946 if (group->info_ == NULL) continue;
1947 isolate->global_handles()->retainer_infos(); 1947 List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info_);
1948 groups->Sort(); 1948 for (size_t j = 0; j < group->length_; ++j) {
1949 infos->Sort(); 1949 HeapObject* obj = HeapObject::cast(*group->objects_[j]);
1950 1950 list->Add(obj);
1951 int info_index = 0; 1951 in_groups_.Insert(obj);
1952 UniqueId current_group_id(0);
1953 int current_group_start = 0;
1954
1955 if (groups->length() > 0) {
1956 for (int i = 0; i <= groups->length(); ++i) {
1957 if (i == 0)
1958 current_group_id = groups->at(i).id;
1959 if (i == groups->length() ||
1960 current_group_id != groups->at(i).id) {
1961 // Group detected: objects in indices [current_group_start, i[.
1962 if (info_index < infos->length() &&
1963 infos->at(info_index).id == groups->at(current_group_start).id) {
1964 // Transfer the ownership of info.
1965 List<HeapObject*>* list =
1966 GetListMaybeDisposeInfo(infos->at(info_index).info);
1967 infos->at(info_index).info = NULL;
1968 for (int j = current_group_start; j < i; ++j) {
1969 HeapObject* obj = HeapObject::cast(*(groups->at(j).object));
1970 list->Add(obj);
1971 in_groups_.Insert(obj);
1972 }
1973 }
1974 if (i < groups->length()) {
1975 current_group_id = groups->at(i).id;
1976 current_group_start = i;
1977 }
1978 }
1979 } 1952 }
1953 group->info_ = NULL; // Acquire info object ownership.
1980 } 1954 }
1981 isolate->global_handles()->RemoveObjectGroups(); 1955 isolate->global_handles()->RemoveObjectGroups();
1982 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type); 1956 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type);
1983 // Record objects that are not in ObjectGroups, but have class ID. 1957 // Record objects that are not in ObjectGroups, but have class ID.
1984 GlobalHandlesExtractor extractor(this); 1958 GlobalHandlesExtractor extractor(this);
1985 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); 1959 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor);
1986 embedder_queried_ = true; 1960 embedder_queried_ = true;
1987 } 1961 }
1988 1962
1989 void NativeObjectsExplorer::FillImplicitReferences() { 1963 void NativeObjectsExplorer::FillImplicitReferences() {
1990 Isolate* isolate = Isolate::Current(); 1964 Isolate* isolate = Isolate::Current();
1991 List<ObjectGroupConnection>* ref_groups = 1965 List<ImplicitRefGroup*>* groups =
1992 isolate->global_handles()->implicit_ref_groups(); 1966 isolate->global_handles()->implicit_ref_groups();
1993 List<ObjectGroupRepresentative>* representative_objects = 1967 for (int i = 0; i < groups->length(); ++i) {
1994 isolate->global_handles()->representative_objects(); 1968 ImplicitRefGroup* group = groups->at(i);
1995 1969 HeapObject* parent = *group->parent_;
1996 if (ref_groups->length() == 0) 1970 int parent_entry =
1997 return; 1971 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index();
1998 1972 ASSERT(parent_entry != HeapEntry::kNoEntry);
1999 ref_groups->Sort(); 1973 Object*** children = group->children_;
2000 representative_objects->Sort(); 1974 for (size_t j = 0; j < group->length_; ++j) {
2001 1975 Object* child = *children[j];
2002 int representative_objects_index = 0; 1976 HeapEntry* child_entry =
2003 UniqueId current_group_id(0); 1977 filler_->FindOrAddEntry(child, native_entries_allocator_);
2004 int current_group_start = 0; 1978 filler_->SetNamedReference(
2005 for (int i = 0; i <= ref_groups->length(); ++i) { 1979 HeapGraphEdge::kInternal,
2006 if (i == 0) 1980 parent_entry,
2007 current_group_id = ref_groups->at(i).id; 1981 "native",
2008 if (i == ref_groups->length() || current_group_id != ref_groups->at(i).id) { 1982 child_entry);
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 }
2046 } 1983 }
2047 } 1984 }
2048 isolate->global_handles()->RemoveImplicitRefGroups(); 1985 isolate->global_handles()->RemoveImplicitRefGroups();
2049 } 1986 }
2050 1987
2051 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( 1988 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo(
2052 v8::RetainedObjectInfo* info) { 1989 v8::RetainedObjectInfo* info) {
2053 HashMap::Entry* entry = 1990 HashMap::Entry* entry =
2054 objects_by_info_.Lookup(info, InfoHash(info), true); 1991 objects_by_info_.Lookup(info, InfoHash(info), true);
2055 if (entry->value != NULL) { 1992 if (entry->value != NULL) {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 2694
2758 2695
2759 void HeapSnapshotJSONSerializer::SortHashMap( 2696 void HeapSnapshotJSONSerializer::SortHashMap(
2760 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2697 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2761 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2698 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2762 sorted_entries->Add(p); 2699 sorted_entries->Add(p);
2763 sorted_entries->Sort(SortUsingEntryValue); 2700 sorted_entries->Sort(SortUsingEntryValue);
2764 } 2701 }
2765 2702
2766 } } // namespace v8::internal 2703 } } // 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