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

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

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 years, 7 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') | src/snapshot/code-serializer.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 <utility> 7 #include <utility>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
11 #include "src/conversions.h" 11 #include "src/conversions.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/layout-descriptor.h" 13 #include "src/layout-descriptor.h"
14 #include "src/objects-body-descriptors.h" 14 #include "src/objects-body-descriptors.h"
15 #include "src/objects-inl.h" 15 #include "src/objects-inl.h"
16 #include "src/profiler/allocation-tracker.h" 16 #include "src/profiler/allocation-tracker.h"
17 #include "src/profiler/heap-profiler.h" 17 #include "src/profiler/heap-profiler.h"
18 #include "src/profiler/heap-snapshot-generator-inl.h" 18 #include "src/profiler/heap-snapshot-generator-inl.h"
19 #include "src/prototype.h" 19 #include "src/prototype.h"
20 #include "src/transitions.h" 20 #include "src/transitions.h"
21 #include "src/visitors.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 25
25 26
26 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) 27 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to)
27 : bit_field_(TypeField::encode(type) | FromIndexField::encode(from)), 28 : bit_field_(TypeField::encode(type) | FromIndexField::encode(from)),
28 to_index_(to), 29 to_index_(to),
29 name_(name) { 30 name_(name) {
30 DCHECK(type == kContextVariable 31 DCHECK(type == kContextVariable
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 HandleScope scope(isolate); 1679 HandleScope scope(isolate);
1679 return *JSReceiver::GetConstructorName(handle(object, isolate)); 1680 return *JSReceiver::GetConstructorName(handle(object, isolate));
1680 } 1681 }
1681 1682
1682 1683
1683 HeapEntry* V8HeapExplorer::GetEntry(Object* obj) { 1684 HeapEntry* V8HeapExplorer::GetEntry(Object* obj) {
1684 if (!obj->IsHeapObject()) return NULL; 1685 if (!obj->IsHeapObject()) return NULL;
1685 return filler_->FindOrAddEntry(obj, this); 1686 return filler_->FindOrAddEntry(obj, this);
1686 } 1687 }
1687 1688
1688 1689 class RootsReferencesExtractor : public RootVisitor {
1689 class RootsReferencesExtractor : public ObjectVisitor {
1690 private: 1690 private:
1691 struct IndexTag { 1691 struct IndexTag {
1692 IndexTag(int index, VisitorSynchronization::SyncTag tag) 1692 IndexTag(int index, VisitorSynchronization::SyncTag tag)
1693 : index(index), tag(tag) { } 1693 : index(index), tag(tag) { }
1694 int index; 1694 int index;
1695 VisitorSynchronization::SyncTag tag; 1695 VisitorSynchronization::SyncTag tag;
1696 }; 1696 };
1697 1697
1698 public: 1698 public:
1699 explicit RootsReferencesExtractor(Heap* heap) 1699 explicit RootsReferencesExtractor(Heap* heap)
1700 : collecting_all_references_(false), 1700 : collecting_all_references_(false),
1701 previous_reference_count_(0), 1701 previous_reference_count_(0),
1702 heap_(heap) { 1702 heap_(heap) {
1703 } 1703 }
1704 1704
1705 void VisitPointers(Object** start, Object** end) override { 1705 void VisitRootPointers(Root root, Object** start, Object** end) override {
1706 if (collecting_all_references_) { 1706 if (collecting_all_references_) {
1707 for (Object** p = start; p < end; p++) all_references_.Add(*p); 1707 for (Object** p = start; p < end; p++) all_references_.Add(*p);
1708 } else { 1708 } else {
1709 for (Object** p = start; p < end; p++) strong_references_.Add(*p); 1709 for (Object** p = start; p < end; p++) strong_references_.Add(*p);
1710 } 1710 }
1711 } 1711 }
1712 1712
1713 void SetCollectingAllReferences() { collecting_all_references_ = true; } 1713 void SetCollectingAllReferences() { collecting_all_references_ = true; }
1714 1714
1715 void FillReferences(V8HeapExplorer* explorer) { 1715 void FillReferences(V8HeapExplorer* explorer) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 } 2140 }
2141 } 2141 }
2142 } 2142 }
2143 2143
2144 void V8HeapExplorer::TagFixedArraySubType(const FixedArray* array, 2144 void V8HeapExplorer::TagFixedArraySubType(const FixedArray* array,
2145 FixedArraySubInstanceType type) { 2145 FixedArraySubInstanceType type) {
2146 DCHECK(array_types_.find(array) == array_types_.end()); 2146 DCHECK(array_types_.find(array) == array_types_.end());
2147 array_types_[array] = type; 2147 array_types_[array] = type;
2148 } 2148 }
2149 2149
2150 class GlobalObjectsEnumerator : public ObjectVisitor { 2150 class GlobalObjectsEnumerator : public RootVisitor {
2151 public: 2151 public:
2152 void VisitPointers(Object** start, Object** end) override { 2152 void VisitRootPointers(Root root, Object** start, Object** end) override {
2153 for (Object** p = start; p < end; p++) { 2153 for (Object** p = start; p < end; p++) {
2154 if ((*p)->IsNativeContext()) { 2154 if ((*p)->IsNativeContext()) {
2155 Context* context = Context::cast(*p); 2155 Context* context = Context::cast(*p);
2156 JSObject* proxy = context->global_proxy(); 2156 JSObject* proxy = context->global_proxy();
2157 if (proxy->IsJSGlobalProxy()) { 2157 if (proxy->IsJSGlobalProxy()) {
2158 Object* global = proxy->map()->prototype(); 2158 Object* global = proxy->map()->prototype();
2159 if (global->IsJSGlobalObject()) { 2159 if (global->IsJSGlobalObject()) {
2160 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global))); 2160 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global)));
2161 } 2161 }
2162 } 2162 }
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 for (int i = 1; i < sorted_strings.length(); ++i) { 3136 for (int i = 1; i < sorted_strings.length(); ++i) {
3137 writer_->AddCharacter(','); 3137 writer_->AddCharacter(',');
3138 SerializeString(sorted_strings[i]); 3138 SerializeString(sorted_strings[i]);
3139 if (writer_->aborted()) return; 3139 if (writer_->aborted()) return;
3140 } 3140 }
3141 } 3141 }
3142 3142
3143 3143
3144 } // namespace internal 3144 } // namespace internal
3145 } // namespace v8 3145 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | src/snapshot/code-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698