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_INL_H_ | 5 #ifndef V8_HEAP_SPACES_INL_H_ |
6 #define V8_HEAP_SPACES_INL_H_ | 6 #define V8_HEAP_SPACES_INL_H_ |
7 | 7 |
8 #include "src/heap/incremental-marking.h" | 8 #include "src/heap/incremental-marking.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return *this; | 21 return *this; |
22 } | 22 } |
23 | 23 |
24 template <class PAGE_TYPE> | 24 template <class PAGE_TYPE> |
25 PageIteratorImpl<PAGE_TYPE> PageIteratorImpl<PAGE_TYPE>::operator++(int) { | 25 PageIteratorImpl<PAGE_TYPE> PageIteratorImpl<PAGE_TYPE>::operator++(int) { |
26 PageIteratorImpl<PAGE_TYPE> tmp(*this); | 26 PageIteratorImpl<PAGE_TYPE> tmp(*this); |
27 operator++(); | 27 operator++(); |
28 return tmp; | 28 return tmp; |
29 } | 29 } |
30 | 30 |
31 NewSpacePageRange::NewSpacePageRange(Address start, Address limit) | 31 PageRange::PageRange(Address start, Address limit) |
32 : range_(Page::FromAddress(start), | 32 : begin_(Page::FromAllocationAreaAddress(start)), |
33 Page::FromAllocationAreaAddress(limit)->next_page()) { | 33 end_(Page::FromAllocationAreaAddress(limit)->next_page()) { |
34 SemiSpace::AssertValidRange(start, limit); | 34 #ifdef DEBUG |
| 35 if (begin_->InNewSpace()) { |
| 36 SemiSpace::AssertValidRange(start, limit); |
| 37 } |
| 38 #endif // DEBUG |
35 } | 39 } |
36 | 40 |
37 // ----------------------------------------------------------------------------- | 41 // ----------------------------------------------------------------------------- |
38 // SemiSpaceIterator | 42 // SemiSpaceIterator |
39 | 43 |
40 HeapObject* SemiSpaceIterator::Next() { | 44 HeapObject* SemiSpaceIterator::Next() { |
41 while (current_ != limit_) { | 45 while (current_ != limit_) { |
42 if (Page::IsAlignedToPageSize(current_)) { | 46 if (Page::IsAlignedToPageSize(current_)) { |
43 Page* page = Page::FromAllocationAreaAddress(current_); | 47 Page* page = Page::FromAllocationAreaAddress(current_); |
44 page = page->next_page(); | 48 page = page->next_page(); |
(...skipping 16 matching lines...) Expand all Loading... |
61 HeapObject* HeapObjectIterator::Next() { | 65 HeapObject* HeapObjectIterator::Next() { |
62 do { | 66 do { |
63 HeapObject* next_obj = FromCurrentPage(); | 67 HeapObject* next_obj = FromCurrentPage(); |
64 if (next_obj != nullptr) return next_obj; | 68 if (next_obj != nullptr) return next_obj; |
65 } while (AdvanceToNextPage()); | 69 } while (AdvanceToNextPage()); |
66 return nullptr; | 70 return nullptr; |
67 } | 71 } |
68 | 72 |
69 HeapObject* HeapObjectIterator::FromCurrentPage() { | 73 HeapObject* HeapObjectIterator::FromCurrentPage() { |
70 while (cur_addr_ != cur_end_) { | 74 while (cur_addr_ != cur_end_) { |
71 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { | 75 // When the current address equals top we have to handle two scenarios: |
72 cur_addr_ = space_->limit(); | 76 // - Old space page: Move forward to limit if top != limit. We will find |
| 77 // a filler following limit. |
| 78 // - New space page: We have to stop iteration before the linear allocation |
| 79 // area as there are no fillers behind it. |
| 80 if (cur_addr_ == space_->top() && |
| 81 (cur_addr_ != space_->limit() || current_page()->InNewSpace())) { |
| 82 cur_addr_ = current_page()->InNewSpace() ? cur_end_ : space_->limit(); |
73 continue; | 83 continue; |
74 } | 84 } |
75 HeapObject* obj = HeapObject::FromAddress(cur_addr_); | 85 HeapObject* obj = HeapObject::FromAddress(cur_addr_); |
76 const int obj_size = obj->Size(); | 86 const int obj_size = obj->Size(); |
77 cur_addr_ += obj_size; | 87 cur_addr_ += obj_size; |
78 DCHECK_LE(cur_addr_, cur_end_); | 88 DCHECK_LE(cur_addr_, cur_end_); |
79 if (!obj->IsFiller()) { | 89 if (!obj->IsFiller()) { |
80 if (obj->IsCode()) { | 90 if (obj->IsCode()) { |
81 DCHECK_EQ(space_, space_->heap()->code_space()); | 91 DCHECK_EQ(space_, space_->heap()->code_space()); |
82 DCHECK_CODEOBJECT_SIZE(obj_size, space_); | 92 DCHECK_CODEOBJECT_SIZE(obj_size, reinterpret_cast<PagedSpace*>(space_)); |
83 } else { | 93 } else { |
84 DCHECK_OBJECT_SIZE(obj_size); | 94 DCHECK_OBJECT_SIZE(obj_size); |
85 } | 95 } |
86 return obj; | 96 return obj; |
87 } | 97 } |
88 } | 98 } |
89 return nullptr; | 99 return nullptr; |
90 } | 100 } |
91 | 101 |
92 // ----------------------------------------------------------------------------- | 102 // ----------------------------------------------------------------------------- |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 other->allocation_info_.Reset(nullptr, nullptr); | 630 other->allocation_info_.Reset(nullptr, nullptr); |
621 return true; | 631 return true; |
622 } | 632 } |
623 return false; | 633 return false; |
624 } | 634 } |
625 | 635 |
626 } // namespace internal | 636 } // namespace internal |
627 } // namespace v8 | 637 } // namespace v8 |
628 | 638 |
629 #endif // V8_HEAP_SPACES_INL_H_ | 639 #endif // V8_HEAP_SPACES_INL_H_ |
OLD | NEW |