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 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 HeapIterator iterator; | 1350 HeapIterator iterator; |
1351 for (HeapObject* obj = iterator.next(); | 1351 for (HeapObject* obj = iterator.next(); |
1352 obj != NULL; | 1352 obj != NULL; |
1353 obj = iterator.next()) { | 1353 obj = iterator.next()) { |
1354 FindOrAddEntry(obj->address(), obj->Size()); | 1354 FindOrAddEntry(obj->address(), obj->Size()); |
1355 } | 1355 } |
1356 RemoveDeadEntries(); | 1356 RemoveDeadEntries(); |
1357 } | 1357 } |
1358 | 1358 |
1359 | 1359 |
1360 void HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) { | 1360 SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) { |
1361 UpdateHeapObjectsMap(); | 1361 UpdateHeapObjectsMap(); |
1362 time_intervals_.Add(TimeInterval(next_id_)); | 1362 time_intervals_.Add(TimeInterval(next_id_)); |
1363 int prefered_chunk_size = stream->GetChunkSize(); | 1363 int prefered_chunk_size = stream->GetChunkSize(); |
1364 List<v8::HeapStatsUpdate> stats_buffer; | 1364 List<v8::HeapStatsUpdate> stats_buffer; |
1365 ASSERT(!entries_.is_empty()); | 1365 ASSERT(!entries_.is_empty()); |
1366 EntryInfo* entry_info = &entries_.first(); | 1366 EntryInfo* entry_info = &entries_.first(); |
1367 EntryInfo* end_entry_info = &entries_.last() + 1; | 1367 EntryInfo* end_entry_info = &entries_.last() + 1; |
1368 for (int time_interval_index = 0; | 1368 for (int time_interval_index = 0; |
1369 time_interval_index < time_intervals_.length(); | 1369 time_interval_index < time_intervals_.length(); |
1370 ++time_interval_index) { | 1370 ++time_interval_index) { |
1371 TimeInterval& time_interval = time_intervals_[time_interval_index]; | 1371 TimeInterval& time_interval = time_intervals_[time_interval_index]; |
1372 SnapshotObjectId time_interval_id = time_interval.id; | 1372 SnapshotObjectId time_interval_id = time_interval.id; |
1373 uint32_t entries_size = 0; | 1373 uint32_t entries_size = 0; |
1374 EntryInfo* start_entry_info = entry_info; | 1374 EntryInfo* start_entry_info = entry_info; |
1375 while (entry_info < end_entry_info && entry_info->id < time_interval_id) { | 1375 while (entry_info < end_entry_info && entry_info->id < time_interval_id) { |
1376 entries_size += entry_info->size; | 1376 entries_size += entry_info->size; |
1377 ++entry_info; | 1377 ++entry_info; |
1378 } | 1378 } |
1379 uint32_t entries_count = | 1379 uint32_t entries_count = |
1380 static_cast<uint32_t>(entry_info - start_entry_info); | 1380 static_cast<uint32_t>(entry_info - start_entry_info); |
1381 if (time_interval.count != entries_count || | 1381 if (time_interval.count != entries_count || |
1382 time_interval.size != entries_size) { | 1382 time_interval.size != entries_size) { |
1383 stats_buffer.Add(v8::HeapStatsUpdate( | 1383 stats_buffer.Add(v8::HeapStatsUpdate( |
1384 time_interval_index, | 1384 time_interval_index, |
1385 time_interval.count = entries_count, | 1385 time_interval.count = entries_count, |
1386 time_interval.size = entries_size)); | 1386 time_interval.size = entries_size)); |
1387 if (stats_buffer.length() >= prefered_chunk_size) { | 1387 if (stats_buffer.length() >= prefered_chunk_size) { |
1388 OutputStream::WriteResult result = stream->WriteHeapStatsChunk( | 1388 OutputStream::WriteResult result = stream->WriteHeapStatsChunk( |
1389 &stats_buffer.first(), stats_buffer.length()); | 1389 &stats_buffer.first(), stats_buffer.length()); |
1390 if (result == OutputStream::kAbort) return; | 1390 if (result == OutputStream::kAbort) return last_assigned_id(); |
1391 stats_buffer.Clear(); | 1391 stats_buffer.Clear(); |
1392 } | 1392 } |
1393 } | 1393 } |
1394 } | 1394 } |
1395 ASSERT(entry_info == end_entry_info); | 1395 ASSERT(entry_info == end_entry_info); |
1396 if (!stats_buffer.is_empty()) { | 1396 if (!stats_buffer.is_empty()) { |
1397 OutputStream::WriteResult result = stream->WriteHeapStatsChunk( | 1397 OutputStream::WriteResult result = stream->WriteHeapStatsChunk( |
1398 &stats_buffer.first(), stats_buffer.length()); | 1398 &stats_buffer.first(), stats_buffer.length()); |
1399 if (result == OutputStream::kAbort) return; | 1399 if (result == OutputStream::kAbort) return last_assigned_id(); |
1400 } | 1400 } |
1401 stream->EndOfStream(); | 1401 stream->EndOfStream(); |
| 1402 return last_assigned_id(); |
1402 } | 1403 } |
1403 | 1404 |
1404 | 1405 |
1405 void HeapObjectsMap::RemoveDeadEntries() { | 1406 void HeapObjectsMap::RemoveDeadEntries() { |
1406 ASSERT(entries_.length() > 0 && | 1407 ASSERT(entries_.length() > 0 && |
1407 entries_.at(0).id == 0 && | 1408 entries_.at(0).id == 0 && |
1408 entries_.at(0).addr == NULL); | 1409 entries_.at(0).addr == NULL); |
1409 int first_free_entry = 1; | 1410 int first_free_entry = 1; |
1410 for (int i = 1; i < entries_.length(); ++i) { | 1411 for (int i = 1; i < entries_.length(); ++i) { |
1411 EntryInfo& entry_info = entries_.at(i); | 1412 EntryInfo& entry_info = entries_.at(i); |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3523 | 3524 |
3524 | 3525 |
3525 void HeapSnapshotJSONSerializer::SortHashMap( | 3526 void HeapSnapshotJSONSerializer::SortHashMap( |
3526 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3527 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3527 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3528 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3528 sorted_entries->Add(p); | 3529 sorted_entries->Add(p); |
3529 sorted_entries->Sort(SortUsingEntryValue); | 3530 sorted_entries->Sort(SortUsingEntryValue); |
3530 } | 3531 } |
3531 | 3532 |
3532 } } // namespace v8::internal | 3533 } } // namespace v8::internal |
OLD | NEW |