Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
| 6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 671 // Used by the incremental marker to keep track of the scanning progress in | 671 // Used by the incremental marker to keep track of the scanning progress in |
| 672 // large objects that have a progress bar and are scanned in increments. | 672 // large objects that have a progress bar and are scanned in increments. |
| 673 int progress_bar_; | 673 int progress_bar_; |
| 674 // Assuming the initial allocation on a page is sequential, | 674 // Assuming the initial allocation on a page is sequential, |
| 675 // count highest number of bytes ever allocated on the page. | 675 // count highest number of bytes ever allocated on the page. |
| 676 int high_water_mark_; | 676 int high_water_mark_; |
| 677 | 677 |
| 678 base::AtomicWord parallel_sweeping_; | 678 base::AtomicWord parallel_sweeping_; |
| 679 | 679 |
| 680 // PagedSpace free-list statistics. | 680 // PagedSpace free-list statistics. |
| 681 intptr_t available_in_small_free_list_; | 681 int available_in_small_free_list_; |
|
Hannes Payer (out of office)
2015/05/27 08:49:30
Why int? What about size_t?
ulan
2015/05/27 11:33:20
All free list counters in other places are signed.
Hannes Payer (out of office)
2015/05/27 12:41:34
yeah...
| |
| 682 intptr_t available_in_medium_free_list_; | 682 int available_in_medium_free_list_; |
| 683 intptr_t available_in_large_free_list_; | 683 int available_in_large_free_list_; |
| 684 intptr_t available_in_huge_free_list_; | 684 int available_in_huge_free_list_; |
| 685 intptr_t non_available_small_blocks_; | 685 int non_available_small_blocks_; |
| 686 | 686 |
| 687 static MemoryChunk* Initialize(Heap* heap, Address base, size_t size, | 687 static MemoryChunk* Initialize(Heap* heap, Address base, size_t size, |
| 688 Address area_start, Address area_end, | 688 Address area_start, Address area_end, |
| 689 Executability executable, Space* owner); | 689 Executability executable, Space* owner); |
| 690 | 690 |
| 691 private: | 691 private: |
| 692 // next_chunk_ holds a pointer of type MemoryChunk | 692 // next_chunk_ holds a pointer of type MemoryChunk |
| 693 base::AtomicWord next_chunk_; | 693 base::AtomicWord next_chunk_; |
| 694 // prev_chunk_ holds a pointer of type MemoryChunk | 694 // prev_chunk_ holds a pointer of type MemoryChunk |
| 695 base::AtomicWord prev_chunk_; | 695 base::AtomicWord prev_chunk_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 Executability executable, PagedSpace* owner); | 769 Executability executable, PagedSpace* owner); |
| 770 | 770 |
| 771 void InitializeAsAnchor(PagedSpace* owner); | 771 void InitializeAsAnchor(PagedSpace* owner); |
| 772 | 772 |
| 773 bool WasSwept() { return IsFlagSet(WAS_SWEPT); } | 773 bool WasSwept() { return IsFlagSet(WAS_SWEPT); } |
| 774 void SetWasSwept() { SetFlag(WAS_SWEPT); } | 774 void SetWasSwept() { SetFlag(WAS_SWEPT); } |
| 775 void ClearWasSwept() { ClearFlag(WAS_SWEPT); } | 775 void ClearWasSwept() { ClearFlag(WAS_SWEPT); } |
| 776 | 776 |
| 777 void ResetFreeListStatistics(); | 777 void ResetFreeListStatistics(); |
| 778 | 778 |
| 779 int LiveBytesFromFreeList() { | |
| 780 return area_size() - non_available_small_blocks_ - | |
| 781 available_in_small_free_list_ - available_in_medium_free_list_ - | |
| 782 available_in_large_free_list_ - available_in_huge_free_list_; | |
| 783 } | |
| 784 | |
| 779 #define FRAGMENTATION_STATS_ACCESSORS(type, name) \ | 785 #define FRAGMENTATION_STATS_ACCESSORS(type, name) \ |
| 780 type name() { return name##_; } \ | 786 type name() { return name##_; } \ |
| 781 void set_##name(type name) { name##_ = name; } \ | 787 void set_##name(type name) { name##_ = name; } \ |
| 782 void add_##name(type name) { name##_ += name; } | 788 void add_##name(type name) { name##_ += name; } |
| 783 | 789 |
| 784 FRAGMENTATION_STATS_ACCESSORS(intptr_t, non_available_small_blocks) | 790 FRAGMENTATION_STATS_ACCESSORS(int, non_available_small_blocks) |
| 785 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_small_free_list) | 791 FRAGMENTATION_STATS_ACCESSORS(int, available_in_small_free_list) |
| 786 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_medium_free_list) | 792 FRAGMENTATION_STATS_ACCESSORS(int, available_in_medium_free_list) |
| 787 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_large_free_list) | 793 FRAGMENTATION_STATS_ACCESSORS(int, available_in_large_free_list) |
| 788 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_huge_free_list) | 794 FRAGMENTATION_STATS_ACCESSORS(int, available_in_huge_free_list) |
| 789 | 795 |
| 790 #undef FRAGMENTATION_STATS_ACCESSORS | 796 #undef FRAGMENTATION_STATS_ACCESSORS |
| 791 | 797 |
| 792 #ifdef DEBUG | 798 #ifdef DEBUG |
| 793 void Print(); | 799 void Print(); |
| 794 #endif // DEBUG | 800 #endif // DEBUG |
| 795 | 801 |
| 796 friend class MemoryAllocator; | 802 friend class MemoryAllocator; |
| 797 }; | 803 }; |
| 798 | 804 |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1693 // Total amount of memory committed for this space. For paged | 1699 // Total amount of memory committed for this space. For paged |
| 1694 // spaces this equals the capacity. | 1700 // spaces this equals the capacity. |
| 1695 intptr_t CommittedMemory() override { return Capacity(); } | 1701 intptr_t CommittedMemory() override { return Capacity(); } |
| 1696 | 1702 |
| 1697 // The maximum amount of memory ever committed for this space. | 1703 // The maximum amount of memory ever committed for this space. |
| 1698 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } | 1704 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } |
| 1699 | 1705 |
| 1700 // Approximate amount of physical memory committed for this space. | 1706 // Approximate amount of physical memory committed for this space. |
| 1701 size_t CommittedPhysicalMemory() override; | 1707 size_t CommittedPhysicalMemory() override; |
| 1702 | 1708 |
| 1703 struct SizeStats { | |
| 1704 intptr_t Total() { | |
| 1705 return small_size_ + medium_size_ + large_size_ + huge_size_; | |
| 1706 } | |
| 1707 | |
| 1708 intptr_t small_size_; | |
| 1709 intptr_t medium_size_; | |
| 1710 intptr_t large_size_; | |
| 1711 intptr_t huge_size_; | |
| 1712 }; | |
| 1713 | |
| 1714 void ObtainFreeListStatistics(Page* p, SizeStats* sizes); | |
| 1715 void ResetFreeListStatistics(); | 1709 void ResetFreeListStatistics(); |
| 1716 | 1710 |
| 1717 // Sets the capacity, the available space and the wasted space to zero. | 1711 // Sets the capacity, the available space and the wasted space to zero. |
| 1718 // The stats are rebuilt during sweeping by adding each page to the | 1712 // The stats are rebuilt during sweeping by adding each page to the |
| 1719 // capacity and the size when it is encountered. As free spaces are | 1713 // capacity and the size when it is encountered. As free spaces are |
| 1720 // discovered during the sweeping they are subtracted from the size and added | 1714 // discovered during the sweeping they are subtracted from the size and added |
| 1721 // to the available and wasted totals. | 1715 // to the available and wasted totals. |
| 1722 void ClearStats() { | 1716 void ClearStats() { |
| 1723 accounting_stats_.ClearSizeWaste(); | 1717 accounting_stats_.ClearSizeWaste(); |
| 1724 ResetFreeListStatistics(); | 1718 ResetFreeListStatistics(); |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2890 count = 0; | 2884 count = 0; |
| 2891 } | 2885 } |
| 2892 // Must be small, since an iteration is used for lookup. | 2886 // Must be small, since an iteration is used for lookup. |
| 2893 static const int kMaxComments = 64; | 2887 static const int kMaxComments = 64; |
| 2894 }; | 2888 }; |
| 2895 #endif | 2889 #endif |
| 2896 } | 2890 } |
| 2897 } // namespace v8::internal | 2891 } // namespace v8::internal |
| 2898 | 2892 |
| 2899 #endif // V8_HEAP_SPACES_H_ | 2893 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |