| 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "heap-profiler.h" | 30 #include "heap-profiler.h" |
| 31 #include "profile-generator.h" | 31 #include "profile-generator.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 | |
| 37 HeapProfiler::HeapProfiler() | 36 HeapProfiler::HeapProfiler() |
| 38 : snapshots_(new HeapSnapshotsCollection()), | 37 : snapshots_(new HeapSnapshotsCollection()), |
| 39 next_snapshot_uid_(1) { | 38 next_snapshot_uid_(1) { |
| 40 } | 39 } |
| 41 | 40 |
| 42 | 41 |
| 43 HeapProfiler::~HeapProfiler() { | 42 HeapProfiler::~HeapProfiler() { |
| 44 delete snapshots_; | 43 delete snapshots_; |
| 45 } | 44 } |
| 46 | 45 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, | 78 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, |
| 80 int type, | 79 int type, |
| 81 v8::ActivityControl* control) { | 80 v8::ActivityControl* control) { |
| 82 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 81 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 83 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, | 82 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, |
| 84 type, | 83 type, |
| 85 control); | 84 control); |
| 86 } | 85 } |
| 87 | 86 |
| 88 | 87 |
| 88 void HeapProfiler::StartHeapObjectsTracking() { |
| 89 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 90 Isolate::Current()->heap_profiler()->StartHeapObjectsTrackingImpl(); |
| 91 } |
| 92 |
| 93 |
| 94 void HeapProfiler::StopHeapObjectsTracking() { |
| 95 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 96 Isolate::Current()->heap_profiler()->StopHeapObjectsTrackingImpl(); |
| 97 } |
| 98 |
| 99 |
| 100 void HeapProfiler::PushHeapObjectsStats(v8::OutputStream* stream) { |
| 101 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 102 return Isolate::Current()->heap_profiler()->PushHeapObjectsStatsImpl(stream); |
| 103 } |
| 104 |
| 105 |
| 89 void HeapProfiler::DefineWrapperClass( | 106 void HeapProfiler::DefineWrapperClass( |
| 90 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) { | 107 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) { |
| 91 ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId); | 108 ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId); |
| 92 if (wrapper_callbacks_.length() <= class_id) { | 109 if (wrapper_callbacks_.length() <= class_id) { |
| 93 wrapper_callbacks_.AddBlock( | 110 wrapper_callbacks_.AddBlock( |
| 94 NULL, class_id - wrapper_callbacks_.length() + 1); | 111 NULL, class_id - wrapper_callbacks_.length() + 1); |
| 95 } | 112 } |
| 96 wrapper_callbacks_[class_id] = callback; | 113 wrapper_callbacks_[class_id] = callback; |
| 97 } | 114 } |
| 98 | 115 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 129 return result; | 146 return result; |
| 130 } | 147 } |
| 131 | 148 |
| 132 | 149 |
| 133 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, | 150 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, |
| 134 int type, | 151 int type, |
| 135 v8::ActivityControl* control) { | 152 v8::ActivityControl* control) { |
| 136 return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control); | 153 return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control); |
| 137 } | 154 } |
| 138 | 155 |
| 156 void HeapProfiler::StartHeapObjectsTrackingImpl() { |
| 157 snapshots_->StartHeapObjectsTracking(); |
| 158 } |
| 159 |
| 160 |
| 161 void HeapProfiler::PushHeapObjectsStatsImpl(OutputStream* stream) { |
| 162 snapshots_->PushHeapObjectsStats(stream); |
| 163 } |
| 164 |
| 165 |
| 166 void HeapProfiler::StopHeapObjectsTrackingImpl() { |
| 167 snapshots_->StopHeapObjectsTracking(); |
| 168 } |
| 169 |
| 139 | 170 |
| 140 int HeapProfiler::GetSnapshotsCount() { | 171 int HeapProfiler::GetSnapshotsCount() { |
| 141 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); | 172 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); |
| 142 ASSERT(profiler != NULL); | 173 ASSERT(profiler != NULL); |
| 143 return profiler->snapshots_->snapshots()->length(); | 174 return profiler->snapshots_->snapshots()->length(); |
| 144 } | 175 } |
| 145 | 176 |
| 146 | 177 |
| 147 HeapSnapshot* HeapProfiler::GetSnapshot(int index) { | 178 HeapSnapshot* HeapProfiler::GetSnapshot(int index) { |
| 148 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); | 179 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 164 profiler->ResetSnapshots(); | 195 profiler->ResetSnapshots(); |
| 165 } | 196 } |
| 166 | 197 |
| 167 | 198 |
| 168 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 199 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { |
| 169 snapshots_->ObjectMoveEvent(from, to); | 200 snapshots_->ObjectMoveEvent(from, to); |
| 170 } | 201 } |
| 171 | 202 |
| 172 | 203 |
| 173 } } // namespace v8::internal | 204 } } // namespace v8::internal |
| OLD | NEW |