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

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

Issue 5314003: New Heap profiler: fix JSON serialization of aggregated profiles. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 int children_count, 867 int children_count,
868 int retainers_count) { 868 int retainers_count) {
869 snapshot_ = snapshot; 869 snapshot_ = snapshot;
870 type_ = type; 870 type_ = type;
871 painted_ = kUnpainted; 871 painted_ = kUnpainted;
872 name_ = name; 872 name_ = name;
873 self_size_ = self_size; 873 self_size_ = self_size;
874 retained_size_ = 0; 874 retained_size_ = 0;
875 children_count_ = children_count; 875 children_count_ = children_count;
876 retainers_count_ = retainers_count; 876 retainers_count_ = retainers_count;
877 dominator_ = NULL; 877 dominator_ = NULL;
Vitaly Repeshko 2010/11/23 15:27:40 Can we set it to "this" here instead?
mnaganov (inactive) 2010/11/23 15:30:38 No. The algorithm (see HeapSnapshot::BuildDominato
878 878
879 union { 879 union {
880 uint64_t set_id; 880 uint64_t set_id;
881 Id stored_id; 881 Id stored_id;
882 } id_adaptor = {id}; 882 } id_adaptor = {id};
883 id_ = id_adaptor.stored_id; 883 id_ = id_adaptor.stored_id;
884 } 884 }
885 885
886 886
887 void HeapEntry::SetNamedReference(HeapGraphEdge::Type type, 887 void HeapEntry::SetNamedReference(HeapGraphEdge::Type type,
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 } 1455 }
1456 if (new_idom != NULL && dominators->at(i) != new_idom) { 1456 if (new_idom != NULL && dominators->at(i) != new_idom) {
1457 dominators->at(i) = new_idom; 1457 dominators->at(i) = new_idom;
1458 changed = true; 1458 changed = true;
1459 } 1459 }
1460 } 1460 }
1461 } 1461 }
1462 } 1462 }
1463 1463
1464 1464
1465 void HeapSnapshot::SetDominatorsToSelf() {
1466 for (int i = 0; i < entries_.length(); ++i) {
1467 HeapEntry* entry = entries_[i];
1468 if (entry->dominator() == NULL) entry->set_dominator(entry);
1469 }
1470 }
1471
1472
1465 void HeapSnapshot::SetEntriesDominators() { 1473 void HeapSnapshot::SetEntriesDominators() {
1466 // This array is used for maintaining reverse postorder of nodes. 1474 // This array is used for maintaining reverse postorder of nodes.
1467 ScopedVector<HeapEntry*> ordered_entries(entries_.length()); 1475 ScopedVector<HeapEntry*> ordered_entries(entries_.length());
1468 FillReversePostorderIndexes(&ordered_entries); 1476 FillReversePostorderIndexes(&ordered_entries);
1469 ScopedVector<HeapEntry*> dominators(ordered_entries.length()); 1477 ScopedVector<HeapEntry*> dominators(ordered_entries.length());
1470 BuildDominatorTree(ordered_entries, &dominators); 1478 BuildDominatorTree(ordered_entries, &dominators);
1471 for (int i = 0; i < ordered_entries.length(); ++i) { 1479 for (int i = 0; i < ordered_entries.length(); ++i) {
1472 ASSERT(dominators[i] != NULL); 1480 ASSERT(dominators[i] != NULL);
1473 ordered_entries[i]->set_dominator(dominators[i]); 1481 ordered_entries[i]->set_dominator(dominators[i]);
1474 } 1482 }
1475 // For nodes unreachable from root, set dominator to itself. 1483 // For nodes unreachable from root, set dominator to itself.
1476 for (int i = 0; i < entries_.length(); ++i) { 1484 SetDominatorsToSelf();
1477 HeapEntry* entry = entries_[i];
1478 if (entry->dominator() == NULL) entry->set_dominator(entry);
1479 }
1480 } 1485 }
1481 1486
1482 1487
1483 void HeapSnapshot::ApproximateRetainedSizes() { 1488 void HeapSnapshot::ApproximateRetainedSizes() {
1484 SetEntriesDominators(); 1489 SetEntriesDominators();
1485 // As for the dominators tree we only know parent nodes, not 1490 // As for the dominators tree we only know parent nodes, not
1486 // children, to sum up total sizes we traverse the tree level by 1491 // children, to sum up total sizes we traverse the tree level by
1487 // level upwards, starting from leaves. 1492 // level upwards, starting from leaves.
1488 for (int i = 0; i < entries_.length(); ++i) { 1493 for (int i = 0; i < entries_.length(); ++i) {
1489 HeapEntry* entry = entries_[i]; 1494 HeapEntry* entry = entries_[i];
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 void HeapSnapshotJSONSerializer::SortHashMap( 2765 void HeapSnapshotJSONSerializer::SortHashMap(
2761 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2766 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2762 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2767 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2763 sorted_entries->Add(p); 2768 sorted_entries->Add(p);
2764 sorted_entries->Sort(SortUsingEntryValue); 2769 sorted_entries->Sort(SortUsingEntryValue);
2765 } 2770 }
2766 2771
2767 } } // namespace v8::internal 2772 } } // namespace v8::internal
2768 2773
2769 #endif // ENABLE_LOGGING_AND_PROFILING 2774 #endif // ENABLE_LOGGING_AND_PROFILING
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