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: 2019-02-19 Functions: 2 2 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             : #include <vector>
      10             : 
      11             : #include "include/v8-profiler.h"
      12             : #include "src/base/platform/mutex.h"
      13             : #include "src/debug/debug-interface.h"
      14             : #include "src/globals.h"
      15             : #include "src/heap/heap.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20             : // Forward declarations.
      21             : class AllocationTracker;
      22             : class HeapObjectsMap;
      23             : class HeapSnapshot;
      24             : class SamplingHeapProfiler;
      25             : class StringsStorage;
      26             : 
      27      305169 : class HeapProfiler : public HeapObjectAllocationTracker {
      28             :  public:
      29             :   explicit HeapProfiler(Heap* heap);
      30             :   ~HeapProfiler() override;
      31             : 
      32             :   HeapSnapshot* TakeSnapshot(
      33             :       v8::ActivityControl* control,
      34             :       v8::HeapProfiler::ObjectNameResolver* resolver);
      35             : 
      36             :   bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth,
      37             :                                  v8::HeapProfiler::SamplingFlags);
      38             :   void StopSamplingHeapProfiler();
      39             :   bool is_sampling_allocations() { return !!sampling_heap_profiler_; }
      40             :   AllocationProfile* GetAllocationProfile();
      41             : 
      42             :   void StartHeapObjectsTracking(bool track_allocations);
      43             :   void StopHeapObjectsTracking();
      44             :   AllocationTracker* allocation_tracker() const {
      45             :     return allocation_tracker_.get();
      46             :   }
      47             :   HeapObjectsMap* heap_object_map() const { return ids_.get(); }
      48             :   StringsStorage* names() const { return names_.get(); }
      49             : 
      50             :   SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
      51             :                                         int64_t* timestamp_us);
      52             :   int GetSnapshotsCount();
      53             :   HeapSnapshot* GetSnapshot(int index);
      54             :   SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj);
      55             :   void DeleteAllSnapshots();
      56             :   void RemoveSnapshot(HeapSnapshot* snapshot);
      57             : 
      58             :   void ObjectMoveEvent(Address from, Address to, int size);
      59             : 
      60             :   void AllocationEvent(Address addr, int size) override;
      61             : 
      62             :   void UpdateObjectSizeEvent(Address addr, int size) override;
      63             : 
      64             :   void AddBuildEmbedderGraphCallback(
      65             :       v8::HeapProfiler::BuildEmbedderGraphCallback callback, void* data);
      66             :   void RemoveBuildEmbedderGraphCallback(
      67             :       v8::HeapProfiler::BuildEmbedderGraphCallback callback, void* data);
      68             :   void BuildEmbedderGraph(Isolate* isolate, v8::EmbedderGraph* graph);
      69             :   bool HasBuildEmbedderGraphCallback() {
      70             :     return !build_embedder_graph_callbacks_.empty();
      71             :   }
      72             : 
      73             :   bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
      74             : 
      75             :   Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
      76             :   void ClearHeapObjectMap();
      77             : 
      78             :   Isolate* isolate() const;
      79             : 
      80             :   void QueryObjects(Handle<Context> context,
      81             :                     debug::QueryObjectPredicate* predicate,
      82             :                     v8::PersistentValueVector<v8::Object>* objects);
      83             : 
      84             :  private:
      85             :   void MaybeClearStringsStorage();
      86             : 
      87             :   Heap* heap() const;
      88             : 
      89             :   // Mapping from HeapObject addresses to objects' uids.
      90             :   std::unique_ptr<HeapObjectsMap> ids_;
      91             :   std::vector<std::unique_ptr<HeapSnapshot>> snapshots_;
      92             :   std::unique_ptr<StringsStorage> names_;
      93             :   std::unique_ptr<AllocationTracker> allocation_tracker_;
      94             :   bool is_tracking_object_moves_;
      95             :   base::Mutex profiler_mutex_;
      96             :   std::unique_ptr<SamplingHeapProfiler> sampling_heap_profiler_;
      97             :   std::vector<std::pair<v8::HeapProfiler::BuildEmbedderGraphCallback, void*>>
      98             :       build_embedder_graph_callbacks_;
      99             : 
     100             :   DISALLOW_COPY_AND_ASSIGN(HeapProfiler);
     101             : };
     102             : 
     103             : }  // namespace internal
     104             : }  // namespace v8
     105             : 
     106             : #endif  // V8_PROFILER_HEAP_PROFILER_H_

Generated by: LCOV version 1.10