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_SPACES_H_ | 5 #ifndef V8_SPACES_H_ |
6 #define V8_SPACES_H_ | 6 #define V8_SPACES_H_ |
7 | 7 |
8 #include "allocation.h" | 8 #include "allocation.h" |
9 #include "hashmap.h" | 9 #include "hashmap.h" |
10 #include "list.h" | 10 #include "list.h" |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 SetTopAndLimit(NULL, NULL); | 1824 SetTopAndLimit(NULL, NULL); |
1825 } | 1825 } |
1826 | 1826 |
1827 void Allocate(int bytes) { | 1827 void Allocate(int bytes) { |
1828 accounting_stats_.AllocateBytes(bytes); | 1828 accounting_stats_.AllocateBytes(bytes); |
1829 } | 1829 } |
1830 | 1830 |
1831 void IncreaseCapacity(int size); | 1831 void IncreaseCapacity(int size); |
1832 | 1832 |
1833 // Releases an unused page and shrinks the space. | 1833 // Releases an unused page and shrinks the space. |
1834 void ReleasePage(Page* page, bool unlink); | 1834 void ReleasePage(Page* page); |
1835 | 1835 |
1836 // The dummy page that anchors the linked list of pages. | 1836 // The dummy page that anchors the linked list of pages. |
1837 Page* anchor() { return &anchor_; } | 1837 Page* anchor() { return &anchor_; } |
1838 | 1838 |
1839 #ifdef VERIFY_HEAP | 1839 #ifdef VERIFY_HEAP |
1840 // Verify integrity of this space. | 1840 // Verify integrity of this space. |
1841 virtual void Verify(ObjectVisitor* visitor); | 1841 virtual void Verify(ObjectVisitor* visitor); |
1842 | 1842 |
1843 // Overridden by subclasses to verify space-specific object | 1843 // Overridden by subclasses to verify space-specific object |
1844 // properties (e.g., only maps or free-list nodes are in map space). | 1844 // properties (e.g., only maps or free-list nodes are in map space). |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 | 1884 |
1885 void DecreaseUnsweptFreeBytes(Page* p) { | 1885 void DecreaseUnsweptFreeBytes(Page* p) { |
1886 ASSERT(ShouldBeSweptBySweeperThreads(p)); | 1886 ASSERT(ShouldBeSweptBySweeperThreads(p)); |
1887 unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); | 1887 unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); |
1888 } | 1888 } |
1889 | 1889 |
1890 void ResetUnsweptFreeBytes() { | 1890 void ResetUnsweptFreeBytes() { |
1891 unswept_free_bytes_ = 0; | 1891 unswept_free_bytes_ = 0; |
1892 } | 1892 } |
1893 | 1893 |
| 1894 // This function tries to steal size_in_bytes memory from the sweeper threads |
| 1895 // free-lists. If it does not succeed stealing enough memory, it will wait |
| 1896 // for the sweeper threads to finish sweeping. |
| 1897 // It returns true when sweeping is completed and false otherwise. |
| 1898 bool EnsureSweeperProgress(intptr_t size_in_bytes); |
| 1899 |
| 1900 void set_end_of_unswept_pages(Page* page) { |
| 1901 end_of_unswept_pages_ = page; |
| 1902 } |
| 1903 |
| 1904 Page* end_of_unswept_pages() { |
| 1905 return end_of_unswept_pages_; |
| 1906 } |
| 1907 |
1894 Page* FirstPage() { return anchor_.next_page(); } | 1908 Page* FirstPage() { return anchor_.next_page(); } |
1895 Page* LastPage() { return anchor_.prev_page(); } | 1909 Page* LastPage() { return anchor_.prev_page(); } |
1896 | 1910 |
1897 void EvictEvacuationCandidatesFromFreeLists(); | 1911 void EvictEvacuationCandidatesFromFreeLists(); |
1898 | 1912 |
1899 bool CanExpand(); | 1913 bool CanExpand(); |
1900 | 1914 |
1901 // Returns the number of total pages in this space. | 1915 // Returns the number of total pages in this space. |
1902 int CountTotalPages(); | 1916 int CountTotalPages(); |
1903 | 1917 |
(...skipping 24 matching lines...) Expand all Loading... |
1928 // Normal allocation information. | 1942 // Normal allocation information. |
1929 AllocationInfo allocation_info_; | 1943 AllocationInfo allocation_info_; |
1930 | 1944 |
1931 bool was_swept_conservatively_; | 1945 bool was_swept_conservatively_; |
1932 | 1946 |
1933 // The number of free bytes which could be reclaimed by advancing the | 1947 // The number of free bytes which could be reclaimed by advancing the |
1934 // concurrent sweeper threads. This is only an estimation because concurrent | 1948 // concurrent sweeper threads. This is only an estimation because concurrent |
1935 // sweeping is done conservatively. | 1949 // sweeping is done conservatively. |
1936 intptr_t unswept_free_bytes_; | 1950 intptr_t unswept_free_bytes_; |
1937 | 1951 |
| 1952 // The sweeper threads iterate over the list of pointer and data space pages |
| 1953 // and sweep these pages concurrently. They will stop sweeping after the |
| 1954 // end_of_unswept_pages_ page. |
| 1955 Page* end_of_unswept_pages_; |
| 1956 |
1938 // Expands the space by allocating a fixed number of pages. Returns false if | 1957 // Expands the space by allocating a fixed number of pages. Returns false if |
1939 // it cannot allocate requested number of pages from OS, or if the hard heap | 1958 // it cannot allocate requested number of pages from OS, or if the hard heap |
1940 // size limit has been hit. | 1959 // size limit has been hit. |
1941 bool Expand(); | 1960 bool Expand(); |
1942 | 1961 |
1943 // Generic fast case allocation function that tries linear allocation at the | 1962 // Generic fast case allocation function that tries linear allocation at the |
1944 // address denoted by top in allocation_info_. | 1963 // address denoted by top in allocation_info_. |
1945 inline HeapObject* AllocateLinearly(int size_in_bytes); | 1964 inline HeapObject* AllocateLinearly(int size_in_bytes); |
1946 | 1965 |
1947 // Slow path of AllocateRaw. This function is space-dependent. | 1966 // Slow path of AllocateRaw. This function is space-dependent. |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2937 } | 2956 } |
2938 // Must be small, since an iteration is used for lookup. | 2957 // Must be small, since an iteration is used for lookup. |
2939 static const int kMaxComments = 64; | 2958 static const int kMaxComments = 64; |
2940 }; | 2959 }; |
2941 #endif | 2960 #endif |
2942 | 2961 |
2943 | 2962 |
2944 } } // namespace v8::internal | 2963 } } // namespace v8::internal |
2945 | 2964 |
2946 #endif // V8_SPACES_H_ | 2965 #endif // V8_SPACES_H_ |
OLD | NEW |