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