OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 int retainers_count) { | 971 int retainers_count) { |
972 snapshot_ = snapshot; | 972 snapshot_ = snapshot; |
973 type_ = type; | 973 type_ = type; |
974 painted_ = false; | 974 painted_ = false; |
975 name_ = name; | 975 name_ = name; |
976 self_size_ = self_size; | 976 self_size_ = self_size; |
977 retained_size_ = 0; | 977 retained_size_ = 0; |
978 children_count_ = children_count; | 978 children_count_ = children_count; |
979 retainers_count_ = retainers_count; | 979 retainers_count_ = retainers_count; |
980 dominator_ = NULL; | 980 dominator_ = NULL; |
981 | 981 id_ = id; |
982 union { | |
983 SnapshotObjectId set_id; | |
984 Id stored_id; | |
985 } id_adaptor = {id}; | |
986 id_ = id_adaptor.stored_id; | |
987 } | 982 } |
988 | 983 |
989 | 984 |
990 void HeapEntry::SetNamedReference(HeapGraphEdge::Type type, | 985 void HeapEntry::SetNamedReference(HeapGraphEdge::Type type, |
991 int child_index, | 986 int child_index, |
992 const char* name, | 987 const char* name, |
993 HeapEntry* entry, | 988 HeapEntry* entry, |
994 int retainer_index) { | 989 int retainer_index) { |
995 children()[child_index].Init(child_index, type, name, entry); | 990 children()[child_index].Init(child_index, type, name, entry); |
996 entry->retainers()[retainer_index] = children_arr() + child_index; | 991 entry->retainers()[retainer_index] = children_arr() + child_index; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 | 1101 |
1107 | 1102 |
1108 // It is very important to keep objects that form a heap snapshot | 1103 // It is very important to keep objects that form a heap snapshot |
1109 // as small as possible. | 1104 // as small as possible. |
1110 namespace { // Avoid littering the global namespace. | 1105 namespace { // Avoid littering the global namespace. |
1111 | 1106 |
1112 template <size_t ptr_size> struct SnapshotSizeConstants; | 1107 template <size_t ptr_size> struct SnapshotSizeConstants; |
1113 | 1108 |
1114 template <> struct SnapshotSizeConstants<4> { | 1109 template <> struct SnapshotSizeConstants<4> { |
1115 static const int kExpectedHeapGraphEdgeSize = 12; | 1110 static const int kExpectedHeapGraphEdgeSize = 12; |
1116 static const int kExpectedHeapEntrySize = 36; | 1111 static const int kExpectedHeapEntrySize = 32; |
1117 static const size_t kMaxSerializableSnapshotRawSize = 256 * MB; | 1112 static const size_t kMaxSerializableSnapshotRawSize = 256 * MB; |
1118 }; | 1113 }; |
1119 | 1114 |
1120 template <> struct SnapshotSizeConstants<8> { | 1115 template <> struct SnapshotSizeConstants<8> { |
1121 static const int kExpectedHeapGraphEdgeSize = 24; | 1116 static const int kExpectedHeapGraphEdgeSize = 24; |
1122 static const int kExpectedHeapEntrySize = 48; | 1117 static const int kExpectedHeapEntrySize = 48; |
1123 static const uint64_t kMaxSerializableSnapshotRawSize = | 1118 static const uint64_t kMaxSerializableSnapshotRawSize = |
1124 static_cast<uint64_t>(6000) * MB; | 1119 static_cast<uint64_t>(6000) * MB; |
1125 }; | 1120 }; |
1126 | 1121 |
1127 } // namespace | 1122 } // namespace |
1128 | 1123 |
1129 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, | 1124 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, |
1130 HeapSnapshot::Type type, | 1125 HeapSnapshot::Type type, |
1131 const char* title, | 1126 const char* title, |
1132 unsigned uid) | 1127 unsigned uid) |
1133 : collection_(collection), | 1128 : collection_(collection), |
1134 type_(type), | 1129 type_(type), |
1135 title_(title), | 1130 title_(title), |
1136 uid_(uid), | 1131 uid_(uid), |
1137 root_entry_(NULL), | 1132 root_entry_(NULL), |
1138 gc_roots_entry_(NULL), | 1133 gc_roots_entry_(NULL), |
1139 natives_root_entry_(NULL), | 1134 natives_root_entry_(NULL), |
1140 raw_entries_(NULL), | 1135 raw_entries_(NULL), |
1141 entries_sorted_(false) { | 1136 entries_sorted_(false) { |
1142 STATIC_ASSERT( | 1137 STATIC_CHECK( |
1143 sizeof(HeapGraphEdge) == | 1138 sizeof(HeapGraphEdge) == |
1144 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); | 1139 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); |
1145 STATIC_ASSERT( | 1140 STATIC_CHECK( |
1146 sizeof(HeapEntry) == | 1141 sizeof(HeapEntry) == |
1147 SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize); | 1142 SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize); |
1148 for (int i = 0; i < VisitorSynchronization::kNumberOfSyncTags; ++i) { | 1143 for (int i = 0; i < VisitorSynchronization::kNumberOfSyncTags; ++i) { |
1149 gc_subroot_entries_[i] = NULL; | 1144 gc_subroot_entries_[i] = NULL; |
1150 } | 1145 } |
1151 } | 1146 } |
1152 | 1147 |
1153 | 1148 |
1154 HeapSnapshot::~HeapSnapshot() { | 1149 HeapSnapshot::~HeapSnapshot() { |
1155 DeleteArray(raw_entries_); | 1150 DeleteArray(raw_entries_); |
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3736 | 3731 |
3737 | 3732 |
3738 void HeapSnapshotJSONSerializer::SortHashMap( | 3733 void HeapSnapshotJSONSerializer::SortHashMap( |
3739 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3734 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3740 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3735 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3741 sorted_entries->Add(p); | 3736 sorted_entries->Add(p); |
3742 sorted_entries->Sort(SortUsingEntryValue); | 3737 sorted_entries->Sort(SortUsingEntryValue); |
3743 } | 3738 } |
3744 | 3739 |
3745 } } // namespace v8::internal | 3740 } } // namespace v8::internal |
OLD | NEW |