| 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/debug/debug.h" |
| 8 #include "src/profiler/allocation-tracker.h" | 9 #include "src/profiler/allocation-tracker.h" |
| 9 #include "src/profiler/heap-snapshot-generator-inl.h" | 10 #include "src/profiler/heap-snapshot-generator-inl.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 HeapProfiler::HeapProfiler(Heap* heap) | 15 HeapProfiler::HeapProfiler(Heap* heap) |
| 15 : ids_(new HeapObjectsMap(heap)), | 16 : ids_(new HeapObjectsMap(heap)), |
| 16 names_(new StringsStorage(heap)), | 17 names_(new StringsStorage(heap)), |
| 17 is_tracking_object_moves_(false) { | 18 is_tracking_object_moves_(false) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 HeapSnapshotGenerator generator(result, control, resolver, heap()); | 69 HeapSnapshotGenerator generator(result, control, resolver, heap()); |
| 69 if (!generator.GenerateSnapshot()) { | 70 if (!generator.GenerateSnapshot()) { |
| 70 delete result; | 71 delete result; |
| 71 result = NULL; | 72 result = NULL; |
| 72 } else { | 73 } else { |
| 73 snapshots_.Add(result); | 74 snapshots_.Add(result); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 ids_->RemoveDeadEntries(); | 77 ids_->RemoveDeadEntries(); |
| 77 is_tracking_object_moves_ = true; | 78 is_tracking_object_moves_ = true; |
| 79 |
| 80 heap()->isolate()->debug()->feature_tracker()->Track( |
| 81 DebugFeatureTracker::kHeapSnapshot); |
| 82 |
| 78 return result; | 83 return result; |
| 79 } | 84 } |
| 80 | 85 |
| 81 | 86 |
| 82 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { | 87 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { |
| 83 ids_->UpdateHeapObjectsMap(); | 88 ids_->UpdateHeapObjectsMap(); |
| 84 is_tracking_object_moves_ = true; | 89 is_tracking_object_moves_ = true; |
| 85 DCHECK(!is_tracking_allocations()); | 90 DCHECK(!is_tracking_allocations()); |
| 86 if (track_allocations) { | 91 if (track_allocations) { |
| 87 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); | 92 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); |
| 88 heap()->DisableInlineAllocation(); | 93 heap()->DisableInlineAllocation(); |
| 94 heap()->isolate()->debug()->feature_tracker()->Track( |
| 95 DebugFeatureTracker::kAllocationTracking); |
| 89 } | 96 } |
| 90 } | 97 } |
| 91 | 98 |
| 92 | 99 |
| 93 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream, | 100 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream, |
| 94 int64_t* timestamp_us) { | 101 int64_t* timestamp_us) { |
| 95 return ids_->PushHeapObjectsStats(stream, timestamp_us); | 102 return ids_->PushHeapObjectsStats(stream, timestamp_us); |
| 96 } | 103 } |
| 97 | 104 |
| 98 | 105 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ids_.Reset(new HeapObjectsMap(heap())); | 191 ids_.Reset(new HeapObjectsMap(heap())); |
| 185 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 192 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; |
| 186 } | 193 } |
| 187 | 194 |
| 188 | 195 |
| 189 Heap* HeapProfiler::heap() const { return ids_->heap(); } | 196 Heap* HeapProfiler::heap() const { return ids_->heap(); } |
| 190 | 197 |
| 191 | 198 |
| 192 } // namespace internal | 199 } // namespace internal |
| 193 } // namespace v8 | 200 } // namespace v8 |
| OLD | NEW |