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 <list> | 8 #include <list> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 HAS_PROGRESS_BAR, | 242 HAS_PROGRESS_BAR, |
243 | 243 |
244 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted | 244 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted |
245 // from new to old space during evacuation. | 245 // from new to old space during evacuation. |
246 PAGE_NEW_OLD_PROMOTION, | 246 PAGE_NEW_OLD_PROMOTION, |
247 | 247 |
248 // |PAGE_NEW_NEW_PROMOTION|: A page tagged with this flag has been moved | 248 // |PAGE_NEW_NEW_PROMOTION|: A page tagged with this flag has been moved |
249 // within the new space during evacuation. | 249 // within the new space during evacuation. |
250 PAGE_NEW_NEW_PROMOTION, | 250 PAGE_NEW_NEW_PROMOTION, |
251 | 251 |
| 252 // A black page has all mark bits set to 1 (black). A black page currently |
| 253 // cannot be iterated because it is not swept. Moreover live bytes are also |
| 254 // not updated. |
| 255 BLACK_PAGE, |
| 256 |
252 // This flag is intended to be used for testing. Works only when both | 257 // This flag is intended to be used for testing. Works only when both |
253 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection | 258 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection |
254 // are set. It forces the page to become an evacuation candidate at next | 259 // are set. It forces the page to become an evacuation candidate at next |
255 // candidates selection cycle. | 260 // candidates selection cycle. |
256 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, | 261 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, |
257 | 262 |
258 // This flag is intended to be used for testing. | 263 // This flag is intended to be used for testing. |
259 NEVER_ALLOCATE_ON_PAGE, | 264 NEVER_ALLOCATE_ON_PAGE, |
260 | 265 |
261 // The memory chunk is already logically freed, however the actual freeing | 266 // The memory chunk is already logically freed, however the actual freeing |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 base::AtomicValue<ConcurrentSweepingState>& concurrent_sweeping_state() { | 421 base::AtomicValue<ConcurrentSweepingState>& concurrent_sweeping_state() { |
417 return concurrent_sweeping_; | 422 return concurrent_sweeping_; |
418 } | 423 } |
419 | 424 |
420 // Manage live byte count, i.e., count of bytes in black objects. | 425 // Manage live byte count, i.e., count of bytes in black objects. |
421 inline void ResetLiveBytes(); | 426 inline void ResetLiveBytes(); |
422 inline void IncrementLiveBytes(int by); | 427 inline void IncrementLiveBytes(int by); |
423 | 428 |
424 int LiveBytes() { | 429 int LiveBytes() { |
425 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); | 430 DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); |
| 431 DCHECK(!IsFlagSet(BLACK_PAGE) || live_byte_count_ == 0); |
426 return live_byte_count_; | 432 return live_byte_count_; |
427 } | 433 } |
428 | 434 |
429 void SetLiveBytes(int live_bytes) { | 435 void SetLiveBytes(int live_bytes) { |
| 436 if (IsFlagSet(BLACK_PAGE)) return; |
430 DCHECK_GE(live_bytes, 0); | 437 DCHECK_GE(live_bytes, 0); |
431 DCHECK_LE(static_cast<size_t>(live_bytes), size_); | 438 DCHECK_LE(static_cast<size_t>(live_bytes), size_); |
432 live_byte_count_ = live_bytes; | 439 live_byte_count_ = live_bytes; |
433 } | 440 } |
434 | 441 |
435 int write_barrier_counter() { | 442 int write_barrier_counter() { |
436 return static_cast<int>(write_barrier_counter_); | 443 return static_cast<int>(write_barrier_counter_); |
437 } | 444 } |
438 | 445 |
439 void set_write_barrier_counter(int counter) { | 446 void set_write_barrier_counter(int counter) { |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 void ResetFreeList() { free_list_.Reset(); } | 2065 void ResetFreeList() { free_list_.Reset(); } |
2059 | 2066 |
2060 // Set space allocation info. | 2067 // Set space allocation info. |
2061 void SetTopAndLimit(Address top, Address limit) { | 2068 void SetTopAndLimit(Address top, Address limit) { |
2062 DCHECK(top == limit || | 2069 DCHECK(top == limit || |
2063 Page::FromAddress(top) == Page::FromAddress(limit - 1)); | 2070 Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
2064 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 2071 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
2065 allocation_info_.Reset(top, limit); | 2072 allocation_info_.Reset(top, limit); |
2066 } | 2073 } |
2067 | 2074 |
2068 void SetAllocationInfo(Address top, Address limit); | |
2069 | |
2070 // Empty space allocation info, returning unused area to free list. | 2075 // Empty space allocation info, returning unused area to free list. |
2071 void EmptyAllocationInfo(); | 2076 void EmptyAllocationInfo() { |
2072 | 2077 // Mark the old linear allocation area with a free space map so it can be |
2073 void MarkAllocationInfoBlack(); | 2078 // skipped when scanning the heap. |
| 2079 int old_linear_size = static_cast<int>(limit() - top()); |
| 2080 Free(top(), old_linear_size); |
| 2081 SetTopAndLimit(NULL, NULL); |
| 2082 } |
2074 | 2083 |
2075 void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); } | 2084 void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); } |
2076 | 2085 |
2077 void IncreaseCapacity(int size); | 2086 void IncreaseCapacity(int size); |
2078 | 2087 |
2079 // Releases an unused page and shrinks the space. | 2088 // Releases an unused page and shrinks the space. |
2080 void ReleasePage(Page* page); | 2089 void ReleasePage(Page* page); |
2081 | 2090 |
2082 // The dummy page that anchors the linked list of pages. | 2091 // The dummy page that anchors the linked list of pages. |
2083 Page* anchor() { return &anchor_; } | 2092 Page* anchor() { return &anchor_; } |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 count = 0; | 2991 count = 0; |
2983 } | 2992 } |
2984 // Must be small, since an iteration is used for lookup. | 2993 // Must be small, since an iteration is used for lookup. |
2985 static const int kMaxComments = 64; | 2994 static const int kMaxComments = 64; |
2986 }; | 2995 }; |
2987 #endif | 2996 #endif |
2988 } // namespace internal | 2997 } // namespace internal |
2989 } // namespace v8 | 2998 } // namespace v8 |
2990 | 2999 |
2991 #endif // V8_HEAP_SPACES_H_ | 3000 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |