deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / src / heap-profiler.h
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_HEAP_PROFILER_H_
6 #define V8_HEAP_PROFILER_H_
7
8 #include "src/heap-snapshot-generator-inl.h"
9 #include "src/isolate.h"
10 #include "src/smart-pointers.h"
11
12 namespace v8 {
13 namespace internal {
14
15 class HeapSnapshot;
16
17 class HeapProfiler {
18  public:
19   explicit HeapProfiler(Heap* heap);
20   ~HeapProfiler();
21
22   size_t GetMemorySizeUsedByProfiler();
23
24   HeapSnapshot* TakeSnapshot(
25       v8::ActivityControl* control,
26       v8::HeapProfiler::ObjectNameResolver* resolver);
27
28   void StartHeapObjectsTracking(bool track_allocations);
29   void StopHeapObjectsTracking();
30   AllocationTracker* allocation_tracker() const {
31     return allocation_tracker_.get();
32   }
33   HeapObjectsMap* heap_object_map() const { return ids_.get(); }
34   StringsStorage* names() const { return names_.get(); }
35
36   SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
37                                         int64_t* timestamp_us);
38   int GetSnapshotsCount();
39   HeapSnapshot* GetSnapshot(int index);
40   SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj);
41   void DeleteAllSnapshots();
42   void RemoveSnapshot(HeapSnapshot* snapshot);
43
44   void ObjectMoveEvent(Address from, Address to, int size);
45
46   void AllocationEvent(Address addr, int size);
47
48   void UpdateObjectSizeEvent(Address addr, int size);
49
50   void DefineWrapperClass(
51       uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback);
52
53   v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
54                                                       Object** wrapper);
55   void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
56
57   bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
58   bool is_tracking_allocations() const {
59     return !allocation_tracker_.is_empty();
60   }
61
62   Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
63   void ClearHeapObjectMap();
64
65  private:
66   Heap* heap() const { return ids_->heap(); }
67
68   // Mapping from HeapObject addresses to objects' uids.
69   SmartPointer<HeapObjectsMap> ids_;
70   List<HeapSnapshot*> snapshots_;
71   SmartPointer<StringsStorage> names_;
72   List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
73   SmartPointer<AllocationTracker> allocation_tracker_;
74   bool is_tracking_object_moves_;
75 };
76
77 } }  // namespace v8::internal
78
79 #endif  // V8_HEAP_PROFILER_H_