LCOV - code coverage report
Current view: top level - src/profiler - heap-profiler.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2017-04-26 Functions: 1 1 100.0 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_PROFILER_HEAP_PROFILER_H_
       6             : #define V8_PROFILER_HEAP_PROFILER_H_
       7             : 
       8             : #include <memory>
       9             : 
      10             : #include "src/isolate.h"
      11             : #include "src/list.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // Forward declarations.
      17             : class AllocationTracker;
      18             : class HeapObjectsMap;
      19             : class HeapSnapshot;
      20             : class SamplingHeapProfiler;
      21             : class StringsStorage;
      22             : 
      23             : class HeapProfiler {
      24             :  public:
      25             :   explicit HeapProfiler(Heap* heap);
      26             :   ~HeapProfiler();
      27             : 
      28             :   size_t GetMemorySizeUsedByProfiler();
      29             : 
      30             :   HeapSnapshot* TakeSnapshot(
      31             :       v8::ActivityControl* control,
      32             :       v8::HeapProfiler::ObjectNameResolver* resolver);
      33             : 
      34             :   bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth,
      35             :                                  v8::HeapProfiler::SamplingFlags);
      36             :   void StopSamplingHeapProfiler();
      37             :   bool is_sampling_allocations() { return !!sampling_heap_profiler_; }
      38             :   AllocationProfile* GetAllocationProfile();
      39             : 
      40             :   void StartHeapObjectsTracking(bool track_allocations);
      41             :   void StopHeapObjectsTracking();
      42             :   AllocationTracker* allocation_tracker() const {
      43             :     return allocation_tracker_.get();
      44             :   }
      45             :   HeapObjectsMap* heap_object_map() const { return ids_.get(); }
      46             :   StringsStorage* names() const { return names_.get(); }
      47             : 
      48             :   SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
      49             :                                         int64_t* timestamp_us);
      50             :   int GetSnapshotsCount();
      51             :   HeapSnapshot* GetSnapshot(int index);
      52             :   SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj);
      53             :   void DeleteAllSnapshots();
      54             :   void RemoveSnapshot(HeapSnapshot* snapshot);
      55             : 
      56             :   void ObjectMoveEvent(Address from, Address to, int size);
      57             : 
      58             :   void AllocationEvent(Address addr, int size);
      59             : 
      60             :   void UpdateObjectSizeEvent(Address addr, int size);
      61             : 
      62             :   void DefineWrapperClass(
      63             :       uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback);
      64             : 
      65             :   v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
      66             :                                                       Object** wrapper);
      67             : 
      68             :   void SetGetRetainerInfosCallback(
      69             :       v8::HeapProfiler::GetRetainerInfosCallback callback);
      70             : 
      71             :   v8::HeapProfiler::RetainerInfos GetRetainerInfos(Isolate* isolate);
      72             : 
      73             :   bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
      74             :   bool is_tracking_allocations() const { return !!allocation_tracker_; }
      75             : 
      76             :   Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
      77             :   void ClearHeapObjectMap();
      78             : 
      79    14410540 :   Isolate* isolate() const { return heap()->isolate(); }
      80             : 
      81             :  private:
      82             :   Heap* heap() const;
      83             : 
      84             :   // Mapping from HeapObject addresses to objects' uids.
      85             :   std::unique_ptr<HeapObjectsMap> ids_;
      86             :   List<HeapSnapshot*> snapshots_;
      87             :   std::unique_ptr<StringsStorage> names_;
      88             :   List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
      89             :   std::unique_ptr<AllocationTracker> allocation_tracker_;
      90             :   bool is_tracking_object_moves_;
      91             :   base::Mutex profiler_mutex_;
      92             :   std::unique_ptr<SamplingHeapProfiler> sampling_heap_profiler_;
      93             :   v8::HeapProfiler::GetRetainerInfosCallback get_retainer_infos_callback_;
      94             : 
      95             :   DISALLOW_COPY_AND_ASSIGN(HeapProfiler);
      96             : };
      97             : 
      98             : }  // namespace internal
      99             : }  // namespace v8
     100             : 
     101             : #endif  // V8_PROFILER_HEAP_PROFILER_H_

Generated by: LCOV version 1.10