Revision: 5224
Author: [email protected]
Date: Tue Aug 10 00:30:14 2010
Log: Heap profiler: Add static assertions for heap snapshot entities' sizes.
Review URL: http://codereview.chromium.org/2808112
http://code.google.com/p/v8/source/detail?r=5224
Modified:
/branches/bleeding_edge/src/profile-generator.cc
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Mon Aug 9 07:57:13
2010
+++ /branches/bleeding_edge/src/profile-generator.cc Tue Aug 10 00:30:14
2010
@@ -1188,6 +1188,25 @@
HeapObject *const HeapSnapshot::kInternalRootObject =
reinterpret_cast<HeapObject*>(1);
+
+// It is very important to keep objects that form a heap snapshot
+// as small as possible.
+namespace { // Avoid littering the global namespace.
+
+template <size_t ptr_size> struct SnapshotSizeConstants;
+
+template <> struct SnapshotSizeConstants<4> {
+ static const int kExpectedHeapGraphEdgeSize = 12;
+ static const int kExpectedHeapEntrySize = 32;
+};
+
+template <> struct SnapshotSizeConstants<8> {
+ static const int kExpectedHeapGraphEdgeSize = 24;
+ static const int kExpectedHeapEntrySize = 40;
+};
+
+} // namespace
+
HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
const char* title,
unsigned uid)
@@ -1197,6 +1216,12 @@
root_entry_index_(-1),
raw_entries_(NULL),
entries_sorted_(false) {
+ STATIC_ASSERT(
+ sizeof(HeapGraphEdge) ==
+ SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapGraphEdgeSize);
+ STATIC_ASSERT(
+ sizeof(HeapEntry) ==
+ SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev