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