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

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

Issue 983833006: Remove uid and title from HeapSnapshot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@cpu-profiling
Patch Set: Addressed review comments Created 5 years, 9 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/heap-profiler.h ('k') | src/heap-snapshot-generator.h » ('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 2009-2010 the V8 project authors. All rights reserved. 1 // Copyright 2009-2010 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/heap-profiler.h" 7 #include "src/heap-profiler.h"
8 8
9 #include "src/allocation-tracker.h" 9 #include "src/allocation-tracker.h"
10 #include "src/heap-snapshot-generator-inl.h" 10 #include "src/heap-snapshot-generator-inl.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 HeapProfiler::HeapProfiler(Heap* heap) 15 HeapProfiler::HeapProfiler(Heap* heap)
16 : ids_(new HeapObjectsMap(heap)), 16 : ids_(new HeapObjectsMap(heap)),
17 names_(new StringsStorage(heap)), 17 names_(new StringsStorage(heap)),
18 next_snapshot_uid_(1),
19 is_tracking_object_moves_(false) { 18 is_tracking_object_moves_(false) {
20 } 19 }
21 20
22 21
23 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) { 22 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) {
24 delete *snapshot_ptr; 23 delete *snapshot_ptr;
25 } 24 }
26 25
27 26
28 HeapProfiler::~HeapProfiler() { 27 HeapProfiler::~HeapProfiler() {
(...skipping 27 matching lines...) Expand all
56 55
57 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( 56 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback(
58 uint16_t class_id, Object** wrapper) { 57 uint16_t class_id, Object** wrapper) {
59 if (wrapper_callbacks_.length() <= class_id) return NULL; 58 if (wrapper_callbacks_.length() <= class_id) return NULL;
60 return wrapper_callbacks_[class_id]( 59 return wrapper_callbacks_[class_id](
61 class_id, Utils::ToLocal(Handle<Object>(wrapper))); 60 class_id, Utils::ToLocal(Handle<Object>(wrapper)));
62 } 61 }
63 62
64 63
65 HeapSnapshot* HeapProfiler::TakeSnapshot( 64 HeapSnapshot* HeapProfiler::TakeSnapshot(
66 const char* name,
67 v8::ActivityControl* control, 65 v8::ActivityControl* control,
68 v8::HeapProfiler::ObjectNameResolver* resolver) { 66 v8::HeapProfiler::ObjectNameResolver* resolver) {
69 HeapSnapshot* result = new HeapSnapshot(this, name, next_snapshot_uid_++); 67 HeapSnapshot* result = new HeapSnapshot(this);
70 { 68 {
71 HeapSnapshotGenerator generator(result, control, resolver, heap()); 69 HeapSnapshotGenerator generator(result, control, resolver, heap());
72 if (!generator.GenerateSnapshot()) { 70 if (!generator.GenerateSnapshot()) {
73 delete result; 71 delete result;
74 result = NULL; 72 result = NULL;
75 } else { 73 } else {
76 snapshots_.Add(result); 74 snapshots_.Add(result);
77 } 75 }
78 } 76 }
79 ids_->RemoveDeadEntries(); 77 ids_->RemoveDeadEntries();
80 is_tracking_object_moves_ = true; 78 is_tracking_object_moves_ = true;
81 return result; 79 return result;
82 } 80 }
83 81
84 82
85 HeapSnapshot* HeapProfiler::TakeSnapshot(
86 String* name,
87 v8::ActivityControl* control,
88 v8::HeapProfiler::ObjectNameResolver* resolver) {
89 return TakeSnapshot(names_->GetName(name), control, resolver);
90 }
91
92
93 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { 83 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) {
94 ids_->UpdateHeapObjectsMap(); 84 ids_->UpdateHeapObjectsMap();
95 is_tracking_object_moves_ = true; 85 is_tracking_object_moves_ = true;
96 DCHECK(!is_tracking_allocations()); 86 DCHECK(!is_tracking_allocations());
97 if (track_allocations) { 87 if (track_allocations) {
98 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); 88 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get()));
99 heap()->DisableInlineAllocation(); 89 heap()->DisableInlineAllocation();
100 } 90 }
101 } 91 }
102 92
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 179 }
190 180
191 181
192 void HeapProfiler::ClearHeapObjectMap() { 182 void HeapProfiler::ClearHeapObjectMap() {
193 ids_.Reset(new HeapObjectsMap(heap())); 183 ids_.Reset(new HeapObjectsMap(heap()));
194 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; 184 if (!is_tracking_allocations()) is_tracking_object_moves_ = false;
195 } 185 }
196 186
197 187
198 } } // namespace v8::internal 188 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-profiler.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698