| 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 #include "src/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 | 23 |
| 24 // ---------------------------------------------------------------------------- | 24 // ---------------------------------------------------------------------------- |
| 25 // HeapObjectIterator | 25 // HeapObjectIterator |
| 26 | 26 |
| 27 HeapObjectIterator::HeapObjectIterator(PagedSpace* space) | 27 HeapObjectIterator::HeapObjectIterator(PagedSpace* space) |
| 28 : cur_addr_(nullptr), | 28 : cur_addr_(nullptr), |
| 29 cur_end_(nullptr), | 29 cur_end_(nullptr), |
| 30 space_(space), | 30 space_(space), |
| 31 page_range_(space->anchor()->next_page(), space->anchor()), | 31 page_range_(space->anchor()->next_page(), space->anchor()), |
| 32 next_page_(page_range_.begin()) {} | 32 current_page_(page_range_.begin()) {} |
| 33 | |
| 34 HeapObjectIterator::HeapObjectIterator(NewSpace* space) | |
| 35 : cur_addr_(nullptr), | |
| 36 cur_end_(nullptr), | |
| 37 space_(space), | |
| 38 page_range_(space->bottom(), space->top()), | |
| 39 next_page_(page_range_.begin()) {} | |
| 40 | 33 |
| 41 HeapObjectIterator::HeapObjectIterator(Page* page) | 34 HeapObjectIterator::HeapObjectIterator(Page* page) |
| 42 : cur_addr_(nullptr), | 35 : cur_addr_(nullptr), |
| 43 cur_end_(nullptr), | 36 cur_end_(nullptr), |
| 44 space_(reinterpret_cast<SpaceWithInlineAllocationArea*>(page->owner())), | 37 space_(reinterpret_cast<PagedSpace*>(page->owner())), |
| 45 page_range_(page), | 38 page_range_(page), |
| 46 next_page_(page_range_.begin()) { | 39 current_page_(page_range_.begin()) { |
| 47 #ifdef DEBUG | 40 #ifdef DEBUG |
| 48 Space* owner = page->owner(); | 41 Space* owner = page->owner(); |
| 49 Heap* heap = page->heap(); | 42 DCHECK(owner == page->heap()->old_space() || |
| 50 DCHECK(owner == heap->old_space() || owner == heap->map_space() || | 43 owner == page->heap()->map_space() || |
| 51 owner == heap->code_space() || owner == heap->new_space()); | 44 owner == page->heap()->code_space()); |
| 52 #endif // DEBUG | 45 #endif // DEBUG |
| 53 } | 46 } |
| 54 | 47 |
| 55 // We have hit the end of the page and should advance to the next block of | 48 // We have hit the end of the page and should advance to the next block of |
| 56 // objects. This happens at the end of the page. | 49 // objects. This happens at the end of the page. |
| 57 bool HeapObjectIterator::AdvanceToNextPage() { | 50 bool HeapObjectIterator::AdvanceToNextPage() { |
| 58 DCHECK_EQ(cur_addr_, cur_end_); | 51 DCHECK_EQ(cur_addr_, cur_end_); |
| 59 if (next_page_ == page_range_.end()) return false; | 52 if (current_page_ == page_range_.end()) return false; |
| 60 Page* cur_page = *(next_page_++); | 53 Page* cur_page = *(current_page_++); |
| 61 space_->heap() | 54 space_->heap() |
| 62 ->mark_compact_collector() | 55 ->mark_compact_collector() |
| 63 ->sweeper() | 56 ->sweeper() |
| 64 .SweepOrWaitUntilSweepingCompleted(cur_page); | 57 .SweepOrWaitUntilSweepingCompleted(cur_page); |
| 65 cur_addr_ = cur_page->area_start(); | 58 cur_addr_ = cur_page->area_start(); |
| 66 cur_end_ = cur_page->area_end(); | 59 cur_end_ = cur_page->area_end(); |
| 67 DCHECK(cur_page->SweepingDone()); | 60 DCHECK(cur_page->SweepingDone()); |
| 68 return true; | 61 return true; |
| 69 } | 62 } |
| 70 | 63 |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 if (!allocation_observers_paused_) { | 1173 if (!allocation_observers_paused_) { |
| 1181 for (int i = 0; i < allocation_observers_->length(); ++i) { | 1174 for (int i = 0; i < allocation_observers_->length(); ++i) { |
| 1182 AllocationObserver* o = (*allocation_observers_)[i]; | 1175 AllocationObserver* o = (*allocation_observers_)[i]; |
| 1183 o->AllocationStep(size, soon_object, size); | 1176 o->AllocationStep(size, soon_object, size); |
| 1184 } | 1177 } |
| 1185 } | 1178 } |
| 1186 } | 1179 } |
| 1187 | 1180 |
| 1188 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, | 1181 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, |
| 1189 Executability executable) | 1182 Executability executable) |
| 1190 : SpaceWithInlineAllocationArea(heap, space, executable), | 1183 : Space(heap, space, executable), anchor_(this), free_list_(this) { |
| 1191 anchor_(this), | |
| 1192 free_list_(this) { | |
| 1193 area_size_ = MemoryAllocator::PageAreaSize(space); | 1184 area_size_ = MemoryAllocator::PageAreaSize(space); |
| 1194 accounting_stats_.Clear(); | 1185 accounting_stats_.Clear(); |
| 1195 | 1186 |
| 1196 allocation_info_.Reset(nullptr, nullptr); | 1187 allocation_info_.Reset(nullptr, nullptr); |
| 1197 } | 1188 } |
| 1198 | 1189 |
| 1199 | 1190 |
| 1200 bool PagedSpace::SetUp() { return true; } | 1191 bool PagedSpace::SetUp() { return true; } |
| 1201 | 1192 |
| 1202 | 1193 |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 std::swap(from->current_page_, to->current_page_); | 2088 std::swap(from->current_page_, to->current_page_); |
| 2098 | 2089 |
| 2099 to->FixPagesFlags(saved_to_space_flags, Page::kCopyOnFlipFlagsMask); | 2090 to->FixPagesFlags(saved_to_space_flags, Page::kCopyOnFlipFlagsMask); |
| 2100 from->FixPagesFlags(0, 0); | 2091 from->FixPagesFlags(0, 0); |
| 2101 } | 2092 } |
| 2102 | 2093 |
| 2103 void SemiSpace::set_age_mark(Address mark) { | 2094 void SemiSpace::set_age_mark(Address mark) { |
| 2104 DCHECK_EQ(Page::FromAllocationAreaAddress(mark)->owner(), this); | 2095 DCHECK_EQ(Page::FromAllocationAreaAddress(mark)->owner(), this); |
| 2105 age_mark_ = mark; | 2096 age_mark_ = mark; |
| 2106 // Mark all pages up to the one containing mark. | 2097 // Mark all pages up to the one containing mark. |
| 2107 for (Page* p : PageRange(space_start(), mark)) { | 2098 for (Page* p : NewSpacePageRange(space_start(), mark)) { |
| 2108 p->SetFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK); | 2099 p->SetFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK); |
| 2109 } | 2100 } |
| 2110 } | 2101 } |
| 2111 | 2102 |
| 2112 std::unique_ptr<ObjectIterator> SemiSpace::GetObjectIterator() { | 2103 std::unique_ptr<ObjectIterator> SemiSpace::GetObjectIterator() { |
| 2113 // Use the NewSpace::NewObjectIterator to iterate the ToSpace. | 2104 // Use the NewSpace::NewObjectIterator to iterate the ToSpace. |
| 2114 UNREACHABLE(); | 2105 UNREACHABLE(); |
| 2115 return std::unique_ptr<ObjectIterator>(); | 2106 return std::unique_ptr<ObjectIterator>(); |
| 2116 } | 2107 } |
| 2117 | 2108 |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3256 object->ShortPrint(); | 3247 object->ShortPrint(); |
| 3257 PrintF("\n"); | 3248 PrintF("\n"); |
| 3258 } | 3249 } |
| 3259 printf(" --------------------------------------\n"); | 3250 printf(" --------------------------------------\n"); |
| 3260 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3251 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3261 } | 3252 } |
| 3262 | 3253 |
| 3263 #endif // DEBUG | 3254 #endif // DEBUG |
| 3264 } // namespace internal | 3255 } // namespace internal |
| 3265 } // namespace v8 | 3256 } // namespace v8 |
| OLD | NEW |