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; |
176 HeapObject* object = NULL; | 179 HeapObject* object = NULL; |
177 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); | 180 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); |
178 // Make sure that object with the given id is still reachable. | 181 // Make sure that object with the given id is still reachable. |
179 for (HeapObject* obj = iterator.next(); | 182 for (HeapObject* obj = iterator.next(); |
180 obj != NULL; | 183 obj != NULL; |
181 obj = iterator.next()) { | 184 obj = iterator.next()) { |
182 if (ids_->FindEntry(obj->address()) == id) { | 185 if (ids_->FindEntry(obj->address()) == id) { |
183 ASSERT(object == NULL); | 186 ASSERT(object == NULL); |
184 object = obj; | 187 object = obj; |
185 // Can't break -- kFilterUnreachable requires full heap traversal. | 188 // Can't break -- kFilterUnreachable requires full heap traversal. |
186 } | 189 } |
187 } | 190 } |
188 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); | 191 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
189 } | 192 } |
190 | 193 |
191 | 194 |
192 void HeapProfiler::ClearHeapObjectMap() { | 195 void HeapProfiler::ClearHeapObjectMap() { |
193 ids_.Reset(new HeapObjectsMap(heap())); | 196 ids_.Reset(new HeapObjectsMap(heap())); |
194 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; | 197 if (!is_tracking_allocations()) is_tracking_object_moves_ = false; |
195 } | 198 } |
196 | 199 |
197 | 200 |
198 } } // namespace v8::internal | 201 } } // namespace v8::internal |
OLD | NEW |