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/platform/mutex.h" | 10 #include "src/base/platform/mutex.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 POINTERS_TO_HERE_ARE_INTERESTING, | 366 POINTERS_TO_HERE_ARE_INTERESTING, |
367 POINTERS_FROM_HERE_ARE_INTERESTING, | 367 POINTERS_FROM_HERE_ARE_INTERESTING, |
368 SCAN_ON_SCAVENGE, | 368 SCAN_ON_SCAVENGE, |
369 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. | 369 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. |
370 IN_TO_SPACE, // All pages in new space has one of these two set. | 370 IN_TO_SPACE, // All pages in new space has one of these two set. |
371 NEW_SPACE_BELOW_AGE_MARK, | 371 NEW_SPACE_BELOW_AGE_MARK, |
372 CONTAINS_ONLY_DATA, | 372 CONTAINS_ONLY_DATA, |
373 EVACUATION_CANDIDATE, | 373 EVACUATION_CANDIDATE, |
374 RESCAN_ON_EVACUATION, | 374 RESCAN_ON_EVACUATION, |
375 | 375 |
376 // Pages swept precisely can be iterated, hitting only the live objects. | 376 // WAS_SWEPT indicates that marking bits have been cleared by the sweeper, |
377 // Whereas those swept conservatively cannot be iterated over. Both flags | 377 // otherwise marking bits are still intact. |
378 // indicate that marking bits have been cleared by the sweeper, otherwise | 378 WAS_SWEPT, |
379 // marking bits are still intact. | |
380 WAS_SWEPT_PRECISELY, | |
381 WAS_SWEPT_CONSERVATIVELY, | |
382 | 379 |
383 // Large objects can have a progress bar in their page header. These object | 380 // Large objects can have a progress bar in their page header. These object |
384 // are scanned in increments and will be kept black while being scanned. | 381 // are scanned in increments and will be kept black while being scanned. |
385 // Even if the mutator writes to them they will be kept black and a white | 382 // Even if the mutator writes to them they will be kept black and a white |
386 // to grey transition is performed in the value. | 383 // to grey transition is performed in the value. |
387 HAS_PROGRESS_BAR, | 384 HAS_PROGRESS_BAR, |
388 | 385 |
389 // Last flag, keep at bottom. | 386 // Last flag, keep at bottom. |
390 NUM_MEMORY_CHUNK_FLAGS | 387 NUM_MEMORY_CHUNK_FLAGS |
391 }; | 388 }; |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // Page size mask. | 755 // Page size mask. |
759 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; | 756 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; |
760 | 757 |
761 inline void ClearGCFields(); | 758 inline void ClearGCFields(); |
762 | 759 |
763 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk, | 760 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk, |
764 Executability executable, PagedSpace* owner); | 761 Executability executable, PagedSpace* owner); |
765 | 762 |
766 void InitializeAsAnchor(PagedSpace* owner); | 763 void InitializeAsAnchor(PagedSpace* owner); |
767 | 764 |
768 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } | 765 bool WasSwept() { return IsFlagSet(WAS_SWEPT); } |
769 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } | 766 void SetWasSwept() { SetFlag(WAS_SWEPT); } |
770 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } | 767 void ClearWasSwept() { ClearFlag(WAS_SWEPT); } |
771 | |
772 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } | |
773 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } | |
774 | |
775 void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); } | |
776 void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); } | |
777 | 768 |
778 void ResetFreeListStatistics(); | 769 void ResetFreeListStatistics(); |
779 | 770 |
780 #define FRAGMENTATION_STATS_ACCESSORS(type, name) \ | 771 #define FRAGMENTATION_STATS_ACCESSORS(type, name) \ |
781 type name() { return name##_; } \ | 772 type name() { return name##_; } \ |
782 void set_##name(type name) { name##_ = name; } \ | 773 void set_##name(type name) { name##_ = name; } \ |
783 void add_##name(type name) { name##_ += name; } | 774 void add_##name(type name) { name##_ += name; } |
784 | 775 |
785 FRAGMENTATION_STATS_ACCESSORS(intptr_t, non_available_small_blocks) | 776 FRAGMENTATION_STATS_ACCESSORS(intptr_t, non_available_small_blocks) |
786 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_small_free_list) | 777 FRAGMENTATION_STATS_ACCESSORS(intptr_t, available_in_small_free_list) |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 | 1814 |
1824 // Reports statistics for the space | 1815 // Reports statistics for the space |
1825 void ReportStatistics(); | 1816 void ReportStatistics(); |
1826 | 1817 |
1827 // Report code object related statistics | 1818 // Report code object related statistics |
1828 void CollectCodeStatistics(); | 1819 void CollectCodeStatistics(); |
1829 static void ReportCodeStatistics(Isolate* isolate); | 1820 static void ReportCodeStatistics(Isolate* isolate); |
1830 static void ResetCodeStatistics(Isolate* isolate); | 1821 static void ResetCodeStatistics(Isolate* isolate); |
1831 #endif | 1822 #endif |
1832 | 1823 |
1833 bool swept_precisely() { return swept_precisely_; } | |
1834 void set_swept_precisely(bool b) { swept_precisely_ = b; } | |
1835 | |
1836 // Evacuation candidates are swept by evacuator. Needs to return a valid | 1824 // Evacuation candidates are swept by evacuator. Needs to return a valid |
1837 // result before _and_ after evacuation has finished. | 1825 // result before _and_ after evacuation has finished. |
1838 static bool ShouldBeSweptBySweeperThreads(Page* p) { | 1826 static bool ShouldBeSweptBySweeperThreads(Page* p) { |
1839 return !p->IsEvacuationCandidate() && | 1827 return !p->IsEvacuationCandidate() && |
1840 !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && !p->WasSweptPrecisely(); | 1828 !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && !p->WasSwept(); |
1841 } | 1829 } |
1842 | 1830 |
1843 void IncrementUnsweptFreeBytes(intptr_t by) { unswept_free_bytes_ += by; } | 1831 void IncrementUnsweptFreeBytes(intptr_t by) { unswept_free_bytes_ += by; } |
1844 | 1832 |
1845 void IncreaseUnsweptFreeBytes(Page* p) { | 1833 void IncreaseUnsweptFreeBytes(Page* p) { |
1846 DCHECK(ShouldBeSweptBySweeperThreads(p)); | 1834 DCHECK(ShouldBeSweptBySweeperThreads(p)); |
1847 unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); | 1835 unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); |
1848 } | 1836 } |
1849 | 1837 |
1850 void DecrementUnsweptFreeBytes(intptr_t by) { unswept_free_bytes_ -= by; } | 1838 void DecrementUnsweptFreeBytes(intptr_t by) { unswept_free_bytes_ -= by; } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 | 1888 |
1901 // The dummy page that anchors the double linked list of pages. | 1889 // The dummy page that anchors the double linked list of pages. |
1902 Page anchor_; | 1890 Page anchor_; |
1903 | 1891 |
1904 // The space's free list. | 1892 // The space's free list. |
1905 FreeList free_list_; | 1893 FreeList free_list_; |
1906 | 1894 |
1907 // Normal allocation information. | 1895 // Normal allocation information. |
1908 AllocationInfo allocation_info_; | 1896 AllocationInfo allocation_info_; |
1909 | 1897 |
1910 // This space was swept precisely, hence it is iterable. | |
1911 bool swept_precisely_; | |
1912 | |
1913 // The number of free bytes which could be reclaimed by advancing the | 1898 // The number of free bytes which could be reclaimed by advancing the |
1914 // concurrent sweeper threads. This is only an estimation because concurrent | 1899 // concurrent sweeper threads. |
1915 // sweeping is done conservatively. | |
1916 intptr_t unswept_free_bytes_; | 1900 intptr_t unswept_free_bytes_; |
1917 | 1901 |
1918 // The sweeper threads iterate over the list of pointer and data space pages | 1902 // The sweeper threads iterate over the list of pointer and data space pages |
1919 // and sweep these pages concurrently. They will stop sweeping after the | 1903 // and sweep these pages concurrently. They will stop sweeping after the |
1920 // end_of_unswept_pages_ page. | 1904 // end_of_unswept_pages_ page. |
1921 Page* end_of_unswept_pages_; | 1905 Page* end_of_unswept_pages_; |
1922 | 1906 |
1923 // Emergency memory is the memory of a full page for a given space, allocated | 1907 // Emergency memory is the memory of a full page for a given space, allocated |
1924 // conservatively before evacuating a page. If compaction fails due to out | 1908 // conservatively before evacuating a page. If compaction fails due to out |
1925 // of memory error the emergency memory can be used to complete compaction. | 1909 // of memory error the emergency memory can be used to complete compaction. |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 count = 0; | 2872 count = 0; |
2889 } | 2873 } |
2890 // Must be small, since an iteration is used for lookup. | 2874 // Must be small, since an iteration is used for lookup. |
2891 static const int kMaxComments = 64; | 2875 static const int kMaxComments = 64; |
2892 }; | 2876 }; |
2893 #endif | 2877 #endif |
2894 } | 2878 } |
2895 } // namespace v8::internal | 2879 } // namespace v8::internal |
2896 | 2880 |
2897 #endif // V8_HEAP_SPACES_H_ | 2881 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |