| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 | 1008 |
| 1009 | 1009 |
| 1010 int HeapEntry::RetainedSize(bool exact) { | 1010 int HeapEntry::RetainedSize(bool exact) { |
| 1011 if (exact && (retained_size_ & kExactRetainedSizeTag) == 0) { | 1011 if (exact && (retained_size_ & kExactRetainedSizeTag) == 0) { |
| 1012 CalculateExactRetainedSize(); | 1012 CalculateExactRetainedSize(); |
| 1013 } | 1013 } |
| 1014 return retained_size_ & (~kExactRetainedSizeTag); | 1014 return retained_size_ & (~kExactRetainedSizeTag); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 | 1017 |
| 1018 Handle<HeapObject> HeapEntry::GetHeapObject() { |
| 1019 return snapshot_->collection()->FindHeapObjectById(id()); |
| 1020 } |
| 1021 |
| 1022 |
| 1018 template<class Visitor> | 1023 template<class Visitor> |
| 1019 void HeapEntry::ApplyAndPaintAllReachable(Visitor* visitor) { | 1024 void HeapEntry::ApplyAndPaintAllReachable(Visitor* visitor) { |
| 1020 List<HeapEntry*> list(10); | 1025 List<HeapEntry*> list(10); |
| 1021 list.Add(this); | 1026 list.Add(this); |
| 1022 this->paint_reachable(); | 1027 this->paint_reachable(); |
| 1023 visitor->Apply(this); | 1028 visitor->Apply(this); |
| 1024 while (!list.is_empty()) { | 1029 while (!list.is_empty()) { |
| 1025 HeapEntry* entry = list.RemoveLast(); | 1030 HeapEntry* entry = list.RemoveLast(); |
| 1026 Vector<HeapGraphEdge> children = entry->children(); | 1031 Vector<HeapGraphEdge> children = entry->children(); |
| 1027 for (int i = 0; i < children.length(); ++i) { | 1032 for (int i = 0; i < children.length(); ++i) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 entries_map_(AddressesMatch), | 1373 entries_map_(AddressesMatch), |
| 1369 entries_(new List<EntryInfo>()) { } | 1374 entries_(new List<EntryInfo>()) { } |
| 1370 | 1375 |
| 1371 | 1376 |
| 1372 HeapObjectsMap::~HeapObjectsMap() { | 1377 HeapObjectsMap::~HeapObjectsMap() { |
| 1373 delete entries_; | 1378 delete entries_; |
| 1374 } | 1379 } |
| 1375 | 1380 |
| 1376 | 1381 |
| 1377 void HeapObjectsMap::SnapshotGenerationFinished() { | 1382 void HeapObjectsMap::SnapshotGenerationFinished() { |
| 1378 initial_fill_mode_ = false; | 1383 initial_fill_mode_ = false; |
| 1379 RemoveDeadEntries(); | 1384 RemoveDeadEntries(); |
| 1380 } | 1385 } |
| 1381 | 1386 |
| 1382 | 1387 |
| 1383 uint64_t HeapObjectsMap::FindObject(Address addr) { | 1388 uint64_t HeapObjectsMap::FindObject(Address addr) { |
| 1384 if (!initial_fill_mode_) { | 1389 if (!initial_fill_mode_) { |
| 1385 uint64_t existing = FindEntry(addr); | 1390 uint64_t existing = FindEntry(addr); |
| 1386 if (existing != 0) return existing; | 1391 if (existing != 0) return existing; |
| 1387 } | 1392 } |
| 1388 uint64_t id = next_id_; | 1393 uint64_t id = next_id_; |
| 1389 next_id_ += 2; | 1394 next_id_ += 2; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 | 1520 |
| 1516 | 1521 |
| 1517 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { | 1522 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { |
| 1518 snapshots_.RemoveElement(snapshot); | 1523 snapshots_.RemoveElement(snapshot); |
| 1519 unsigned uid = snapshot->uid(); | 1524 unsigned uid = snapshot->uid(); |
| 1520 snapshots_uids_.Remove(reinterpret_cast<void*>(uid), | 1525 snapshots_uids_.Remove(reinterpret_cast<void*>(uid), |
| 1521 static_cast<uint32_t>(uid)); | 1526 static_cast<uint32_t>(uid)); |
| 1522 } | 1527 } |
| 1523 | 1528 |
| 1524 | 1529 |
| 1530 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(uint64_t id) { |
| 1531 AssertNoAllocation no_allocation; |
| 1532 HeapObject* object = NULL; |
| 1533 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
| 1534 // Make sure that object with the given id is still reachable. |
| 1535 for (HeapObject* obj = iterator.next(); |
| 1536 obj != NULL; |
| 1537 obj = iterator.next()) { |
| 1538 if (ids_.FindObject(obj->address()) == id) { |
| 1539 ASSERT(object == NULL); |
| 1540 object = obj; |
| 1541 // Can't break -- kFilterUnreachable requires full heap traversal. |
| 1542 } |
| 1543 } |
| 1544 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
| 1545 } |
| 1546 |
| 1547 |
| 1525 HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = | 1548 HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = |
| 1526 reinterpret_cast<HeapEntry*>(1); | 1549 reinterpret_cast<HeapEntry*>(1); |
| 1527 | 1550 |
| 1528 HeapEntriesMap::HeapEntriesMap() | 1551 HeapEntriesMap::HeapEntriesMap() |
| 1529 : entries_(HeapThingsMatch), | 1552 : entries_(HeapThingsMatch), |
| 1530 entries_count_(0), | 1553 entries_count_(0), |
| 1531 total_children_count_(0), | 1554 total_children_count_(0), |
| 1532 total_retainers_count_(0) { | 1555 total_retainers_count_(0) { |
| 1533 } | 1556 } |
| 1534 | 1557 |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3326 | 3349 |
| 3327 | 3350 |
| 3328 void HeapSnapshotJSONSerializer::SortHashMap( | 3351 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3329 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3352 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3330 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3353 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3331 sorted_entries->Add(p); | 3354 sorted_entries->Add(p); |
| 3332 sorted_entries->Sort(SortUsingEntryValue); | 3355 sorted_entries->Sort(SortUsingEntryValue); |
| 3333 } | 3356 } |
| 3334 | 3357 |
| 3335 } } // namespace v8::internal | 3358 } } // namespace v8::internal |
| OLD | NEW |