OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap-snapshot-generator-inl.h" | 7 #include "src/heap-snapshot-generator-inl.h" |
8 | 8 |
9 #include "src/allocation-tracker.h" | 9 #include "src/allocation-tracker.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 }; | 171 }; |
172 | 172 |
173 template <> struct SnapshotSizeConstants<8> { | 173 template <> struct SnapshotSizeConstants<8> { |
174 static const int kExpectedHeapGraphEdgeSize = 24; | 174 static const int kExpectedHeapGraphEdgeSize = 24; |
175 static const int kExpectedHeapEntrySize = 40; | 175 static const int kExpectedHeapEntrySize = 40; |
176 }; | 176 }; |
177 | 177 |
178 } // namespace | 178 } // namespace |
179 | 179 |
180 | 180 |
181 HeapSnapshot::HeapSnapshot(HeapProfiler* profiler, | 181 HeapSnapshot::HeapSnapshot(HeapProfiler* profiler) |
182 const char* title, | |
183 unsigned uid) | |
184 : profiler_(profiler), | 182 : profiler_(profiler), |
185 title_(title), | |
186 uid_(uid), | |
187 root_index_(HeapEntry::kNoEntry), | 183 root_index_(HeapEntry::kNoEntry), |
188 gc_roots_index_(HeapEntry::kNoEntry), | 184 gc_roots_index_(HeapEntry::kNoEntry), |
189 max_snapshot_js_object_id_(0) { | 185 max_snapshot_js_object_id_(0) { |
190 STATIC_ASSERT( | 186 STATIC_ASSERT( |
191 sizeof(HeapGraphEdge) == | 187 sizeof(HeapGraphEdge) == |
192 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); | 188 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); |
193 STATIC_ASSERT( | 189 STATIC_ASSERT( |
194 sizeof(HeapEntry) == | 190 sizeof(HeapEntry) == |
195 SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize); | 191 SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize); |
196 USE(SnapshotSizeConstants<4>::kExpectedHeapGraphEdgeSize); | 192 USE(SnapshotSizeConstants<4>::kExpectedHeapGraphEdgeSize); |
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 void HeapSnapshotJSONSerializer::SerializeNodes() { | 2872 void HeapSnapshotJSONSerializer::SerializeNodes() { |
2877 List<HeapEntry>& entries = snapshot_->entries(); | 2873 List<HeapEntry>& entries = snapshot_->entries(); |
2878 for (int i = 0; i < entries.length(); ++i) { | 2874 for (int i = 0; i < entries.length(); ++i) { |
2879 SerializeNode(&entries[i]); | 2875 SerializeNode(&entries[i]); |
2880 if (writer_->aborted()) return; | 2876 if (writer_->aborted()) return; |
2881 } | 2877 } |
2882 } | 2878 } |
2883 | 2879 |
2884 | 2880 |
2885 void HeapSnapshotJSONSerializer::SerializeSnapshot() { | 2881 void HeapSnapshotJSONSerializer::SerializeSnapshot() { |
2886 writer_->AddString("\"title\":\""); | 2882 writer_->AddString("\"meta\":"); |
2887 writer_->AddString(snapshot_->title()); | |
2888 writer_->AddString("\""); | |
2889 writer_->AddString(",\"uid\":"); | |
2890 writer_->AddNumber(snapshot_->uid()); | |
2891 writer_->AddString(",\"meta\":"); | |
2892 // The object describing node serialization layout. | 2883 // The object describing node serialization layout. |
2893 // We use a set of macros to improve readability. | 2884 // We use a set of macros to improve readability. |
2894 #define JSON_A(s) "[" s "]" | 2885 #define JSON_A(s) "[" s "]" |
2895 #define JSON_O(s) "{" s "}" | 2886 #define JSON_O(s) "{" s "}" |
2896 #define JSON_S(s) "\"" s "\"" | 2887 #define JSON_S(s) "\"" s "\"" |
2897 writer_->AddString(JSON_O( | 2888 writer_->AddString(JSON_O( |
2898 JSON_S("node_fields") ":" JSON_A( | 2889 JSON_S("node_fields") ":" JSON_A( |
2899 JSON_S("type") "," | 2890 JSON_S("type") "," |
2900 JSON_S("name") "," | 2891 JSON_S("name") "," |
2901 JSON_S("id") "," | 2892 JSON_S("id") "," |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3129 writer_->AddString("\"<dummy>\""); | 3120 writer_->AddString("\"<dummy>\""); |
3130 for (int i = 1; i < sorted_strings.length(); ++i) { | 3121 for (int i = 1; i < sorted_strings.length(); ++i) { |
3131 writer_->AddCharacter(','); | 3122 writer_->AddCharacter(','); |
3132 SerializeString(sorted_strings[i]); | 3123 SerializeString(sorted_strings[i]); |
3133 if (writer_->aborted()) return; | 3124 if (writer_->aborted()) return; |
3134 } | 3125 } |
3135 } | 3126 } |
3136 | 3127 |
3137 | 3128 |
3138 } } // namespace v8::internal | 3129 } } // namespace v8::internal |
OLD | NEW |