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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 } | 196 } |
197 | 197 |
198 inline MarkBit MarkBitFromIndex(uint32_t index) { | 198 inline MarkBit MarkBitFromIndex(uint32_t index) { |
199 MarkBit::CellType mask = 1u << IndexInCell(index); | 199 MarkBit::CellType mask = 1u << IndexInCell(index); |
200 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); | 200 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); |
201 return MarkBit(cell, mask); | 201 return MarkBit(cell, mask); |
202 } | 202 } |
203 | 203 |
204 static inline void Clear(MemoryChunk* chunk); | 204 static inline void Clear(MemoryChunk* chunk); |
205 | 205 |
206 static inline void SetAllBits(MemoryChunk* chunk); | |
207 | |
206 static void PrintWord(uint32_t word, uint32_t himask = 0) { | 208 static void PrintWord(uint32_t word, uint32_t himask = 0) { |
207 for (uint32_t mask = 1; mask != 0; mask <<= 1) { | 209 for (uint32_t mask = 1; mask != 0; mask <<= 1) { |
208 if ((mask & himask) != 0) PrintF("["); | 210 if ((mask & himask) != 0) PrintF("["); |
209 PrintF((mask & word) ? "1" : "0"); | 211 PrintF((mask & word) ? "1" : "0"); |
210 if ((mask & himask) != 0) PrintF("]"); | 212 if ((mask & himask) != 0) PrintF("]"); |
211 } | 213 } |
212 } | 214 } |
213 | 215 |
214 class CellPrinter { | 216 class CellPrinter { |
215 public: | 217 public: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 RESCAN_ON_EVACUATION, | 309 RESCAN_ON_EVACUATION, |
308 NEVER_EVACUATE, // May contain immortal immutables. | 310 NEVER_EVACUATE, // May contain immortal immutables. |
309 POPULAR_PAGE, // Slots buffer of this page overflowed on the previous GC. | 311 POPULAR_PAGE, // Slots buffer of this page overflowed on the previous GC. |
310 | 312 |
311 // Large objects can have a progress bar in their page header. These object | 313 // Large objects can have a progress bar in their page header. These object |
312 // are scanned in increments and will be kept black while being scanned. | 314 // are scanned in increments and will be kept black while being scanned. |
313 // Even if the mutator writes to them they will be kept black and a white | 315 // Even if the mutator writes to them they will be kept black and a white |
314 // to grey transition is performed in the value. | 316 // to grey transition is performed in the value. |
315 HAS_PROGRESS_BAR, | 317 HAS_PROGRESS_BAR, |
316 | 318 |
319 // A black page has all mark bits set to 1 (black). A black page currently | |
320 // cannot be iterated because it is not swept. | |
Michael Lippautz
2016/02/04 17:59:51
Add: Live bytes are also not updated on those page
Hannes Payer (out of office)
2016/02/06 08:50:16
Done.
| |
321 BLACK_PAGE, | |
322 | |
317 // 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 |
318 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection | 324 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection |
319 // 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 |
320 // candidates selection cycle. | 326 // candidates selection cycle. |
321 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, | 327 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, |
322 | 328 |
323 // This flag is inteded to be used for testing. | 329 // This flag is inteded to be used for testing. |
324 NEVER_ALLOCATE_ON_PAGE, | 330 NEVER_ALLOCATE_ON_PAGE, |
325 | 331 |
326 // The memory chunk is already logically freed, however the actual freeing | 332 // The memory chunk is already logically freed, however the actual freeing |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 // because they are marked black). | 572 // because they are marked black). |
567 void ResetLiveBytes() { | 573 void ResetLiveBytes() { |
568 if (FLAG_gc_verbose) { | 574 if (FLAG_gc_verbose) { |
569 PrintF("ResetLiveBytes:%p:%x->0\n", static_cast<void*>(this), | 575 PrintF("ResetLiveBytes:%p:%x->0\n", static_cast<void*>(this), |
570 live_byte_count_); | 576 live_byte_count_); |
571 } | 577 } |
572 live_byte_count_ = 0; | 578 live_byte_count_ = 0; |
573 } | 579 } |
574 | 580 |
575 void IncrementLiveBytes(int by) { | 581 void IncrementLiveBytes(int by) { |
582 if (IsFlagSet(BLACK_PAGE)) return; | |
576 if (FLAG_gc_verbose) { | 583 if (FLAG_gc_verbose) { |
577 printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", static_cast<void*>(this), | 584 printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", static_cast<void*>(this), |
578 live_byte_count_, ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by), | 585 live_byte_count_, ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by), |
579 live_byte_count_ + by); | 586 live_byte_count_ + by); |
580 } | 587 } |
581 live_byte_count_ += by; | 588 live_byte_count_ += by; |
582 DCHECK_GE(live_byte_count_, 0); | 589 DCHECK_GE(live_byte_count_, 0); |
583 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); | 590 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); |
584 } | 591 } |
585 | 592 |
586 int LiveBytes() { | 593 int LiveBytes() { |
587 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); | 594 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); |
595 DCHECK(!IsFlagSet(BLACK_PAGE) || live_byte_count_ == 0); | |
588 return live_byte_count_; | 596 return live_byte_count_; |
589 } | 597 } |
590 | 598 |
591 void SetLiveBytes(int live_bytes) { | 599 void SetLiveBytes(int live_bytes) { |
600 if (IsFlagSet(BLACK_PAGE)) return; | |
592 DCHECK_GE(live_bytes, 0); | 601 DCHECK_GE(live_bytes, 0); |
593 DCHECK_LE(static_cast<unsigned>(live_bytes), size_); | 602 DCHECK_LE(static_cast<unsigned>(live_bytes), size_); |
594 live_byte_count_ = live_bytes; | 603 live_byte_count_ = live_bytes; |
595 } | 604 } |
596 | 605 |
597 int write_barrier_counter() { | 606 int write_barrier_counter() { |
598 return static_cast<int>(write_barrier_counter_); | 607 return static_cast<int>(write_barrier_counter_); |
599 } | 608 } |
600 | 609 |
601 void set_write_barrier_counter(int counter) { | 610 void set_write_barrier_counter(int counter) { |
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2174 | 2183 |
2175 // The space's free list. | 2184 // The space's free list. |
2176 FreeList free_list_; | 2185 FreeList free_list_; |
2177 | 2186 |
2178 // Normal allocation information. | 2187 // Normal allocation information. |
2179 AllocationInfo allocation_info_; | 2188 AllocationInfo allocation_info_; |
2180 | 2189 |
2181 // Mutex guarding any concurrent access to the space. | 2190 // Mutex guarding any concurrent access to the space. |
2182 base::Mutex space_mutex_; | 2191 base::Mutex space_mutex_; |
2183 | 2192 |
2193 friend class IncrementalMarking; | |
2184 friend class MarkCompactCollector; | 2194 friend class MarkCompactCollector; |
2185 friend class PageIterator; | 2195 friend class PageIterator; |
2186 | 2196 |
2187 // Used in cctest. | 2197 // Used in cctest. |
2188 friend class HeapTester; | 2198 friend class HeapTester; |
2189 }; | 2199 }; |
2190 | 2200 |
2191 | 2201 |
2192 class NumberAndSizeInfo BASE_EMBEDDED { | 2202 class NumberAndSizeInfo BASE_EMBEDDED { |
2193 public: | 2203 public: |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3117 count = 0; | 3127 count = 0; |
3118 } | 3128 } |
3119 // Must be small, since an iteration is used for lookup. | 3129 // Must be small, since an iteration is used for lookup. |
3120 static const int kMaxComments = 64; | 3130 static const int kMaxComments = 64; |
3121 }; | 3131 }; |
3122 #endif | 3132 #endif |
3123 } // namespace internal | 3133 } // namespace internal |
3124 } // namespace v8 | 3134 } // namespace v8 |
3125 | 3135 |
3126 #endif // V8_HEAP_SPACES_H_ | 3136 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |