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.
5 #ifndef V8_HEAP_PROFILER_H_
6 #define V8_HEAP_PROFILER_H_
8 #include "src/heap-snapshot-generator-inl.h"
9 #include "src/isolate.h"
10 #include "src/smart-pointers.h"
19 explicit HeapProfiler(Heap* heap);
22 size_t GetMemorySizeUsedByProfiler();
24 HeapSnapshot* TakeSnapshot(
25 v8::ActivityControl* control,
26 v8::HeapProfiler::ObjectNameResolver* resolver);
28 void StartHeapObjectsTracking(bool track_allocations);
29 void StopHeapObjectsTracking();
30 AllocationTracker* allocation_tracker() const {
31 return allocation_tracker_.get();
33 HeapObjectsMap* heap_object_map() const { return ids_.get(); }
34 StringsStorage* names() const { return names_.get(); }
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);
44 void ObjectMoveEvent(Address from, Address to, int size);
46 void AllocationEvent(Address addr, int size);
48 void UpdateObjectSizeEvent(Address addr, int size);
50 void DefineWrapperClass(
51 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback);
53 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
55 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
57 bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
58 bool is_tracking_allocations() const {
59 return !allocation_tracker_.is_empty();
62 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
63 void ClearHeapObjectMap();
66 Heap* heap() const { return ids_->heap(); }
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_;
77 } } // namespace v8::internal
79 #endif // V8_HEAP_PROFILER_H_