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

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

Issue 1555553002: [profiler] Implement POC Sampling Heap Profiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove unused variable Created 4 years, 11 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-profiler.h ('k') | src/profiler/sampling-heap-profiler.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/profiler/heap-profiler.h" 5 #include "src/profiler/heap-profiler.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/profiler/allocation-tracker.h" 9 #include "src/profiler/allocation-tracker.h"
10 #include "src/profiler/heap-snapshot-generator-inl.h" 10 #include "src/profiler/heap-snapshot-generator-inl.h"
11 #include "src/profiler/sampling-heap-profiler.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 HeapProfiler::HeapProfiler(Heap* heap) 16 HeapProfiler::HeapProfiler(Heap* heap)
16 : ids_(new HeapObjectsMap(heap)), 17 : ids_(new HeapObjectsMap(heap)),
17 names_(new StringsStorage(heap)), 18 names_(new StringsStorage(heap)),
18 is_tracking_object_moves_(false) { 19 is_tracking_object_moves_(false) {
19 } 20 }
20 21
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ids_->RemoveDeadEntries(); 78 ids_->RemoveDeadEntries();
78 is_tracking_object_moves_ = true; 79 is_tracking_object_moves_ = true;
79 80
80 heap()->isolate()->debug()->feature_tracker()->Track( 81 heap()->isolate()->debug()->feature_tracker()->Track(
81 DebugFeatureTracker::kHeapSnapshot); 82 DebugFeatureTracker::kHeapSnapshot);
82 83
83 return result; 84 return result;
84 } 85 }
85 86
86 87
88 bool HeapProfiler::StartSamplingHeapProfiler(uint64_t sample_interval,
89 int stack_depth) {
90 if (sampling_heap_profiler_.get()) {
91 return false;
92 }
93 sampling_heap_profiler_.Reset(new SamplingHeapProfiler(
94 heap(), names_.get(), sample_interval, stack_depth));
95 return true;
96 }
97
98
99 void HeapProfiler::StopSamplingHeapProfiler() {
100 sampling_heap_profiler_.Reset(nullptr);
101 }
102
103
104 v8::AllocationProfile* HeapProfiler::GetAllocationProfile() {
105 if (sampling_heap_profiler_.get()) {
106 return sampling_heap_profiler_->GetAllocationProfile();
107 } else {
108 return nullptr;
109 }
110 }
111
112
87 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { 113 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) {
88 ids_->UpdateHeapObjectsMap(); 114 ids_->UpdateHeapObjectsMap();
89 is_tracking_object_moves_ = true; 115 is_tracking_object_moves_ = true;
90 DCHECK(!is_tracking_allocations()); 116 DCHECK(!is_tracking_allocations());
91 if (track_allocations) { 117 if (track_allocations) {
92 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); 118 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get()));
93 heap()->DisableInlineAllocation(); 119 heap()->DisableInlineAllocation();
94 heap()->isolate()->debug()->feature_tracker()->Track( 120 heap()->isolate()->debug()->feature_tracker()->Track(
95 DebugFeatureTracker::kAllocationTracking); 121 DebugFeatureTracker::kAllocationTracking);
96 } 122 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ids_.Reset(new HeapObjectsMap(heap())); 217 ids_.Reset(new HeapObjectsMap(heap()));
192 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; 218 if (!is_tracking_allocations()) is_tracking_object_moves_ = false;
193 } 219 }
194 220
195 221
196 Heap* HeapProfiler::heap() const { return ids_->heap(); } 222 Heap* HeapProfiler::heap() const { return ids_->heap(); }
197 223
198 224
199 } // namespace internal 225 } // namespace internal
200 } // namespace v8 226 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-profiler.h ('k') | src/profiler/sampling-heap-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698