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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 inline MarkBit MarkBitFromIndex(uint32_t index) { | 199 inline MarkBit MarkBitFromIndex(uint32_t index) { |
200 MarkBit::CellType mask = 1u << IndexInCell(index); | 200 MarkBit::CellType mask = 1u << IndexInCell(index); |
201 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); | 201 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); |
202 return MarkBit(cell, mask); | 202 return MarkBit(cell, mask); |
203 } | 203 } |
204 | 204 |
205 static inline void Clear(MemoryChunk* chunk); | 205 static inline void Clear(MemoryChunk* chunk); |
206 | 206 |
| 207 static inline void SetAllBits(MemoryChunk* chunk); |
| 208 |
207 static void PrintWord(uint32_t word, uint32_t himask = 0) { | 209 static void PrintWord(uint32_t word, uint32_t himask = 0) { |
208 for (uint32_t mask = 1; mask != 0; mask <<= 1) { | 210 for (uint32_t mask = 1; mask != 0; mask <<= 1) { |
209 if ((mask & himask) != 0) PrintF("["); | 211 if ((mask & himask) != 0) PrintF("["); |
210 PrintF((mask & word) ? "1" : "0"); | 212 PrintF((mask & word) ? "1" : "0"); |
211 if ((mask & himask) != 0) PrintF("]"); | 213 if ((mask & himask) != 0) PrintF("]"); |
212 } | 214 } |
213 } | 215 } |
214 | 216 |
215 class CellPrinter { | 217 class CellPrinter { |
216 public: | 218 public: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 RESCAN_ON_EVACUATION, | 308 RESCAN_ON_EVACUATION, |
307 NEVER_EVACUATE, // May contain immortal immutables. | 309 NEVER_EVACUATE, // May contain immortal immutables. |
308 POPULAR_PAGE, // Slots buffer of this page overflowed on the previous GC. | 310 POPULAR_PAGE, // Slots buffer of this page overflowed on the previous GC. |
309 | 311 |
310 // Large objects can have a progress bar in their page header. These object | 312 // Large objects can have a progress bar in their page header. These object |
311 // are scanned in increments and will be kept black while being scanned. | 313 // are scanned in increments and will be kept black while being scanned. |
312 // Even if the mutator writes to them they will be kept black and a white | 314 // Even if the mutator writes to them they will be kept black and a white |
313 // to grey transition is performed in the value. | 315 // to grey transition is performed in the value. |
314 HAS_PROGRESS_BAR, | 316 HAS_PROGRESS_BAR, |
315 | 317 |
| 318 // A black page has all mark bits set to 1 (black). A black page currently |
| 319 // cannot be iterated because it is not swept. Moreover live bytes are also |
| 320 // not updated. |
| 321 BLACK_PAGE, |
| 322 |
316 // This flag is intended to be used for testing. Works only when both | 323 // This flag is intended to be used for testing. Works only when both |
317 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection | 324 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection |
318 // are set. It forces the page to become an evacuation candidate at next | 325 // are set. It forces the page to become an evacuation candidate at next |
319 // candidates selection cycle. | 326 // candidates selection cycle. |
320 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, | 327 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, |
321 | 328 |
322 // This flag is intended to be used for testing. | 329 // This flag is intended to be used for testing. |
323 NEVER_ALLOCATE_ON_PAGE, | 330 NEVER_ALLOCATE_ON_PAGE, |
324 | 331 |
325 // The memory chunk is already logically freed, however the actual freeing | 332 // The memory chunk is already logically freed, however the actual freeing |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 483 |
477 AtomicValue<ParallelCompactingState>& parallel_compaction_state() { | 484 AtomicValue<ParallelCompactingState>& parallel_compaction_state() { |
478 return parallel_compaction_; | 485 return parallel_compaction_; |
479 } | 486 } |
480 | 487 |
481 // Manage live byte count, i.e., count of bytes in black objects. | 488 // Manage live byte count, i.e., count of bytes in black objects. |
482 inline void ResetLiveBytes(); | 489 inline void ResetLiveBytes(); |
483 inline void IncrementLiveBytes(int by); | 490 inline void IncrementLiveBytes(int by); |
484 | 491 |
485 int LiveBytes() { | 492 int LiveBytes() { |
486 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); | 493 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); |
| 494 DCHECK(!IsFlagSet(BLACK_PAGE) || live_byte_count_ == 0); |
487 return live_byte_count_; | 495 return live_byte_count_; |
488 } | 496 } |
489 | 497 |
490 void SetLiveBytes(int live_bytes) { | 498 void SetLiveBytes(int live_bytes) { |
| 499 if (IsFlagSet(BLACK_PAGE)) return; |
491 DCHECK_GE(live_bytes, 0); | 500 DCHECK_GE(live_bytes, 0); |
492 DCHECK_LE(static_cast<size_t>(live_bytes), size_); | 501 DCHECK_LE(static_cast<size_t>(live_bytes), size_); |
493 live_byte_count_ = live_bytes; | 502 live_byte_count_ = live_bytes; |
494 } | 503 } |
495 | 504 |
496 int write_barrier_counter() { | 505 int write_barrier_counter() { |
497 return static_cast<int>(write_barrier_counter_); | 506 return static_cast<int>(write_barrier_counter_); |
498 } | 507 } |
499 | 508 |
500 void set_write_barrier_counter(int counter) { | 509 void set_write_barrier_counter(int counter) { |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 | 2136 |
2128 // The space's free list. | 2137 // The space's free list. |
2129 FreeList free_list_; | 2138 FreeList free_list_; |
2130 | 2139 |
2131 // Normal allocation information. | 2140 // Normal allocation information. |
2132 AllocationInfo allocation_info_; | 2141 AllocationInfo allocation_info_; |
2133 | 2142 |
2134 // Mutex guarding any concurrent access to the space. | 2143 // Mutex guarding any concurrent access to the space. |
2135 base::Mutex space_mutex_; | 2144 base::Mutex space_mutex_; |
2136 | 2145 |
| 2146 friend class IncrementalMarking; |
2137 friend class MarkCompactCollector; | 2147 friend class MarkCompactCollector; |
2138 friend class PageIterator; | 2148 friend class PageIterator; |
2139 | 2149 |
2140 // Used in cctest. | 2150 // Used in cctest. |
2141 friend class HeapTester; | 2151 friend class HeapTester; |
2142 }; | 2152 }; |
2143 | 2153 |
2144 | 2154 |
2145 class NumberAndSizeInfo BASE_EMBEDDED { | 2155 class NumberAndSizeInfo BASE_EMBEDDED { |
2146 public: | 2156 public: |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 count = 0; | 3028 count = 0; |
3019 } | 3029 } |
3020 // Must be small, since an iteration is used for lookup. | 3030 // Must be small, since an iteration is used for lookup. |
3021 static const int kMaxComments = 64; | 3031 static const int kMaxComments = 64; |
3022 }; | 3032 }; |
3023 #endif | 3033 #endif |
3024 } // namespace internal | 3034 } // namespace internal |
3025 } // namespace v8 | 3035 } // namespace v8 |
3026 | 3036 |
3027 #endif // V8_HEAP_SPACES_H_ | 3037 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |