| OLD | NEW | 
|---|
| 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/base/utils/random-number-generator.h" | 
| 8 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" | 
|  | 10 #include "src/frames-inl.h" | 
| 9 #include "src/profiler/allocation-tracker.h" | 11 #include "src/profiler/allocation-tracker.h" | 
| 10 #include "src/profiler/heap-snapshot-generator-inl.h" | 12 #include "src/profiler/heap-snapshot-generator-inl.h" | 
|  | 13 #include "src/profiler/sampling-heap-profiler.h" | 
| 11 | 14 | 
| 12 namespace v8 { | 15 namespace v8 { | 
| 13 namespace internal { | 16 namespace internal { | 
| 14 | 17 | 
| 15 HeapProfiler::HeapProfiler(Heap* heap) | 18 HeapProfiler::HeapProfiler(Heap* heap) | 
| 16     : ids_(new HeapObjectsMap(heap)), | 19     : ids_(new HeapObjectsMap(heap)), | 
| 17       names_(new StringsStorage(heap)), | 20       names_(new StringsStorage(heap)), | 
| 18       is_tracking_object_moves_(false) { | 21       is_tracking_object_moves_(false) { | 
| 19 } | 22 } | 
| 20 | 23 | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 77   ids_->RemoveDeadEntries(); | 80   ids_->RemoveDeadEntries(); | 
| 78   is_tracking_object_moves_ = true; | 81   is_tracking_object_moves_ = true; | 
| 79 | 82 | 
| 80   heap()->isolate()->debug()->feature_tracker()->Track( | 83   heap()->isolate()->debug()->feature_tracker()->Track( | 
| 81       DebugFeatureTracker::kHeapSnapshot); | 84       DebugFeatureTracker::kHeapSnapshot); | 
| 82 | 85 | 
| 83   return result; | 86   return result; | 
| 84 } | 87 } | 
| 85 | 88 | 
| 86 | 89 | 
|  | 90 bool HeapProfiler::StartSamplingHeapProfiler(uint64_t sample_interval, | 
|  | 91                                              int stack_depth) { | 
|  | 92   if (sampling_heap_profiler_.get()) { | 
|  | 93     return false; | 
|  | 94   } | 
|  | 95   sampling_heap_profiler_.Reset(new SamplingHeapProfiler( | 
|  | 96       heap(), names_.get(), sample_interval, stack_depth)); | 
|  | 97   return true; | 
|  | 98 } | 
|  | 99 | 
|  | 100 | 
|  | 101 void HeapProfiler::StopSamplingHeapProfiler() { | 
|  | 102   sampling_heap_profiler_.Reset(nullptr); | 
|  | 103 } | 
|  | 104 | 
|  | 105 | 
|  | 106 void HeapProfiler::GetHeapSample(OutputStream* stream) { | 
|  | 107   if (sampling_heap_profiler_.get()) { | 
|  | 108     sampling_heap_profiler_->GetHeapSample(stream); | 
|  | 109   } else { | 
|  | 110     stream->EndOfStream(); | 
|  | 111   } | 
|  | 112 } | 
|  | 113 | 
|  | 114 | 
| 87 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { | 115 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { | 
| 88   ids_->UpdateHeapObjectsMap(); | 116   ids_->UpdateHeapObjectsMap(); | 
| 89   is_tracking_object_moves_ = true; | 117   is_tracking_object_moves_ = true; | 
| 90   DCHECK(!is_tracking_allocations()); | 118   DCHECK(!is_tracking_allocations()); | 
| 91   if (track_allocations) { | 119   if (track_allocations) { | 
| 92     allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); | 120     allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); | 
| 93     heap()->DisableInlineAllocation(); | 121     heap()->DisableInlineAllocation(); | 
| 94     heap()->isolate()->debug()->feature_tracker()->Track( | 122     heap()->isolate()->debug()->feature_tracker()->Track( | 
| 95         DebugFeatureTracker::kAllocationTracking); | 123         DebugFeatureTracker::kAllocationTracking); | 
| 96   } | 124   } | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 191   ids_.Reset(new HeapObjectsMap(heap())); | 219   ids_.Reset(new HeapObjectsMap(heap())); | 
| 192   if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 220   if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 
| 193 } | 221 } | 
| 194 | 222 | 
| 195 | 223 | 
| 196 Heap* HeapProfiler::heap() const { return ids_->heap(); } | 224 Heap* HeapProfiler::heap() const { return ids_->heap(); } | 
| 197 | 225 | 
| 198 | 226 | 
| 199 }  // namespace internal | 227 }  // namespace internal | 
| 200 }  // namespace v8 | 228 }  // namespace v8 | 
| OLD | NEW | 
|---|