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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "heap-profiler.h" | 7 #include "heap-profiler.h" |
8 | 8 |
9 #include "allocation-tracker.h" | 9 #include "allocation-tracker.h" |
10 #include "heap-snapshot-generator-inl.h" | 10 #include "heap-snapshot-generator-inl.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 | 167 |
168 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 168 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
169 RetainedObjectInfo* info) { | 169 RetainedObjectInfo* info) { |
170 // TODO(yurus, marja): Don't route this information through GlobalHandles. | 170 // TODO(yurus, marja): Don't route this information through GlobalHandles. |
171 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); | 171 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 Handle<HeapObject> HeapProfiler::FindHeapObjectById(SnapshotObjectId id) { | 175 Handle<HeapObject> HeapProfiler::FindHeapObjectById(SnapshotObjectId id) { |
176 heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, | |
177 "HeapProfiler::FindHeapObjectById"); | |
178 DisallowHeapAllocation no_allocation; | |
179 HeapObject* object = NULL; | 176 HeapObject* object = NULL; |
180 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); | 177 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); |
181 // Make sure that object with the given id is still reachable. | 178 // Make sure that object with the given id is still reachable. |
182 for (HeapObject* obj = iterator.next(); | 179 for (HeapObject* obj = iterator.next(); |
183 obj != NULL; | 180 obj != NULL; |
184 obj = iterator.next()) { | 181 obj = iterator.next()) { |
185 if (ids_->FindEntry(obj->address()) == id) { | 182 if (ids_->FindEntry(obj->address()) == id) { |
186 ASSERT(object == NULL); | 183 ASSERT(object == NULL); |
187 object = obj; | 184 object = obj; |
188 // Can't break -- kFilterUnreachable requires full heap traversal. | 185 // Can't break -- kFilterUnreachable requires full heap traversal. |
189 } | 186 } |
190 } | 187 } |
191 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); | 188 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
192 } | 189 } |
193 | 190 |
194 | 191 |
195 void HeapProfiler::ClearHeapObjectMap() { | 192 void HeapProfiler::ClearHeapObjectMap() { |
196 ids_.Reset(new HeapObjectsMap(heap())); | 193 ids_.Reset(new HeapObjectsMap(heap())); |
197 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 194 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; |
198 } | 195 } |
199 | 196 |
200 | 197 |
201 } } // namespace v8::internal | 198 } } // namespace v8::internal |
OLD | NEW |