Chromium Code Reviews| 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 #ifndef V8_PROFILER_HEAP_PROFILER_H_ | 5 #ifndef V8_PROFILER_HEAP_PROFILER_H_ |
| 6 #define V8_PROFILER_HEAP_PROFILER_H_ | 6 #define V8_PROFILER_HEAP_PROFILER_H_ |
| 7 | 7 |
| 8 #include "src/base/smart-pointers.h" | 8 #include <memory> |
| 9 | |
| 9 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| 10 #include "src/list.h" | 11 #include "src/list.h" |
| 11 | 12 |
| 12 namespace v8 { | 13 namespace v8 { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 // Forward declarations. | 16 // Forward declarations. |
| 16 class AllocationTracker; | 17 class AllocationTracker; |
| 17 class HeapObjectsMap; | 18 class HeapObjectsMap; |
| 18 class HeapSnapshot; | 19 class HeapSnapshot; |
| 19 class SamplingHeapProfiler; | 20 class SamplingHeapProfiler; |
| 20 class StringsStorage; | 21 class StringsStorage; |
| 21 | 22 |
| 22 class HeapProfiler { | 23 class HeapProfiler { |
| 23 public: | 24 public: |
| 24 explicit HeapProfiler(Heap* heap); | 25 explicit HeapProfiler(Heap* heap); |
| 25 ~HeapProfiler(); | 26 ~HeapProfiler(); |
| 26 | 27 |
| 27 size_t GetMemorySizeUsedByProfiler(); | 28 size_t GetMemorySizeUsedByProfiler(); |
| 28 | 29 |
| 29 HeapSnapshot* TakeSnapshot( | 30 HeapSnapshot* TakeSnapshot( |
| 30 v8::ActivityControl* control, | 31 v8::ActivityControl* control, |
| 31 v8::HeapProfiler::ObjectNameResolver* resolver); | 32 v8::HeapProfiler::ObjectNameResolver* resolver); |
| 32 | 33 |
| 33 bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth, | 34 bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth, |
| 34 v8::HeapProfiler::SamplingFlags); | 35 v8::HeapProfiler::SamplingFlags); |
| 35 void StopSamplingHeapProfiler(); | 36 void StopSamplingHeapProfiler(); |
| 36 bool is_sampling_allocations() { return !sampling_heap_profiler_.is_empty(); } | 37 bool is_sampling_allocations() { return !!sampling_heap_profiler_; } |
|
Igor Sheludko
2016/07/25 09:58:10
same here
| |
| 37 AllocationProfile* GetAllocationProfile(); | 38 AllocationProfile* GetAllocationProfile(); |
| 38 | 39 |
| 39 void StartHeapObjectsTracking(bool track_allocations); | 40 void StartHeapObjectsTracking(bool track_allocations); |
| 40 void StopHeapObjectsTracking(); | 41 void StopHeapObjectsTracking(); |
| 41 AllocationTracker* allocation_tracker() const { | 42 AllocationTracker* allocation_tracker() const { |
| 42 return allocation_tracker_.get(); | 43 return allocation_tracker_.get(); |
| 43 } | 44 } |
| 44 HeapObjectsMap* heap_object_map() const { return ids_.get(); } | 45 HeapObjectsMap* heap_object_map() const { return ids_.get(); } |
| 45 StringsStorage* names() const { return names_.get(); } | 46 StringsStorage* names() const { return names_.get(); } |
| 46 | 47 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 59 void UpdateObjectSizeEvent(Address addr, int size); | 60 void UpdateObjectSizeEvent(Address addr, int size); |
| 60 | 61 |
| 61 void DefineWrapperClass( | 62 void DefineWrapperClass( |
| 62 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); | 63 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); |
| 63 | 64 |
| 64 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, | 65 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, |
| 65 Object** wrapper); | 66 Object** wrapper); |
| 66 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); | 67 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); |
| 67 | 68 |
| 68 bool is_tracking_object_moves() const { return is_tracking_object_moves_; } | 69 bool is_tracking_object_moves() const { return is_tracking_object_moves_; } |
| 69 bool is_tracking_allocations() const { | 70 bool is_tracking_allocations() const { return !!allocation_tracker_; } |
|
Igor Sheludko
2016/07/25 09:58:10
same here
| |
| 70 return !allocation_tracker_.is_empty(); | |
| 71 } | |
| 72 | 71 |
| 73 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 72 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
| 74 void ClearHeapObjectMap(); | 73 void ClearHeapObjectMap(); |
| 75 | 74 |
| 76 Isolate* isolate() const { return heap()->isolate(); } | 75 Isolate* isolate() const { return heap()->isolate(); } |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 Heap* heap() const; | 78 Heap* heap() const; |
| 80 | 79 |
| 81 // Mapping from HeapObject addresses to objects' uids. | 80 // Mapping from HeapObject addresses to objects' uids. |
| 82 base::SmartPointer<HeapObjectsMap> ids_; | 81 std::unique_ptr<HeapObjectsMap> ids_; |
| 83 List<HeapSnapshot*> snapshots_; | 82 List<HeapSnapshot*> snapshots_; |
| 84 base::SmartPointer<StringsStorage> names_; | 83 std::unique_ptr<StringsStorage> names_; |
| 85 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; | 84 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; |
| 86 base::SmartPointer<AllocationTracker> allocation_tracker_; | 85 std::unique_ptr<AllocationTracker> allocation_tracker_; |
| 87 bool is_tracking_object_moves_; | 86 bool is_tracking_object_moves_; |
| 88 base::Mutex profiler_mutex_; | 87 base::Mutex profiler_mutex_; |
| 89 base::SmartPointer<SamplingHeapProfiler> sampling_heap_profiler_; | 88 std::unique_ptr<SamplingHeapProfiler> sampling_heap_profiler_; |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(HeapProfiler); | |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 } // namespace internal | 93 } // namespace internal |
| 93 } // namespace v8 | 94 } // namespace v8 |
| 94 | 95 |
| 95 #endif // V8_PROFILER_HEAP_PROFILER_H_ | 96 #endif // V8_PROFILER_HEAP_PROFILER_H_ |
| OLD | NEW |