| 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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/heap-profiler.h" | 7 #include "src/heap-profiler.h" |
| 8 | 8 |
| 9 #include "src/allocation-tracker.h" | 9 #include "src/allocation-tracker.h" |
| 10 #include "src/heap-snapshot-generator-inl.h" | 10 #include "src/heap-snapshot-generator-inl.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 void HeapProfiler::RemoveSnapshot(HeapSnapshot* snapshot) { | 41 void HeapProfiler::RemoveSnapshot(HeapSnapshot* snapshot) { |
| 42 snapshots_.RemoveElement(snapshot); | 42 snapshots_.RemoveElement(snapshot); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 void HeapProfiler::DefineWrapperClass( | 46 void HeapProfiler::DefineWrapperClass( |
| 47 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) { | 47 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) { |
| 48 ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId); | 48 DCHECK(class_id != v8::HeapProfiler::kPersistentHandleNoClassId); |
| 49 if (wrapper_callbacks_.length() <= class_id) { | 49 if (wrapper_callbacks_.length() <= class_id) { |
| 50 wrapper_callbacks_.AddBlock( | 50 wrapper_callbacks_.AddBlock( |
| 51 NULL, class_id - wrapper_callbacks_.length() + 1); | 51 NULL, class_id - wrapper_callbacks_.length() + 1); |
| 52 } | 52 } |
| 53 wrapper_callbacks_[class_id] = callback; | 53 wrapper_callbacks_[class_id] = callback; |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( | 57 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( |
| 58 uint16_t class_id, Object** wrapper) { | 58 uint16_t class_id, Object** wrapper) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 String* name, | 86 String* name, |
| 87 v8::ActivityControl* control, | 87 v8::ActivityControl* control, |
| 88 v8::HeapProfiler::ObjectNameResolver* resolver) { | 88 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 89 return TakeSnapshot(names_->GetName(name), control, resolver); | 89 return TakeSnapshot(names_->GetName(name), control, resolver); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { | 93 void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { |
| 94 ids_->UpdateHeapObjectsMap(); | 94 ids_->UpdateHeapObjectsMap(); |
| 95 is_tracking_object_moves_ = true; | 95 is_tracking_object_moves_ = true; |
| 96 ASSERT(!is_tracking_allocations()); | 96 DCHECK(!is_tracking_allocations()); |
| 97 if (track_allocations) { | 97 if (track_allocations) { |
| 98 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); | 98 allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); |
| 99 heap()->DisableInlineAllocation(); | 99 heap()->DisableInlineAllocation(); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { | 104 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { |
| 105 return ids_->PushHeapObjectsStats(stream); | 105 return ids_->PushHeapObjectsStats(stream); |
| 106 } | 106 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 | 174 |
| 175 Handle<HeapObject> HeapProfiler::FindHeapObjectById(SnapshotObjectId id) { | 175 Handle<HeapObject> HeapProfiler::FindHeapObjectById(SnapshotObjectId id) { |
| 176 HeapObject* object = NULL; | 176 HeapObject* object = NULL; |
| 177 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); | 177 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); |
| 178 // Make sure that object with the given id is still reachable. | 178 // Make sure that object with the given id is still reachable. |
| 179 for (HeapObject* obj = iterator.next(); | 179 for (HeapObject* obj = iterator.next(); |
| 180 obj != NULL; | 180 obj != NULL; |
| 181 obj = iterator.next()) { | 181 obj = iterator.next()) { |
| 182 if (ids_->FindEntry(obj->address()) == id) { | 182 if (ids_->FindEntry(obj->address()) == id) { |
| 183 ASSERT(object == NULL); | 183 DCHECK(object == NULL); |
| 184 object = obj; | 184 object = obj; |
| 185 // Can't break -- kFilterUnreachable requires full heap traversal. | 185 // Can't break -- kFilterUnreachable requires full heap traversal. |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); | 188 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 void HeapProfiler::ClearHeapObjectMap() { | 192 void HeapProfiler::ClearHeapObjectMap() { |
| 193 ids_.Reset(new HeapObjectsMap(heap())); | 193 ids_.Reset(new HeapObjectsMap(heap())); |
| 194 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 194 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 } } // namespace v8::internal | 198 } } // namespace v8::internal |
| OLD | NEW |