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

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

Issue 2189643004: Fix performance regression of heap snapshot generator that was (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments Created 4 years, 4 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/profiler/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/heap-snapshot-generator.h" 5 #include "src/profiler/heap-snapshot-generator.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/objects-body-descriptors.h" 10 #include "src/objects-body-descriptors.h"
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 parent_end_(HeapObject::RawField(parent_obj_, parent_obj_->Size())), 979 parent_end_(HeapObject::RawField(parent_obj_, parent_obj_->Size())),
980 parent_(parent), 980 parent_(parent),
981 next_index_(0) {} 981 next_index_(0) {}
982 void VisitCodeEntry(Address entry_address) override { 982 void VisitCodeEntry(Address entry_address) override {
983 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); 983 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
984 generator_->SetInternalReference(parent_obj_, parent_, "code", code); 984 generator_->SetInternalReference(parent_obj_, parent_, "code", code);
985 generator_->TagCodeObject(code); 985 generator_->TagCodeObject(code);
986 } 986 }
987 void VisitPointers(Object** start, Object** end) override { 987 void VisitPointers(Object** start, Object** end) override {
988 for (Object** p = start; p < end; p++) { 988 for (Object** p = start; p < end; p++) {
989 intptr_t index = 989 int index = static_cast<int>(p - HeapObject::RawField(parent_obj_, 0));
990 static_cast<intptr_t>(p - HeapObject::RawField(parent_obj_, 0));
991 ++next_index_; 990 ++next_index_;
992 // |p| could be outside of the object, e.g., while visiting RelocInfo of 991 // |p| could be outside of the object, e.g., while visiting RelocInfo of
993 // code objects. 992 // code objects.
994 if (p >= parent_start_ && p < parent_end_ && generator_->marks_[index]) { 993 if (p >= parent_start_ && p < parent_end_ && generator_->marks_[index]) {
995 generator_->marks_[index] = false; 994 generator_->marks_[index] = false;
996 continue; 995 continue;
997 } 996 }
998 generator_->SetHiddenReference(parent_obj_, parent_, next_index_, *p); 997 generator_->SetHiddenReference(parent_obj_, parent_, next_index_, *p,
998 index * kPointerSize);
999 } 999 }
1000 } 1000 }
1001 1001
1002 private: 1002 private:
1003 V8HeapExplorer* generator_; 1003 V8HeapExplorer* generator_;
1004 HeapObject* parent_obj_; 1004 HeapObject* parent_obj_;
1005 Object** parent_start_; 1005 Object** parent_start_;
1006 Object** parent_end_; 1006 Object** parent_end_;
1007 int parent_; 1007 int parent_;
1008 int next_index_; 1008 int next_index_;
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 object != heap_->empty_fixed_array() && 1828 object != heap_->empty_fixed_array() &&
1829 object != heap_->empty_descriptor_array() && 1829 object != heap_->empty_descriptor_array() &&
1830 object != heap_->fixed_array_map() && object != heap_->cell_map() && 1830 object != heap_->fixed_array_map() && object != heap_->cell_map() &&
1831 object != heap_->global_property_cell_map() && 1831 object != heap_->global_property_cell_map() &&
1832 object != heap_->shared_function_info_map() && 1832 object != heap_->shared_function_info_map() &&
1833 object != heap_->free_space_map() && 1833 object != heap_->free_space_map() &&
1834 object != heap_->one_pointer_filler_map() && 1834 object != heap_->one_pointer_filler_map() &&
1835 object != heap_->two_pointer_filler_map(); 1835 object != heap_->two_pointer_filler_map();
1836 } 1836 }
1837 1837
1838 bool V8HeapExplorer::IsEssentialHiddenReference(Object* parent,
1839 int field_offset) {
1840 if (parent->IsAllocationSite() &&
1841 field_offset == AllocationSite::kWeakNextOffset)
1842 return false;
1843 // TODO(ulan): JSFunction, Code, and Context also have next weak link, which
1844 // is non-essential. Currently they are handled as normal weak links.
1845 // Move them here.
1846 return true;
1847 }
1838 1848
1839 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, 1849 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj,
1840 int parent_entry, 1850 int parent_entry,
1841 String* reference_name, 1851 String* reference_name,
1842 Object* child_obj, 1852 Object* child_obj,
1843 int field_offset) { 1853 int field_offset) {
1844 DCHECK(parent_entry == GetEntry(parent_obj)->index()); 1854 DCHECK(parent_entry == GetEntry(parent_obj)->index());
1845 HeapEntry* child_entry = GetEntry(child_obj); 1855 HeapEntry* child_entry = GetEntry(child_obj);
1846 if (child_entry != NULL) { 1856 if (child_entry != NULL) {
1847 filler_->SetNamedReference(HeapGraphEdge::kContextVariable, 1857 filler_->SetNamedReference(HeapGraphEdge::kContextVariable,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 if (child_entry == NULL) return; 1929 if (child_entry == NULL) return;
1920 if (IsEssentialObject(child_obj)) { 1930 if (IsEssentialObject(child_obj)) {
1921 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1931 filler_->SetNamedReference(HeapGraphEdge::kInternal,
1922 parent_entry, 1932 parent_entry,
1923 names_->GetName(index), 1933 names_->GetName(index),
1924 child_entry); 1934 child_entry);
1925 } 1935 }
1926 MarkVisitedField(parent_obj, field_offset); 1936 MarkVisitedField(parent_obj, field_offset);
1927 } 1937 }
1928 1938
1929
1930 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj, 1939 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj,
1931 int parent_entry, 1940 int parent_entry, int index,
1932 int index, 1941 Object* child_obj, int field_offset) {
1933 Object* child_obj) {
1934 DCHECK(parent_entry == GetEntry(parent_obj)->index()); 1942 DCHECK(parent_entry == GetEntry(parent_obj)->index());
1935 HeapEntry* child_entry = GetEntry(child_obj); 1943 HeapEntry* child_entry = GetEntry(child_obj);
1936 if (child_entry != NULL && IsEssentialObject(child_obj)) { 1944 if (child_entry != NULL && IsEssentialObject(child_obj) &&
1945 IsEssentialHiddenReference(parent_obj, field_offset)) {
1937 filler_->SetIndexedReference(HeapGraphEdge::kHidden, 1946 filler_->SetIndexedReference(HeapGraphEdge::kHidden,
1938 parent_entry, 1947 parent_entry,
1939 index, 1948 index,
1940 child_entry); 1949 child_entry);
1941 } 1950 }
1942 } 1951 }
1943 1952
1944 1953
1945 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, 1954 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj,
1946 int parent_entry, 1955 int parent_entry,
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 for (int i = 1; i < sorted_strings.length(); ++i) { 3117 for (int i = 1; i < sorted_strings.length(); ++i) {
3109 writer_->AddCharacter(','); 3118 writer_->AddCharacter(',');
3110 SerializeString(sorted_strings[i]); 3119 SerializeString(sorted_strings[i]);
3111 if (writer_->aborted()) return; 3120 if (writer_->aborted()) return;
3112 } 3121 }
3113 } 3122 }
3114 3123
3115 3124
3116 } // namespace internal 3125 } // namespace internal
3117 } // namespace v8 3126 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698