From: mikhail.naganov@gmail.com Date: Tue, 10 Aug 2010 07:30:14 +0000 (+0000) Subject: Heap profiler: Add static assertions for heap snapshot entities' sizes. X-Git-Tag: upstream/4.7.83~21394 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdf15ec9f349e7c3e6ca9889d34a318a5611d479;p=platform%2Fupstream%2Fv8.git Heap profiler: Add static assertions for heap snapshot entities' sizes. Review URL: http://codereview.chromium.org/2808112 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5224 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 7653c0956..cc46606f8 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -1188,6 +1188,25 @@ void HeapGraphPath::Print() { HeapObject *const HeapSnapshot::kInternalRootObject = reinterpret_cast(1); + +// It is very important to keep objects that form a heap snapshot +// as small as possible. +namespace { // Avoid littering the global namespace. + +template 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 @@ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, root_entry_index_(-1), raw_entries_(NULL), entries_sorted_(false) { + STATIC_ASSERT( + sizeof(HeapGraphEdge) == + SnapshotSizeConstants::kExpectedHeapGraphEdgeSize); + STATIC_ASSERT( + sizeof(HeapEntry) == + SnapshotSizeConstants::kExpectedHeapEntrySize); }