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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 59373003: AllocationProfiler: introduce allocation_profiler flag in V8 api. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 unsigned int size, 477 unsigned int size,
478 bool accessed) { 478 bool accessed) {
479 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); 479 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy());
480 HashMap::Entry* entry = entries_map_.Lookup(addr, ComputePointerHash(addr), 480 HashMap::Entry* entry = entries_map_.Lookup(addr, ComputePointerHash(addr),
481 true); 481 true);
482 if (entry->value != NULL) { 482 if (entry->value != NULL) {
483 int entry_index = 483 int entry_index =
484 static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 484 static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
485 EntryInfo& entry_info = entries_.at(entry_index); 485 EntryInfo& entry_info = entries_.at(entry_index);
486 entry_info.accessed = accessed; 486 entry_info.accessed = accessed;
487 if (FLAG_heap_profiler_trace_objects) { 487 if (FLAG_heap_profiler_trace_objects && entry_info.size != size) {
488 PrintF("Update object size : %p with old size %d and new size %d\n", 488 PrintF("Update object size : %p with old size %d and new size %d\n",
489 addr, 489 addr,
490 entry_info.size, 490 entry_info.size,
491 size); 491 size);
492 } 492 }
493 entry_info.size = size; 493 entry_info.size = size;
494 return entry_info.id; 494 return entry_info.id;
495 } 495 }
496 entry->value = reinterpret_cast<void*>(entries_.length()); 496 entry->value = reinterpret_cast<void*>(entries_.length());
497 SnapshotObjectId id = next_id_; 497 SnapshotObjectId id = next_id_;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 } 611 }
612 if (FLAG_heap_profiler_trace_objects) { 612 if (FLAG_heap_profiler_trace_objects) {
613 PrintF("\nBegin HeapObjectsMap::FindUntrackedObjects. %d entries in map.\n", 613 PrintF("\nBegin HeapObjectsMap::FindUntrackedObjects. %d entries in map.\n",
614 entries_map_.occupancy()); 614 entries_map_.occupancy());
615 heap_objects.Sort(comparator); 615 heap_objects.Sort(comparator);
616 int last_printed_object = -1; 616 int last_printed_object = -1;
617 bool print_next_object = false; 617 bool print_next_object = false;
618 for (int i = 0; i < heap_objects.length(); ++i) { 618 for (int i = 0; i < heap_objects.length(); ++i) {
619 const HeapObjectInfo& object_info = heap_objects[i]; 619 const HeapObjectInfo& object_info = heap_objects[i];
620 if (!object_info.IsValid()) { 620 if (!object_info.IsValid()) {
621 ++untracked;
622 if (last_printed_object != i - 1) { 621 if (last_printed_object != i - 1) {
623 if (i > 0) { 622 if (i > 0) {
624 PrintF("%d objects were skipped\n", i - 1 - last_printed_object); 623 PrintF("%d objects were skipped\n", i - 1 - last_printed_object);
625 heap_objects[i - 1].Print(); 624 heap_objects[i - 1].Print();
626 } 625 }
627 } 626 }
628 object_info.Print(); 627 object_info.Print();
629 last_printed_object = i; 628 last_printed_object = i;
630 print_next_object = true; 629 print_next_object = true;
631 } else if (print_next_object) { 630 } else if (print_next_object) {
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 writer_->AddString("\"<dummy>\""); 3025 writer_->AddString("\"<dummy>\"");
3027 for (int i = 1; i < sorted_strings.length(); ++i) { 3026 for (int i = 1; i < sorted_strings.length(); ++i) {
3028 writer_->AddCharacter(','); 3027 writer_->AddCharacter(',');
3029 SerializeString(sorted_strings[i]); 3028 SerializeString(sorted_strings[i]);
3030 if (writer_->aborted()) return; 3029 if (writer_->aborted()) return;
3031 } 3030 }
3032 } 3031 }
3033 3032
3034 3033
3035 } } // namespace v8::internal 3034 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698