| 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 "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 bool PagedSpace::Expand() { | 1154 bool PagedSpace::Expand() { |
| 1155 int size = AreaSize(); | 1155 int size = AreaSize(); |
| 1156 if (snapshotable() && !HasPages()) { | 1156 if (snapshotable() && !HasPages()) { |
| 1157 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); | 1157 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 if (!heap()->CanExpandOldGeneration(size)) return false; | 1160 if (!heap()->CanExpandOldGeneration(size)) return false; |
| 1161 | 1161 |
| 1162 Page* p = | 1162 Page* p = |
| 1163 heap()->memory_allocator()->AllocatePage<Page>(size, this, executable()); | 1163 heap()->memory_allocator()->AllocatePage<Page>(size, this, executable()); |
| 1164 if (p == nullptr) return false; | 1164 if (p == NULL) return false; |
| 1165 | 1165 |
| 1166 AccountCommitted(static_cast<intptr_t>(p->size())); | 1166 AccountCommitted(static_cast<intptr_t>(p->size())); |
| 1167 | 1167 |
| 1168 // Pages created during bootstrapping may contain immortal immovable objects. | 1168 // Pages created during bootstrapping may contain immortal immovable objects. |
| 1169 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); | 1169 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); |
| 1170 | 1170 |
| 1171 // When incremental marking was activated, old space pages are allocated | 1171 // When incremental marking was activated, old space pages are allocated |
| 1172 // black. | 1172 // black. |
| 1173 if (heap()->incremental_marking()->black_allocation() && | 1173 if (heap()->incremental_marking()->black_allocation() && |
| 1174 identity() == OLD_SPACE) { | 1174 identity() == OLD_SPACE) { |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 page->IsFlagSet(MemoryChunk::IN_FROM_SPACE)); | 1810 page->IsFlagSet(MemoryChunk::IN_FROM_SPACE)); |
| 1811 } | 1811 } |
| 1812 } | 1812 } |
| 1813 | 1813 |
| 1814 | 1814 |
| 1815 void SemiSpace::Reset() { | 1815 void SemiSpace::Reset() { |
| 1816 DCHECK_NE(anchor_.next_page(), &anchor_); | 1816 DCHECK_NE(anchor_.next_page(), &anchor_); |
| 1817 current_page_ = anchor_.next_page(); | 1817 current_page_ = anchor_.next_page(); |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 void SemiSpace::ReplaceWithEmptyPage(NewSpacePage* old_page) { | |
| 1821 NewSpacePage* new_page = | |
| 1822 heap()->memory_allocator()->AllocatePage<NewSpacePage>( | |
| 1823 NewSpacePage::kAllocatableMemory, this, executable()); | |
| 1824 Bitmap::Clear(new_page); | |
| 1825 new_page->SetFlags(old_page->GetFlags(), NewSpacePage::kCopyAllFlags); | |
| 1826 new_page->set_next_page(old_page->next_page()); | |
| 1827 new_page->set_prev_page(old_page->prev_page()); | |
| 1828 old_page->next_page()->set_prev_page(new_page); | |
| 1829 old_page->prev_page()->set_next_page(new_page); | |
| 1830 heap()->CreateFillerObjectAt(new_page->area_start(), new_page->area_size(), | |
| 1831 ClearRecordedSlots::kNo); | |
| 1832 } | |
| 1833 | 1820 |
| 1834 void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) { | 1821 void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) { |
| 1835 // We won't be swapping semispaces without data in them. | 1822 // We won't be swapping semispaces without data in them. |
| 1836 DCHECK_NE(from->anchor_.next_page(), &from->anchor_); | 1823 DCHECK_NE(from->anchor_.next_page(), &from->anchor_); |
| 1837 DCHECK_NE(to->anchor_.next_page(), &to->anchor_); | 1824 DCHECK_NE(to->anchor_.next_page(), &to->anchor_); |
| 1838 | 1825 |
| 1839 intptr_t saved_to_space_flags = to->current_page()->GetFlags(); | 1826 intptr_t saved_to_space_flags = to->current_page()->GetFlags(); |
| 1840 | 1827 |
| 1841 // We swap all properties but id_. | 1828 // We swap all properties but id_. |
| 1842 std::swap(from->current_capacity_, to->current_capacity_); | 1829 std::swap(from->current_capacity_, to->current_capacity_); |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 object->ShortPrint(); | 3127 object->ShortPrint(); |
| 3141 PrintF("\n"); | 3128 PrintF("\n"); |
| 3142 } | 3129 } |
| 3143 printf(" --------------------------------------\n"); | 3130 printf(" --------------------------------------\n"); |
| 3144 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3131 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3145 } | 3132 } |
| 3146 | 3133 |
| 3147 #endif // DEBUG | 3134 #endif // DEBUG |
| 3148 } // namespace internal | 3135 } // namespace internal |
| 3149 } // namespace v8 | 3136 } // namespace v8 |
| OLD | NEW |