Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: src/heap/spaces.h

Issue 1420423009: [heap] Black allocation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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. Moreover live bytes are also
321 // not updated.
322 BLACK_PAGE,
323
317 // This flag is intended to be used for testing. Works only when both 324 // This flag is intended to be used for testing. Works only when both
318 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection 325 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection
319 // are set. It forces the page to become an evacuation candidate at next 326 // are set. It forces the page to become an evacuation candidate at next
320 // candidates selection cycle. 327 // candidates selection cycle.
321 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, 328 FORCE_EVACUATION_CANDIDATE_FOR_TESTING,
322 329
323 // This flag is inteded to be used for testing. 330 // This flag is inteded to be used for testing.
324 NEVER_ALLOCATE_ON_PAGE, 331 NEVER_ALLOCATE_ON_PAGE,
325 332
326 // The memory chunk is already logically freed, however the actual freeing 333 // The memory chunk is already logically freed, however the actual freeing
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // because they are marked black). 573 // because they are marked black).
567 void ResetLiveBytes() { 574 void ResetLiveBytes() {
568 if (FLAG_gc_verbose) { 575 if (FLAG_gc_verbose) {
569 PrintF("ResetLiveBytes:%p:%x->0\n", static_cast<void*>(this), 576 PrintF("ResetLiveBytes:%p:%x->0\n", static_cast<void*>(this),
570 live_byte_count_); 577 live_byte_count_);
571 } 578 }
572 live_byte_count_ = 0; 579 live_byte_count_ = 0;
573 } 580 }
574 581
575 void IncrementLiveBytes(int by) { 582 void IncrementLiveBytes(int by) {
583 if (IsFlagSet(BLACK_PAGE)) return;
576 if (FLAG_gc_verbose) { 584 if (FLAG_gc_verbose) {
577 printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", static_cast<void*>(this), 585 printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", static_cast<void*>(this),
578 live_byte_count_, ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by), 586 live_byte_count_, ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by),
579 live_byte_count_ + by); 587 live_byte_count_ + by);
580 } 588 }
581 live_byte_count_ += by; 589 live_byte_count_ += by;
582 DCHECK_GE(live_byte_count_, 0); 590 DCHECK_GE(live_byte_count_, 0);
583 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); 591 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_);
584 } 592 }
585 593
586 int LiveBytes() { 594 int LiveBytes() {
587 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); 595 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_);
596 DCHECK(!IsFlagSet(BLACK_PAGE) || live_byte_count_ == 0);
588 return live_byte_count_; 597 return live_byte_count_;
589 } 598 }
590 599
591 void SetLiveBytes(int live_bytes) { 600 void SetLiveBytes(int live_bytes) {
601 if (IsFlagSet(BLACK_PAGE)) return;
592 DCHECK_GE(live_bytes, 0); 602 DCHECK_GE(live_bytes, 0);
593 DCHECK_LE(static_cast<unsigned>(live_bytes), size_); 603 DCHECK_LE(static_cast<unsigned>(live_bytes), size_);
594 live_byte_count_ = live_bytes; 604 live_byte_count_ = live_bytes;
595 } 605 }
596 606
597 int write_barrier_counter() { 607 int write_barrier_counter() {
598 return static_cast<int>(write_barrier_counter_); 608 return static_cast<int>(write_barrier_counter_);
599 } 609 }
600 610
601 void set_write_barrier_counter(int counter) { 611 void set_write_barrier_counter(int counter) {
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 2184
2175 // The space's free list. 2185 // The space's free list.
2176 FreeList free_list_; 2186 FreeList free_list_;
2177 2187
2178 // Normal allocation information. 2188 // Normal allocation information.
2179 AllocationInfo allocation_info_; 2189 AllocationInfo allocation_info_;
2180 2190
2181 // Mutex guarding any concurrent access to the space. 2191 // Mutex guarding any concurrent access to the space.
2182 base::Mutex space_mutex_; 2192 base::Mutex space_mutex_;
2183 2193
2194 friend class IncrementalMarking;
2184 friend class MarkCompactCollector; 2195 friend class MarkCompactCollector;
2185 friend class PageIterator; 2196 friend class PageIterator;
2186 2197
2187 // Used in cctest. 2198 // Used in cctest.
2188 friend class HeapTester; 2199 friend class HeapTester;
2189 }; 2200 };
2190 2201
2191 2202
2192 class NumberAndSizeInfo BASE_EMBEDDED { 2203 class NumberAndSizeInfo BASE_EMBEDDED {
2193 public: 2204 public:
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 count = 0; 3128 count = 0;
3118 } 3129 }
3119 // Must be small, since an iteration is used for lookup. 3130 // Must be small, since an iteration is used for lookup.
3120 static const int kMaxComments = 64; 3131 static const int kMaxComments = 64;
3121 }; 3132 };
3122 #endif 3133 #endif
3123 } // namespace internal 3134 } // namespace internal
3124 } // namespace v8 3135 } // namespace v8
3125 3136
3126 #endif // V8_HEAP_SPACES_H_ 3137 #endif // V8_HEAP_SPACES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698