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 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 | 2123 |
2124 // If sweeping is still in progress try to sweep unswept pages. If that is | 2124 // If sweeping is still in progress try to sweep unswept pages. If that is |
2125 // not successful, wait for the sweeper threads and re-try free-list | 2125 // not successful, wait for the sweeper threads and re-try free-list |
2126 // allocation. | 2126 // allocation. |
2127 MUST_USE_RESULT virtual HeapObject* SweepAndRetryAllocation( | 2127 MUST_USE_RESULT virtual HeapObject* SweepAndRetryAllocation( |
2128 int size_in_bytes); | 2128 int size_in_bytes); |
2129 | 2129 |
2130 // Slow path of AllocateRaw. This function is space-dependent. | 2130 // Slow path of AllocateRaw. This function is space-dependent. |
2131 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); | 2131 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
2132 | 2132 |
| 2133 virtual bool ShouldForceOOM() { return force_oom_; } |
| 2134 |
| 2135 void SetForcedOOM(bool value) { force_oom_ = value; } |
| 2136 |
2133 int area_size_; | 2137 int area_size_; |
2134 | 2138 |
2135 // Accounting information for this space. | 2139 // Accounting information for this space. |
2136 AllocationStats accounting_stats_; | 2140 AllocationStats accounting_stats_; |
2137 | 2141 |
2138 // The dummy page that anchors the double linked list of pages. | 2142 // The dummy page that anchors the double linked list of pages. |
2139 Page anchor_; | 2143 Page anchor_; |
2140 | 2144 |
2141 // The space's free list. | 2145 // The space's free list. |
2142 FreeList free_list_; | 2146 FreeList free_list_; |
2143 | 2147 |
2144 // Normal allocation information. | 2148 // Normal allocation information. |
2145 AllocationInfo allocation_info_; | 2149 AllocationInfo allocation_info_; |
2146 | 2150 |
2147 // The sweeper threads iterate over the list of pointer and data space pages | 2151 // The sweeper threads iterate over the list of pointer and data space pages |
2148 // and sweep these pages concurrently. They will stop sweeping after the | 2152 // and sweep these pages concurrently. They will stop sweeping after the |
2149 // end_of_unswept_pages_ page. | 2153 // end_of_unswept_pages_ page. |
2150 Page* end_of_unswept_pages_; | 2154 Page* end_of_unswept_pages_; |
2151 | 2155 |
2152 // Mutex guarding any concurrent access to the space. | 2156 // Mutex guarding any concurrent access to the space. |
2153 base::Mutex space_mutex_; | 2157 base::Mutex space_mutex_; |
2154 | 2158 |
| 2159 bool force_oom_; |
| 2160 |
| 2161 friend class CompactionSpace; |
2155 friend class MarkCompactCollector; | 2162 friend class MarkCompactCollector; |
2156 friend class PageIterator; | 2163 friend class PageIterator; |
2157 | 2164 |
2158 // Used in cctest. | 2165 // Used in cctest. |
2159 friend class HeapTester; | 2166 friend class HeapTester; |
2160 }; | 2167 }; |
2161 | 2168 |
2162 | 2169 |
2163 class NumberAndSizeInfo BASE_EMBEDDED { | 2170 class NumberAndSizeInfo BASE_EMBEDDED { |
2164 public: | 2171 public: |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 bool is_local() override { return true; } | 2922 bool is_local() override { return true; } |
2916 | 2923 |
2917 void RefillFreeList() override; | 2924 void RefillFreeList() override; |
2918 | 2925 |
2919 protected: | 2926 protected: |
2920 // The space is temporary and not included in any snapshots. | 2927 // The space is temporary and not included in any snapshots. |
2921 bool snapshotable() override { return false; } | 2928 bool snapshotable() override { return false; } |
2922 | 2929 |
2923 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( | 2930 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( |
2924 int size_in_bytes) override; | 2931 int size_in_bytes) override; |
| 2932 |
| 2933 bool ShouldForceOOM() override; |
2925 }; | 2934 }; |
2926 | 2935 |
2927 | 2936 |
2928 // A collection of |CompactionSpace|s used by a single compaction task. | 2937 // A collection of |CompactionSpace|s used by a single compaction task. |
2929 class CompactionSpaceCollection : public Malloced { | 2938 class CompactionSpaceCollection : public Malloced { |
2930 public: | 2939 public: |
2931 explicit CompactionSpaceCollection(Heap* heap) | 2940 explicit CompactionSpaceCollection(Heap* heap) |
2932 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), | 2941 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), |
2933 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), | 2942 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), |
2934 duration_(0.0), | 2943 duration_(0.0), |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 count = 0; | 3164 count = 0; |
3156 } | 3165 } |
3157 // Must be small, since an iteration is used for lookup. | 3166 // Must be small, since an iteration is used for lookup. |
3158 static const int kMaxComments = 64; | 3167 static const int kMaxComments = 64; |
3159 }; | 3168 }; |
3160 #endif | 3169 #endif |
3161 } // namespace internal | 3170 } // namespace internal |
3162 } // namespace v8 | 3171 } // namespace v8 |
3163 | 3172 |
3164 #endif // V8_HEAP_SPACES_H_ | 3173 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |