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 <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 STATIC_ASSERT(Page::kPageSize % kRegionSize == 0); | 1090 STATIC_ASSERT(Page::kPageSize % kRegionSize == 0); |
1091 | 1091 |
1092 Address starts_[kSize]; | 1092 Address starts_[kSize]; |
1093 }; | 1093 }; |
1094 | 1094 |
1095 | 1095 |
1096 // ---------------------------------------------------------------------------- | 1096 // ---------------------------------------------------------------------------- |
1097 // A space acquires chunks of memory from the operating system. The memory | 1097 // A space acquires chunks of memory from the operating system. The memory |
1098 // allocator allocates and deallocates pages for the paged heap spaces and large | 1098 // allocator allocates and deallocates pages for the paged heap spaces and large |
1099 // pages for large object space. | 1099 // pages for large object space. |
1100 class MemoryAllocator { | 1100 class V8_EXPORT_PRIVATE MemoryAllocator { |
1101 public: | 1101 public: |
1102 // Unmapper takes care of concurrently unmapping and uncommitting memory | 1102 // Unmapper takes care of concurrently unmapping and uncommitting memory |
1103 // chunks. | 1103 // chunks. |
1104 class Unmapper { | 1104 class Unmapper { |
1105 public: | 1105 public: |
1106 class UnmapFreeMemoryTask; | 1106 class UnmapFreeMemoryTask; |
1107 | 1107 |
1108 explicit Unmapper(MemoryAllocator* allocator) | 1108 explicit Unmapper(MemoryAllocator* allocator) |
1109 : allocator_(allocator), | 1109 : allocator_(allocator), |
1110 pending_unmapping_tasks_semaphore_(0), | 1110 pending_unmapping_tasks_semaphore_(0), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 friend class MemoryAllocator; | 1185 friend class MemoryAllocator; |
1186 }; | 1186 }; |
1187 | 1187 |
1188 enum AllocationMode { | 1188 enum AllocationMode { |
1189 kRegular, | 1189 kRegular, |
1190 kPooled, | 1190 kPooled, |
1191 }; | 1191 }; |
1192 | 1192 |
1193 enum FreeMode { | 1193 enum FreeMode { |
1194 kFull, | 1194 kFull, |
| 1195 kAlreadyPooled, |
1195 kPreFreeAndQueue, | 1196 kPreFreeAndQueue, |
1196 kPooledAndQueue, | 1197 kPooledAndQueue, |
1197 }; | 1198 }; |
1198 | 1199 |
1199 static size_t CodePageGuardStartOffset(); | 1200 static size_t CodePageGuardStartOffset(); |
1200 | 1201 |
1201 static size_t CodePageGuardSize(); | 1202 static size_t CodePageGuardSize(); |
1202 | 1203 |
1203 static size_t CodePageAreaStartOffset(); | 1204 static size_t CodePageAreaStartOffset(); |
1204 | 1205 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 // 11-31 words (tiny): The tiny blocks are only used for allocation, when | 1642 // 11-31 words (tiny): The tiny blocks are only used for allocation, when |
1642 // categories >= small do not have entries anymore. | 1643 // categories >= small do not have entries anymore. |
1643 // 32-255 words (small): Used for allocating free space between 1-31 words in | 1644 // 32-255 words (small): Used for allocating free space between 1-31 words in |
1644 // size. | 1645 // size. |
1645 // 256-2047 words (medium): Used for allocating free space between 32-255 words | 1646 // 256-2047 words (medium): Used for allocating free space between 32-255 words |
1646 // in size. | 1647 // in size. |
1647 // 1048-16383 words (large): Used for allocating free space between 256-2047 | 1648 // 1048-16383 words (large): Used for allocating free space between 256-2047 |
1648 // words in size. | 1649 // words in size. |
1649 // At least 16384 words (huge): This list is for objects of 2048 words or | 1650 // At least 16384 words (huge): This list is for objects of 2048 words or |
1650 // larger. Empty pages are also added to this list. | 1651 // larger. Empty pages are also added to this list. |
1651 class FreeList { | 1652 class V8_EXPORT_PRIVATE FreeList { |
1652 public: | 1653 public: |
1653 // This method returns how much memory can be allocated after freeing | 1654 // This method returns how much memory can be allocated after freeing |
1654 // maximum_freed memory. | 1655 // maximum_freed memory. |
1655 static inline size_t GuaranteedAllocatable(size_t maximum_freed) { | 1656 static inline size_t GuaranteedAllocatable(size_t maximum_freed) { |
1656 if (maximum_freed <= kTiniestListMax) { | 1657 if (maximum_freed <= kTiniestListMax) { |
1657 // Since we are not iterating over all list entries, we cannot guarantee | 1658 // Since we are not iterating over all list entries, we cannot guarantee |
1658 // that we can find the maximum freed block in that free list. | 1659 // that we can find the maximum freed block in that free list. |
1659 return 0; | 1660 return 0; |
1660 } else if (maximum_freed <= kTinyListMax) { | 1661 } else if (maximum_freed <= kTinyListMax) { |
1661 return kTinyAllocationMax; | 1662 return kTinyAllocationMax; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 | 1879 |
1879 private: | 1880 private: |
1880 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); | 1881 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); |
1881 | 1882 |
1882 void Close(); | 1883 void Close(); |
1883 | 1884 |
1884 Heap* heap_; | 1885 Heap* heap_; |
1885 AllocationInfo allocation_info_; | 1886 AllocationInfo allocation_info_; |
1886 }; | 1887 }; |
1887 | 1888 |
1888 class PagedSpace : public Space { | 1889 class V8_EXPORT_PRIVATE PagedSpace : public Space { |
1889 public: | 1890 public: |
1890 typedef PageIterator iterator; | 1891 typedef PageIterator iterator; |
1891 | 1892 |
1892 static const intptr_t kCompactionMemoryWanted = 500 * KB; | 1893 static const intptr_t kCompactionMemoryWanted = 500 * KB; |
1893 | 1894 |
1894 // Creates a space with an id. | 1895 // Creates a space with an id. |
1895 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); | 1896 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); |
1896 | 1897 |
1897 ~PagedSpace() override { TearDown(); } | 1898 ~PagedSpace() override { TearDown(); } |
1898 | 1899 |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 PageIterator old_iterator_; | 2898 PageIterator old_iterator_; |
2898 PageIterator code_iterator_; | 2899 PageIterator code_iterator_; |
2899 PageIterator map_iterator_; | 2900 PageIterator map_iterator_; |
2900 LargePageIterator lo_iterator_; | 2901 LargePageIterator lo_iterator_; |
2901 }; | 2902 }; |
2902 | 2903 |
2903 } // namespace internal | 2904 } // namespace internal |
2904 } // namespace v8 | 2905 } // namespace v8 |
2905 | 2906 |
2906 #endif // V8_HEAP_SPACES_H_ | 2907 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |