Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: src/profile-generator.cc

Issue 8046006: Add v8::HeapGraphNode::GetHeapValue method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 // First perform a full GC in order to avoid dead objects.
1532 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
1533 AssertNoAllocation no_allocation;
1534 HeapObject* object = NULL;
1535 HeapIterator iterator(HeapIterator::kFilterUnreachable);
1536 // Make sure that object with the given id is still reachable.
1537 for (HeapObject* obj = iterator.next();
1538 obj != NULL;
1539 obj = iterator.next()) {
1540 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
1541 ASSERT(object == NULL);
1542 object = obj;
1543 // 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
1544 }
1545 }
1546 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>();
1547 }
1548
1549
1525 HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = 1550 HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder =
1526 reinterpret_cast<HeapEntry*>(1); 1551 reinterpret_cast<HeapEntry*>(1);
1527 1552
1528 HeapEntriesMap::HeapEntriesMap() 1553 HeapEntriesMap::HeapEntriesMap()
1529 : entries_(HeapThingsMatch), 1554 : entries_(HeapThingsMatch),
1530 entries_count_(0), 1555 entries_count_(0),
1531 total_children_count_(0), 1556 total_children_count_(0),
1532 total_retainers_count_(0) { 1557 total_retainers_count_(0) {
1533 } 1558 }
1534 1559
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 3393
3369 3394
3370 void HeapSnapshotJSONSerializer::SortHashMap( 3395 void HeapSnapshotJSONSerializer::SortHashMap(
3371 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3396 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3372 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3397 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3373 sorted_entries->Add(p); 3398 sorted_entries->Add(p);
3374 sorted_entries->Sort(SortUsingEntryValue); 3399 sorted_entries->Sort(SortUsingEntryValue);
3375 } 3400 }
3376 3401
3377 } } // namespace v8::internal 3402 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698