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 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 28 matching lines...) Expand all Loading... |
39 #define HEAP_PROFILE(heap, call) \ | 39 #define HEAP_PROFILE(heap, call) \ |
40 do { \ | 40 do { \ |
41 v8::internal::HeapProfiler* profiler = heap->isolate()->heap_profiler(); \ | 41 v8::internal::HeapProfiler* profiler = heap->isolate()->heap_profiler(); \ |
42 if (profiler != NULL && profiler->is_profiling()) { \ | 42 if (profiler != NULL && profiler->is_profiling()) { \ |
43 profiler->call; \ | 43 profiler->call; \ |
44 } \ | 44 } \ |
45 } while (false) | 45 } while (false) |
46 | 46 |
47 class HeapProfiler { | 47 class HeapProfiler { |
48 public: | 48 public: |
49 explicit HeapProfiler(Heap* heap); | 49 static void SetUp(); |
50 ~HeapProfiler(); | 50 static void TearDown(); |
51 | 51 |
52 size_t GetMemorySizeUsedByProfiler(); | 52 static size_t GetMemorySizeUsedByProfiler(); |
53 | 53 |
54 HeapSnapshot* TakeSnapshot( | 54 static HeapSnapshot* TakeSnapshot( |
55 const char* name, | 55 const char* name, |
| 56 int type, |
56 v8::ActivityControl* control, | 57 v8::ActivityControl* control, |
57 v8::HeapProfiler::ObjectNameResolver* resolver); | 58 v8::HeapProfiler::ObjectNameResolver* resolver); |
58 HeapSnapshot* TakeSnapshot( | 59 static HeapSnapshot* TakeSnapshot( |
59 String* name, | 60 String* name, |
| 61 int type, |
60 v8::ActivityControl* control, | 62 v8::ActivityControl* control, |
61 v8::HeapProfiler::ObjectNameResolver* resolver); | 63 v8::HeapProfiler::ObjectNameResolver* resolver); |
62 | 64 |
63 void StartHeapObjectsTracking(); | 65 static void StartHeapObjectsTracking(); |
64 void StopHeapObjectsTracking(); | 66 static void StopHeapObjectsTracking(); |
65 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 67 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); |
66 int GetSnapshotsCount(); | 68 static int GetSnapshotsCount(); |
67 HeapSnapshot* GetSnapshot(int index); | 69 static HeapSnapshot* GetSnapshot(int index); |
68 HeapSnapshot* FindSnapshot(unsigned uid); | 70 static HeapSnapshot* FindSnapshot(unsigned uid); |
69 SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj); | 71 static SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj); |
70 void DeleteAllSnapshots(); | 72 static void DeleteAllSnapshots(); |
71 | 73 |
72 void ObjectMoveEvent(Address from, Address to); | 74 void ObjectMoveEvent(Address from, Address to); |
73 | 75 |
74 void DefineWrapperClass( | 76 void DefineWrapperClass( |
75 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); | 77 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); |
76 | 78 |
77 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, | 79 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, |
78 Object** wrapper); | 80 Object** wrapper); |
79 INLINE(bool is_profiling()) { | 81 INLINE(bool is_profiling()) { |
80 return snapshots_->is_tracking_objects(); | 82 return snapshots_->is_tracking_objects(); |
81 } | 83 } |
82 | 84 |
83 private: | 85 private: |
| 86 explicit HeapProfiler(Heap* heap); |
| 87 ~HeapProfiler(); |
| 88 HeapSnapshot* TakeSnapshotImpl( |
| 89 const char* name, |
| 90 int type, |
| 91 v8::ActivityControl* control, |
| 92 v8::HeapProfiler::ObjectNameResolver* resolver); |
| 93 HeapSnapshot* TakeSnapshotImpl( |
| 94 String* name, |
| 95 int type, |
| 96 v8::ActivityControl* control, |
| 97 v8::HeapProfiler::ObjectNameResolver* resolver); |
| 98 void ResetSnapshots(); |
| 99 |
| 100 void StartHeapObjectsTrackingImpl(); |
| 101 void StopHeapObjectsTrackingImpl(); |
| 102 SnapshotObjectId PushHeapObjectsStatsImpl(OutputStream* stream); |
| 103 |
84 Heap* heap() const { return snapshots_->heap(); } | 104 Heap* heap() const { return snapshots_->heap(); } |
85 | 105 |
86 HeapSnapshotsCollection* snapshots_; | 106 HeapSnapshotsCollection* snapshots_; |
87 unsigned next_snapshot_uid_; | 107 unsigned next_snapshot_uid_; |
88 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; | 108 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; |
89 }; | 109 }; |
90 | 110 |
91 } } // namespace v8::internal | 111 } } // namespace v8::internal |
92 | 112 |
93 #endif // V8_HEAP_PROFILER_H_ | 113 #endif // V8_HEAP_PROFILER_H_ |
OLD | NEW |