| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 inline MarkBit MarkBitFromIndex(uint32_t index) { | 196 inline MarkBit MarkBitFromIndex(uint32_t index) { |
| 197 MarkBit::CellType mask = 1u << IndexInCell(index); | 197 MarkBit::CellType mask = 1u << IndexInCell(index); |
| 198 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); | 198 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); |
| 199 return MarkBit(cell, mask); | 199 return MarkBit(cell, mask); |
| 200 } | 200 } |
| 201 | 201 |
| 202 static inline void Clear(MemoryChunk* chunk); | 202 static inline void Clear(MemoryChunk* chunk); |
| 203 | 203 |
| 204 static inline void SetAllBits(MemoryChunk* chunk); |
| 205 |
| 204 static void PrintWord(uint32_t word, uint32_t himask = 0) { | 206 static void PrintWord(uint32_t word, uint32_t himask = 0) { |
| 205 for (uint32_t mask = 1; mask != 0; mask <<= 1) { | 207 for (uint32_t mask = 1; mask != 0; mask <<= 1) { |
| 206 if ((mask & himask) != 0) PrintF("["); | 208 if ((mask & himask) != 0) PrintF("["); |
| 207 PrintF((mask & word) ? "1" : "0"); | 209 PrintF((mask & word) ? "1" : "0"); |
| 208 if ((mask & himask) != 0) PrintF("]"); | 210 if ((mask & himask) != 0) PrintF("]"); |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 | 213 |
| 212 class CellPrinter { | 214 class CellPrinter { |
| 213 public: | 215 public: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 EVACUATION_CANDIDATE, | 304 EVACUATION_CANDIDATE, |
| 303 RESCAN_ON_EVACUATION, | 305 RESCAN_ON_EVACUATION, |
| 304 NEVER_EVACUATE, // May contain immortal immutables. | 306 NEVER_EVACUATE, // May contain immortal immutables. |
| 305 | 307 |
| 306 // Large objects can have a progress bar in their page header. These object | 308 // Large objects can have a progress bar in their page header. These object |
| 307 // are scanned in increments and will be kept black while being scanned. | 309 // are scanned in increments and will be kept black while being scanned. |
| 308 // Even if the mutator writes to them they will be kept black and a white | 310 // Even if the mutator writes to them they will be kept black and a white |
| 309 // to grey transition is performed in the value. | 311 // to grey transition is performed in the value. |
| 310 HAS_PROGRESS_BAR, | 312 HAS_PROGRESS_BAR, |
| 311 | 313 |
| 314 // A black page has all mark bits set to 1 (black). A black page currently |
| 315 // cannot be iterated because it is not swept. Moreover live bytes are also |
| 316 // not updated. |
| 317 BLACK_PAGE, |
| 318 |
| 312 // This flag is intended to be used for testing. Works only when both | 319 // This flag is intended to be used for testing. Works only when both |
| 313 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection | 320 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection |
| 314 // are set. It forces the page to become an evacuation candidate at next | 321 // are set. It forces the page to become an evacuation candidate at next |
| 315 // candidates selection cycle. | 322 // candidates selection cycle. |
| 316 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, | 323 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, |
| 317 | 324 |
| 318 // This flag is intended to be used for testing. | 325 // This flag is intended to be used for testing. |
| 319 NEVER_ALLOCATE_ON_PAGE, | 326 NEVER_ALLOCATE_ON_PAGE, |
| 320 | 327 |
| 321 // The memory chunk is already logically freed, however the actual freeing | 328 // The memory chunk is already logically freed, however the actual freeing |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 461 |
| 455 AtomicValue<ConcurrentSweepingState>& concurrent_sweeping_state() { | 462 AtomicValue<ConcurrentSweepingState>& concurrent_sweeping_state() { |
| 456 return concurrent_sweeping_; | 463 return concurrent_sweeping_; |
| 457 } | 464 } |
| 458 | 465 |
| 459 // Manage live byte count, i.e., count of bytes in black objects. | 466 // Manage live byte count, i.e., count of bytes in black objects. |
| 460 inline void ResetLiveBytes(); | 467 inline void ResetLiveBytes(); |
| 461 inline void IncrementLiveBytes(int by); | 468 inline void IncrementLiveBytes(int by); |
| 462 | 469 |
| 463 int LiveBytes() { | 470 int LiveBytes() { |
| 464 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); | 471 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); |
| 472 DCHECK(!IsFlagSet(BLACK_PAGE) || live_byte_count_ == 0); |
| 465 return live_byte_count_; | 473 return live_byte_count_; |
| 466 } | 474 } |
| 467 | 475 |
| 468 void SetLiveBytes(int live_bytes) { | 476 void SetLiveBytes(int live_bytes) { |
| 477 if (IsFlagSet(BLACK_PAGE)) return; |
| 469 DCHECK_GE(live_bytes, 0); | 478 DCHECK_GE(live_bytes, 0); |
| 470 DCHECK_LE(static_cast<size_t>(live_bytes), size_); | 479 DCHECK_LE(static_cast<size_t>(live_bytes), size_); |
| 471 live_byte_count_ = live_bytes; | 480 live_byte_count_ = live_bytes; |
| 472 } | 481 } |
| 473 | 482 |
| 474 int write_barrier_counter() { | 483 int write_barrier_counter() { |
| 475 return static_cast<int>(write_barrier_counter_); | 484 return static_cast<int>(write_barrier_counter_); |
| 476 } | 485 } |
| 477 | 486 |
| 478 void set_write_barrier_counter(int counter) { | 487 void set_write_barrier_counter(int counter) { |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 | 2144 |
| 2136 // The space's free list. | 2145 // The space's free list. |
| 2137 FreeList free_list_; | 2146 FreeList free_list_; |
| 2138 | 2147 |
| 2139 // Normal allocation information. | 2148 // Normal allocation information. |
| 2140 AllocationInfo allocation_info_; | 2149 AllocationInfo allocation_info_; |
| 2141 | 2150 |
| 2142 // Mutex guarding any concurrent access to the space. | 2151 // Mutex guarding any concurrent access to the space. |
| 2143 base::Mutex space_mutex_; | 2152 base::Mutex space_mutex_; |
| 2144 | 2153 |
| 2154 friend class IncrementalMarking; |
| 2145 friend class MarkCompactCollector; | 2155 friend class MarkCompactCollector; |
| 2146 friend class PageIterator; | 2156 friend class PageIterator; |
| 2147 | 2157 |
| 2148 // Used in cctest. | 2158 // Used in cctest. |
| 2149 friend class HeapTester; | 2159 friend class HeapTester; |
| 2150 }; | 2160 }; |
| 2151 | 2161 |
| 2152 | 2162 |
| 2153 class NumberAndSizeInfo BASE_EMBEDDED { | 2163 class NumberAndSizeInfo BASE_EMBEDDED { |
| 2154 public: | 2164 public: |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 count = 0; | 3029 count = 0; |
| 3020 } | 3030 } |
| 3021 // Must be small, since an iteration is used for lookup. | 3031 // Must be small, since an iteration is used for lookup. |
| 3022 static const int kMaxComments = 64; | 3032 static const int kMaxComments = 64; |
| 3023 }; | 3033 }; |
| 3024 #endif | 3034 #endif |
| 3025 } // namespace internal | 3035 } // namespace internal |
| 3026 } // namespace v8 | 3036 } // namespace v8 |
| 3027 | 3037 |
| 3028 #endif // V8_HEAP_SPACES_H_ | 3038 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |