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/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 intptr_t SumFreeLists(); | 1736 intptr_t SumFreeLists(); |
1737 bool IsVeryLong(); | 1737 bool IsVeryLong(); |
1738 #endif | 1738 #endif |
1739 | 1739 |
1740 // Used after booting the VM. | 1740 // Used after booting the VM. |
1741 void RepairLists(Heap* heap); | 1741 void RepairLists(Heap* heap); |
1742 | 1742 |
1743 intptr_t EvictFreeListItems(Page* p); | 1743 intptr_t EvictFreeListItems(Page* p); |
1744 bool ContainsPageFreeListItems(Page* p); | 1744 bool ContainsPageFreeListItems(Page* p); |
1745 | 1745 |
1746 FreeListCategory* small_list() { return &small_list_; } | |
1747 FreeListCategory* medium_list() { return &medium_list_; } | |
1748 FreeListCategory* large_list() { return &large_list_; } | |
1749 FreeListCategory* huge_list() { return &huge_list_; } | |
1750 | |
1751 PagedSpace* owner() { return owner_; } | 1746 PagedSpace* owner() { return owner_; } |
1752 intptr_t wasted_bytes() { return wasted_bytes_; } | 1747 intptr_t wasted_bytes() { return wasted_bytes_; } |
1753 base::Mutex* mutex() { return &mutex_; } | 1748 base::Mutex* mutex() { return &mutex_; } |
1754 | 1749 |
1755 private: | 1750 private: |
1756 // The size range of blocks, in bytes. | 1751 // The size range of blocks, in bytes. |
1757 static const int kMinBlockSize = 3 * kPointerSize; | 1752 static const int kMinBlockSize = 3 * kPointerSize; |
1758 static const int kMaxBlockSize = Page::kAllocatableMemory; | 1753 static const int kMaxBlockSize = Page::kAllocatableMemory; |
1759 | 1754 |
1760 static const int kSmallListMin = 0x1f * kPointerSize; | 1755 static const int kSmallListMin = 0x1f * kPointerSize; |
1761 static const int kSmallListMax = 0xff * kPointerSize; | 1756 static const int kSmallListMax = 0xff * kPointerSize; |
1762 static const int kMediumListMax = 0x7ff * kPointerSize; | 1757 static const int kMediumListMax = 0x7ff * kPointerSize; |
1763 static const int kLargeListMax = 0x3fff * kPointerSize; | 1758 static const int kLargeListMax = 0x3fff * kPointerSize; |
1764 static const int kSmallAllocationMax = kSmallListMin; | 1759 static const int kSmallAllocationMax = kSmallListMin; |
1765 static const int kMediumAllocationMax = kSmallListMax; | 1760 static const int kMediumAllocationMax = kSmallListMax; |
1766 static const int kLargeAllocationMax = kMediumListMax; | 1761 static const int kLargeAllocationMax = kMediumListMax; |
1767 | 1762 |
1768 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); | 1763 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); |
| 1764 FreeSpace* FindNodeIn(FreeListCategoryType category, int* node_size); |
| 1765 |
| 1766 FreeListCategory* GetFreeListCategory(FreeListCategoryType category) { |
| 1767 switch (category) { |
| 1768 case kSmall: |
| 1769 return &small_list_; |
| 1770 case kMedium: |
| 1771 return &medium_list_; |
| 1772 case kLarge: |
| 1773 return &large_list_; |
| 1774 case kHuge: |
| 1775 return &huge_list_; |
| 1776 default: |
| 1777 UNREACHABLE(); |
| 1778 } |
| 1779 UNREACHABLE(); |
| 1780 return nullptr; |
| 1781 } |
| 1782 |
1769 | 1783 |
1770 PagedSpace* owner_; | 1784 PagedSpace* owner_; |
1771 Heap* heap_; | 1785 Heap* heap_; |
1772 base::Mutex mutex_; | 1786 base::Mutex mutex_; |
1773 intptr_t wasted_bytes_; | 1787 intptr_t wasted_bytes_; |
1774 FreeListCategory small_list_; | 1788 FreeListCategory small_list_; |
1775 FreeListCategory medium_list_; | 1789 FreeListCategory medium_list_; |
1776 FreeListCategory large_list_; | 1790 FreeListCategory large_list_; |
1777 FreeListCategory huge_list_; | 1791 FreeListCategory huge_list_; |
1778 | 1792 |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 count = 0; | 3009 count = 0; |
2996 } | 3010 } |
2997 // Must be small, since an iteration is used for lookup. | 3011 // Must be small, since an iteration is used for lookup. |
2998 static const int kMaxComments = 64; | 3012 static const int kMaxComments = 64; |
2999 }; | 3013 }; |
3000 #endif | 3014 #endif |
3001 } // namespace internal | 3015 } // namespace internal |
3002 } // namespace v8 | 3016 } // namespace v8 |
3003 | 3017 |
3004 #endif // V8_HEAP_SPACES_H_ | 3018 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |