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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 // |COMPACTION_WAS_ABORTED|: Indicates that the compaction in this page | 276 // |COMPACTION_WAS_ABORTED|: Indicates that the compaction in this page |
277 // has been aborted and needs special handling by the sweeper. | 277 // has been aborted and needs special handling by the sweeper. |
278 COMPACTION_WAS_ABORTED = 1u << 15, | 278 COMPACTION_WAS_ABORTED = 1u << 15, |
279 | 279 |
280 // |COMPACTION_WAS_ABORTED_FOR_TESTING|: During stress testing evacuation | 280 // |COMPACTION_WAS_ABORTED_FOR_TESTING|: During stress testing evacuation |
281 // on pages is sometimes aborted. The flag is used to avoid repeatedly | 281 // on pages is sometimes aborted. The flag is used to avoid repeatedly |
282 // triggering on the same page. | 282 // triggering on the same page. |
283 COMPACTION_WAS_ABORTED_FOR_TESTING = 1u << 16, | 283 COMPACTION_WAS_ABORTED_FOR_TESTING = 1u << 16, |
284 | 284 |
| 285 // |CANNOT_BE_VERIFIED|: Used for moved pages to indicate that these pages |
| 286 // cannot be verified due to stale pointers in the body. Note that the |
| 287 // objects can still be iterated over, as the size can be correctly |
| 288 // obtained. |
| 289 CANNOT_BE_VERIFIED = 1u << 17, |
| 290 |
285 // |ANCHOR|: Flag is set if page is an anchor. | 291 // |ANCHOR|: Flag is set if page is an anchor. |
286 ANCHOR = 1u << 17, | 292 ANCHOR = 1u << 17, |
287 }; | 293 }; |
288 typedef base::Flags<Flag, uintptr_t> Flags; | 294 typedef base::Flags<Flag, uintptr_t> Flags; |
289 | 295 |
290 static const int kPointersToHereAreInterestingMask = | 296 static const int kPointersToHereAreInterestingMask = |
291 POINTERS_TO_HERE_ARE_INTERESTING; | 297 POINTERS_TO_HERE_ARE_INTERESTING; |
292 | 298 |
293 static const int kPointersFromHereAreInterestingMask = | 299 static const int kPointersFromHereAreInterestingMask = |
294 POINTERS_FROM_HERE_ARE_INTERESTING; | 300 POINTERS_FROM_HERE_ARE_INTERESTING; |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 iterator end() { return range_.end(); } | 1891 iterator end() { return range_.end(); } |
1886 | 1892 |
1887 private: | 1893 private: |
1888 PageRange range_; | 1894 PageRange range_; |
1889 }; | 1895 }; |
1890 | 1896 |
1891 class PagedSpace : public Space { | 1897 class PagedSpace : public Space { |
1892 public: | 1898 public: |
1893 typedef PageIterator iterator; | 1899 typedef PageIterator iterator; |
1894 | 1900 |
| 1901 // Reuse a page for allocation only if it has at least {kPageReuseThreshold} |
| 1902 // memory available in its freelist. |
| 1903 static const size_t kPageReuseThreshold = 4 * KB; |
1895 static const intptr_t kCompactionMemoryWanted = 500 * KB; | 1904 static const intptr_t kCompactionMemoryWanted = 500 * KB; |
1896 | 1905 |
1897 // Creates a space with an id. | 1906 // Creates a space with an id. |
1898 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); | 1907 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); |
1899 | 1908 |
1900 ~PagedSpace() override { TearDown(); } | 1909 ~PagedSpace() override { TearDown(); } |
1901 | 1910 |
1902 // Set up the space using the given address range of virtual memory (from | 1911 // Set up the space using the given address range of virtual memory (from |
1903 // the memory allocator's initial chunk) if possible. If the block of | 1912 // the memory allocator's initial chunk) if possible. If the block of |
1904 // addresses is not big enough to contain a single page-aligned page, a | 1913 // addresses is not big enough to contain a single page-aligned page, a |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 | 2106 |
2098 iterator begin() { return iterator(anchor_.next_page()); } | 2107 iterator begin() { return iterator(anchor_.next_page()); } |
2099 iterator end() { return iterator(&anchor_); } | 2108 iterator end() { return iterator(&anchor_); } |
2100 | 2109 |
2101 // Shrink immortal immovable pages of the space to be exactly the size needed | 2110 // Shrink immortal immovable pages of the space to be exactly the size needed |
2102 // using the high water mark. | 2111 // using the high water mark. |
2103 void ShrinkImmortalImmovablePages(); | 2112 void ShrinkImmortalImmovablePages(); |
2104 | 2113 |
2105 std::unique_ptr<ObjectIterator> GetObjectIterator() override; | 2114 std::unique_ptr<ObjectIterator> GetObjectIterator() override; |
2106 | 2115 |
| 2116 // Removes a page from the space. |
| 2117 Page* RemovePageSafe(); |
| 2118 void AddPage(Page* page); |
| 2119 |
2107 protected: | 2120 protected: |
2108 // PagedSpaces that should be included in snapshots have different, i.e., | 2121 // PagedSpaces that should be included in snapshots have different, i.e., |
2109 // smaller, initial pages. | 2122 // smaller, initial pages. |
2110 virtual bool snapshotable() { return true; } | 2123 virtual bool snapshotable() { return true; } |
2111 | 2124 |
2112 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2125 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2113 | 2126 |
2114 // Cleans up the space, frees all pages in this space except those belonging | 2127 // Cleans up the space, frees all pages in this space except those belonging |
2115 // to the initial chunk, uncommits addresses in the initial chunk. | 2128 // to the initial chunk, uncommits addresses in the initial chunk. |
2116 void TearDown(); | 2129 void TearDown(); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 PageIterator old_iterator_; | 2929 PageIterator old_iterator_; |
2917 PageIterator code_iterator_; | 2930 PageIterator code_iterator_; |
2918 PageIterator map_iterator_; | 2931 PageIterator map_iterator_; |
2919 LargePageIterator lo_iterator_; | 2932 LargePageIterator lo_iterator_; |
2920 }; | 2933 }; |
2921 | 2934 |
2922 } // namespace internal | 2935 } // namespace internal |
2923 } // namespace v8 | 2936 } // namespace v8 |
2924 | 2937 |
2925 #endif // V8_HEAP_SPACES_H_ | 2938 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |