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 17 matching lines...) Expand all Loading... |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "heap-profiler.h" | 30 #include "heap-profiler.h" |
31 #include "heap-snapshot-generator-inl.h" | 31 #include "heap-snapshot-generator-inl.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 HeapProfiler::HeapProfiler(Heap* heap) | 36 HeapProfiler::HeapProfiler(Heap* heap) |
37 : snapshots_(new HeapSnapshotsCollection(heap)), | 37 : snapshots_(new HeapSnapshotsCollection(heap)), |
38 next_snapshot_uid_(1) { | 38 next_snapshot_uid_(1), |
| 39 is_tracking_allocations_(false) { |
39 } | 40 } |
40 | 41 |
41 | 42 |
42 HeapProfiler::~HeapProfiler() { | 43 HeapProfiler::~HeapProfiler() { |
43 delete snapshots_; | 44 delete snapshots_; |
44 } | 45 } |
45 | 46 |
46 | 47 |
47 void HeapProfiler::DeleteAllSnapshots() { | 48 void HeapProfiler::DeleteAllSnapshots() { |
48 Heap* the_heap = heap(); | 49 Heap* the_heap = heap(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 126 } |
126 | 127 |
127 | 128 |
128 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) { | 129 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) { |
129 if (!obj->IsHeapObject()) | 130 if (!obj->IsHeapObject()) |
130 return v8::HeapProfiler::kUnknownObjectId; | 131 return v8::HeapProfiler::kUnknownObjectId; |
131 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); | 132 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); |
132 } | 133 } |
133 | 134 |
134 | 135 |
135 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 136 void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) { |
136 snapshots_->ObjectMoveEvent(from, to); | 137 snapshots_->ObjectMoveEvent(from, to, size); |
137 } | 138 } |
138 | 139 |
| 140 |
| 141 void HeapProfiler::NewObjectEvent(Address addr, int size) { |
| 142 snapshots_->NewObjectEvent(addr, size); |
| 143 } |
| 144 |
| 145 |
139 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 146 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
140 RetainedObjectInfo* info) { | 147 RetainedObjectInfo* info) { |
141 // TODO(yurus, marja): Don't route this information through GlobalHandles. | 148 // TODO(yurus, marja): Don't route this information through GlobalHandles. |
142 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); | 149 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); |
143 } | 150 } |
144 | 151 |
| 152 |
| 153 bool* HeapProfiler::is_tracking_allocations_address() { |
| 154 return &is_tracking_allocations_; |
| 155 } |
| 156 |
| 157 |
| 158 void HeapProfiler::StartHeapAllocationsRecording() { |
| 159 StartHeapObjectsTracking(); |
| 160 is_tracking_allocations_ = true; |
| 161 } |
| 162 |
| 163 |
| 164 void HeapProfiler::StopHeapAllocationsRecording() { |
| 165 StopHeapObjectsTracking(); |
| 166 is_tracking_allocations_ = false; |
| 167 } |
| 168 |
| 169 |
| 170 void HeapProfiler::RecordObjectAllocationFromMasm(Isolate* isolate, |
| 171 Address obj, |
| 172 int size) { |
| 173 isolate->heap_profiler()->NewObjectEvent(obj, size); |
| 174 } |
| 175 |
| 176 |
| 177 int HeapProfiler::FindUntrackedObjects() { |
| 178 return snapshots_->FindUntrackedObjects(); |
| 179 } |
| 180 |
| 181 |
145 } } // namespace v8::internal | 182 } } // namespace v8::internal |
OLD | NEW |