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

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

Issue 10110001: Push heap stats as HeapStatsUpdate struct instead of raw array of uint32_t values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fields of HeapStatsUpdate struct were commented. Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 FindOrAddEntry(obj->address(), obj->Size()); 1396 FindOrAddEntry(obj->address(), obj->Size());
1397 } 1397 }
1398 RemoveDeadEntries(); 1398 RemoveDeadEntries();
1399 } 1399 }
1400 1400
1401 1401
1402 void HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) { 1402 void HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) {
1403 UpdateHeapObjectsMap(); 1403 UpdateHeapObjectsMap();
1404 time_intervals_.Add(TimeInterval(next_id_)); 1404 time_intervals_.Add(TimeInterval(next_id_));
1405 int prefered_chunk_size = stream->GetChunkSize(); 1405 int prefered_chunk_size = stream->GetChunkSize();
1406 List<uint32_t> stats_buffer; 1406 List<v8::HeapStatsUpdate> stats_buffer;
1407 ASSERT(!entries_.is_empty()); 1407 ASSERT(!entries_.is_empty());
1408 EntryInfo* entry_info = &entries_.first(); 1408 EntryInfo* entry_info = &entries_.first();
1409 EntryInfo* end_entry_info = &entries_.last() + 1; 1409 EntryInfo* end_entry_info = &entries_.last() + 1;
1410 for (int time_interval_index = 0; 1410 for (int time_interval_index = 0;
1411 time_interval_index < time_intervals_.length(); 1411 time_interval_index < time_intervals_.length();
1412 ++time_interval_index) { 1412 ++time_interval_index) {
1413 TimeInterval& time_interval = time_intervals_[time_interval_index]; 1413 TimeInterval& time_interval = time_intervals_[time_interval_index];
1414 SnapshotObjectId time_interval_id = time_interval.id; 1414 SnapshotObjectId time_interval_id = time_interval.id;
1415 uint32_t entries_size = 0; 1415 uint32_t entries_size = 0;
1416 EntryInfo* start_entry_info = entry_info; 1416 EntryInfo* start_entry_info = entry_info;
1417 while (entry_info < end_entry_info && entry_info->id < time_interval_id) { 1417 while (entry_info < end_entry_info && entry_info->id < time_interval_id) {
1418 entries_size += entry_info->size; 1418 entries_size += entry_info->size;
1419 ++entry_info; 1419 ++entry_info;
1420 } 1420 }
1421 uint32_t entries_count = 1421 uint32_t entries_count =
1422 static_cast<uint32_t>(entry_info - start_entry_info); 1422 static_cast<uint32_t>(entry_info - start_entry_info);
1423 if (time_interval.count != entries_count || 1423 if (time_interval.count != entries_count ||
1424 time_interval.size != entries_size) { 1424 time_interval.size != entries_size) {
1425 stats_buffer.Add(time_interval_index); 1425 stats_buffer.Add(v8::HeapStatsUpdate(
1426 stats_buffer.Add(time_interval.count = entries_count); 1426 time_interval_index,
1427 stats_buffer.Add(time_interval.size = entries_size); 1427 time_interval.count = entries_count,
1428 time_interval.size = entries_size));
1428 if (stats_buffer.length() >= prefered_chunk_size) { 1429 if (stats_buffer.length() >= prefered_chunk_size) {
1429 OutputStream::WriteResult result = stream->WriteUint32Chunk( 1430 OutputStream::WriteResult result = stream->WriteHeapStatsChunk(
1430 &stats_buffer.first(), stats_buffer.length()); 1431 &stats_buffer.first(), stats_buffer.length());
1431 if (result == OutputStream::kAbort) return; 1432 if (result == OutputStream::kAbort) return;
1432 stats_buffer.Clear(); 1433 stats_buffer.Clear();
1433 } 1434 }
1434 } 1435 }
1435 } 1436 }
1436 ASSERT(entry_info == end_entry_info); 1437 ASSERT(entry_info == end_entry_info);
1437 if (!stats_buffer.is_empty()) { 1438 if (!stats_buffer.is_empty()) {
1438 OutputStream::WriteResult result = 1439 OutputStream::WriteResult result = stream->WriteHeapStatsChunk(
1439 stream->WriteUint32Chunk(&stats_buffer.first(), stats_buffer.length()); 1440 &stats_buffer.first(), stats_buffer.length());
1440 if (result == OutputStream::kAbort) return; 1441 if (result == OutputStream::kAbort) return;
1441 } 1442 }
1442 stream->EndOfStream(); 1443 stream->EndOfStream();
1443 } 1444 }
1444 1445
1445 1446
1446 void HeapObjectsMap::RemoveDeadEntries() { 1447 void HeapObjectsMap::RemoveDeadEntries() {
1447 ASSERT(entries_.length() > 0 && 1448 ASSERT(entries_.length() > 0 &&
1448 entries_.at(0).id == 0 && 1449 entries_.at(0).id == 0 &&
1449 entries_.at(0).addr == NULL); 1450 entries_.at(0).addr == NULL);
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3893 3894
3894 3895
3895 void HeapSnapshotJSONSerializer::SortHashMap( 3896 void HeapSnapshotJSONSerializer::SortHashMap(
3896 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3897 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3897 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3898 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3898 sorted_entries->Add(p); 3899 sorted_entries->Add(p);
3899 sorted_entries->Sort(SortUsingEntryValue); 3900 sorted_entries->Sort(SortUsingEntryValue);
3900 } 3901 }
3901 3902
3902 } } // namespace v8::internal 3903 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698