OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 // --- | 5 // --- |
6 // Author: Sainbayar Sukhbaatar | 6 // Author: Sainbayar Sukhbaatar |
7 // Dai Mikurube | 7 // Dai Mikurube |
8 // | 8 // |
9 | 9 |
10 #include "deep-heap-profile.h" | 10 #include "deep-heap-profile.h" |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 memory_residence_info_getter, first_address, last_address); | 657 memory_residence_info_getter, first_address, last_address); |
658 | 658 |
659 // TODO(dmikurube): Stop double-counting pagemap. | 659 // TODO(dmikurube): Stop double-counting pagemap. |
660 // Counts unhooked memory regions in /proc/<pid>/maps. | 660 // Counts unhooked memory regions in /proc/<pid>/maps. |
661 if (MemoryRegionMap::IsRecordingLocked()) { | 661 if (MemoryRegionMap::IsRecordingLocked()) { |
662 // It assumes that every mmap'ed region is included in one maps line. | 662 // It assumes that every mmap'ed region is included in one maps line. |
663 uint64 cursor = first_address; | 663 uint64 cursor = first_address; |
664 bool first = true; | 664 bool first = true; |
665 | 665 |
666 do { | 666 do { |
| 667 Bucket* bucket = NULL; |
| 668 DeepBucket* deep_bucket = NULL; |
667 if (!first) { | 669 if (!first) { |
668 cursor = mmap_iter->end_addr; | |
669 ++mmap_iter; | |
670 // Don't break here even if mmap_iter == EndRegionLocked(). | |
671 } | |
672 first = false; | |
673 | |
674 DeepBucket* deep_bucket = NULL; | |
675 if (mmap_iter != MemoryRegionMap::EndRegionLocked()) { | |
676 size_t committed = deep_profile->memory_residence_info_getter_-> | 670 size_t committed = deep_profile->memory_residence_info_getter_-> |
677 CommittedSize(mmap_iter->start_addr, mmap_iter->end_addr - 1); | 671 CommittedSize(mmap_iter->start_addr, mmap_iter->end_addr - 1); |
678 // TODO(dmikurube): Store a reference to the bucket in region. | 672 // TODO(dmikurube): Store a reference to the bucket in region. |
679 Bucket* bucket = MemoryRegionMap::GetBucket( | 673 Bucket* bucket = MemoryRegionMap::GetBucket( |
680 mmap_iter->call_stack_depth, mmap_iter->call_stack); | 674 mmap_iter->call_stack_depth, mmap_iter->call_stack); |
| 675 DeepBucket* deep_bucket = NULL; |
681 if (bucket != NULL) { | 676 if (bucket != NULL) { |
682 deep_bucket = deep_profile->deep_table_.Lookup( | 677 deep_bucket = deep_profile->deep_table_.Lookup( |
683 bucket, | 678 bucket, |
684 #if defined(TYPE_PROFILING) | 679 #if defined(TYPE_PROFILING) |
685 NULL, // No type information for mmap'ed memory regions. | 680 NULL, // No type information for mmap'ed memory regions. |
686 #endif | 681 #endif |
687 /* is_mmap */ true); | 682 /* is_mmap */ true); |
688 } | 683 } |
689 | 684 |
690 if (deep_bucket != NULL) | 685 if (deep_bucket != NULL) |
691 deep_bucket->committed_size += committed; | 686 deep_bucket->committed_size += committed; |
692 profiled_mmap_.AddToVirtualBytes( | 687 profiled_mmap_.AddToVirtualBytes( |
693 mmap_iter->end_addr - mmap_iter->start_addr); | 688 mmap_iter->end_addr - mmap_iter->start_addr); |
694 profiled_mmap_.AddToCommittedBytes(committed); | 689 profiled_mmap_.AddToCommittedBytes(committed); |
| 690 |
| 691 cursor = mmap_iter->end_addr; |
| 692 ++mmap_iter; |
| 693 // Don't break here even if mmap_iter == EndRegionLocked(). |
695 } | 694 } |
| 695 first = false; |
696 | 696 |
697 uint64 last_address_of_unhooked; | 697 uint64 last_address_of_unhooked; |
698 // If the next mmap entry is away from the current maps line. | 698 // If the next mmap entry is away from the current maps line. |
699 if (mmap_iter == MemoryRegionMap::EndRegionLocked() || | 699 if (mmap_iter == MemoryRegionMap::EndRegionLocked() || |
700 mmap_iter->start_addr > last_address) { | 700 mmap_iter->start_addr > last_address) { |
701 last_address_of_unhooked = last_address; | 701 last_address_of_unhooked = last_address; |
702 } else { | 702 } else { |
703 last_address_of_unhooked = mmap_iter->start_addr - 1; | 703 last_address_of_unhooked = mmap_iter->start_addr - 1; |
704 } | 704 } |
705 | 705 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 } | 884 } |
885 | 885 |
886 DeepHeapProfile::~DeepHeapProfile() { | 886 DeepHeapProfile::~DeepHeapProfile() { |
887 } | 887 } |
888 | 888 |
889 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { | 889 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { |
890 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); | 890 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); |
891 } | 891 } |
892 | 892 |
893 #endif // DEEP_HEAP_PROFILE | 893 #endif // DEEP_HEAP_PROFILE |
OLD | NEW |