Index: src/profile-generator.cc |
diff --git a/src/profile-generator.cc b/src/profile-generator.cc |
index 814e9b3e9d578a62850a3dab5d46d41bdd022bf2..c075c031e1ddfbfbdbadf743b76948c3b380902f 100644 |
--- a/src/profile-generator.cc |
+++ b/src/profile-generator.cc |
@@ -1015,6 +1015,11 @@ int HeapEntry::RetainedSize(bool exact) { |
} |
+Handle<HeapObject> HeapEntry::GetHeapObject() { |
+ return snapshot_->collection()->FindHeapObjectById(id()); |
+} |
+ |
+ |
template<class Visitor> |
void HeapEntry::ApplyAndPaintAllReachable(Visitor* visitor) { |
List<HeapEntry*> list(10); |
@@ -1375,8 +1380,8 @@ HeapObjectsMap::~HeapObjectsMap() { |
void HeapObjectsMap::SnapshotGenerationFinished() { |
- initial_fill_mode_ = false; |
- RemoveDeadEntries(); |
+ initial_fill_mode_ = false; |
+ RemoveDeadEntries(); |
} |
@@ -1522,6 +1527,26 @@ void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { |
} |
+Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(uint64_t id) { |
+ // First perform a full GC in order to avoid dead objects. |
+ HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); |
+ AssertNoAllocation no_allocation; |
+ HeapObject* object = NULL; |
+ HeapIterator iterator(HeapIterator::kFilterUnreachable); |
+ // Make sure that object with the given id is still reachable. |
+ for (HeapObject* obj = iterator.next(); |
+ obj != NULL; |
+ obj = iterator.next()) { |
+ if (ids_.FindObject(obj->address()) == id) { |
Vyacheslav Egorov (Chromium)
2011/09/26 14:22:10
this is not going to work if obj was in new space
mnaganov (inactive)
2011/09/26 14:28:19
What do you mean? We start keeping IDs for heap ob
|
+ ASSERT(object == NULL); |
+ object = obj; |
+ // Can't break -- kFilterUnreachable requires full heap traversal. |
Vyacheslav Egorov (Chromium)
2011/09/26 14:22:10
We can fix this by switching kFilterUnreachable fr
mnaganov (inactive)
2011/09/26 14:28:19
Yes, that's a good idea. I will create a bug to tr
|
+ } |
+ } |
+ return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
+} |
+ |
+ |
HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = |
reinterpret_cast<HeapEntry*>(1); |