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

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

Issue 2808112: Heap profiler: Add static assertions for heap snapshot entities' sizes. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | 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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1181 }
1182 edge->to()->Print(1, 0); 1182 edge->to()->Print(1, 0);
1183 } 1183 }
1184 OS::Print("\n"); 1184 OS::Print("\n");
1185 } 1185 }
1186 1186
1187 1187
1188 HeapObject *const HeapSnapshot::kInternalRootObject = 1188 HeapObject *const HeapSnapshot::kInternalRootObject =
1189 reinterpret_cast<HeapObject*>(1); 1189 reinterpret_cast<HeapObject*>(1);
1190 1190
1191
1192 // It is very important to keep objects that form a heap snapshot
1193 // as small as possible.
1194 namespace { // Avoid littering the global namespace.
1195
1196 template <size_t ptr_size> struct SnapshotSizeConstants;
1197
1198 template <> struct SnapshotSizeConstants<4> {
1199 static const int kExpectedHeapGraphEdgeSize = 12;
1200 static const int kExpectedHeapEntrySize = 32;
1201 };
1202
1203 template <> struct SnapshotSizeConstants<8> {
1204 static const int kExpectedHeapGraphEdgeSize = 24;
1205 static const int kExpectedHeapEntrySize = 40;
1206 };
1207
1208 } // namespace
1209
1191 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, 1210 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
1192 const char* title, 1211 const char* title,
1193 unsigned uid) 1212 unsigned uid)
1194 : collection_(collection), 1213 : collection_(collection),
1195 title_(title), 1214 title_(title),
1196 uid_(uid), 1215 uid_(uid),
1197 root_entry_index_(-1), 1216 root_entry_index_(-1),
1198 raw_entries_(NULL), 1217 raw_entries_(NULL),
1199 entries_sorted_(false) { 1218 entries_sorted_(false) {
1219 STATIC_ASSERT(
1220 sizeof(HeapGraphEdge) ==
1221 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapGraphEdgeSize);
1222 STATIC_ASSERT(
1223 sizeof(HeapEntry) ==
1224 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize);
1200 } 1225 }
1201 1226
1202 1227
1203 static void DisposeCalculatedData(HeapEntryCalculatedData* cdata) { 1228 static void DisposeCalculatedData(HeapEntryCalculatedData* cdata) {
1204 cdata->Dispose(); 1229 cdata->Dispose();
1205 } 1230 }
1206 1231
1207 HeapSnapshot::~HeapSnapshot() { 1232 HeapSnapshot::~HeapSnapshot() {
1208 DeleteArray(raw_entries_); 1233 DeleteArray(raw_entries_);
1209 calculated_data_.Iterate(DisposeCalculatedData); 1234 calculated_data_.Iterate(DisposeCalculatedData);
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 HeapEntry* entry = added_entries[i]; 2129 HeapEntry* entry = added_entries[i];
2105 if (entry->painted_reachable()) 2130 if (entry->painted_reachable())
2106 diff->AddAddedEntry(add_child_index++, added_entry_index++, entry); 2131 diff->AddAddedEntry(add_child_index++, added_entry_index++, entry);
2107 } 2132 }
2108 return diff; 2133 return diff;
2109 } 2134 }
2110 2135
2111 } } // namespace v8::internal 2136 } } // namespace v8::internal
2112 2137
2113 #endif // ENABLE_LOGGING_AND_PROFILING 2138 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698