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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 bool PagedSpace::Expand() { | 1158 bool PagedSpace::Expand() { |
1159 int size = AreaSize(); | 1159 int size = AreaSize(); |
1160 if (snapshotable() && !HasPages()) { | 1160 if (snapshotable() && !HasPages()) { |
1161 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); | 1161 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); |
1162 } | 1162 } |
1163 | 1163 |
1164 if (!heap()->CanExpandOldGeneration(size)) return false; | 1164 if (!heap()->CanExpandOldGeneration(size)) return false; |
1165 | 1165 |
1166 Page* p = | 1166 Page* p = |
1167 heap()->memory_allocator()->AllocatePage<Page>(size, this, executable()); | 1167 heap()->memory_allocator()->AllocatePage<Page>(size, this, executable()); |
1168 if (p == NULL) return false; | 1168 if (p == nullptr) return false; |
1169 | 1169 |
1170 AccountCommitted(static_cast<intptr_t>(p->size())); | 1170 AccountCommitted(static_cast<intptr_t>(p->size())); |
1171 | 1171 |
1172 // Pages created during bootstrapping may contain immortal immovable objects. | 1172 // Pages created during bootstrapping may contain immortal immovable objects. |
1173 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); | 1173 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); |
1174 | 1174 |
1175 // When incremental marking was activated, old space pages are allocated | 1175 // When incremental marking was activated, old space pages are allocated |
1176 // black. | 1176 // black. |
1177 if (heap()->incremental_marking()->black_allocation() && | 1177 if (heap()->incremental_marking()->black_allocation() && |
1178 identity() == OLD_SPACE) { | 1178 identity() == OLD_SPACE) { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 page->IsFlagSet(MemoryChunk::IN_FROM_SPACE)); | 1795 page->IsFlagSet(MemoryChunk::IN_FROM_SPACE)); |
1796 } | 1796 } |
1797 } | 1797 } |
1798 | 1798 |
1799 | 1799 |
1800 void SemiSpace::Reset() { | 1800 void SemiSpace::Reset() { |
1801 DCHECK_NE(anchor_.next_page(), &anchor_); | 1801 DCHECK_NE(anchor_.next_page(), &anchor_); |
1802 current_page_ = anchor_.next_page(); | 1802 current_page_ = anchor_.next_page(); |
1803 } | 1803 } |
1804 | 1804 |
| 1805 void SemiSpace::ReplaceWithEmptyPage(NewSpacePage* old_page) { |
| 1806 NewSpacePage* new_page = |
| 1807 heap()->memory_allocator()->AllocatePage<NewSpacePage>( |
| 1808 NewSpacePage::kAllocatableMemory, this, executable()); |
| 1809 Bitmap::Clear(new_page); |
| 1810 new_page->SetFlags(old_page->GetFlags(), NewSpacePage::kCopyAllFlags); |
| 1811 new_page->set_next_page(old_page->next_page()); |
| 1812 new_page->set_prev_page(old_page->prev_page()); |
| 1813 old_page->next_page()->set_prev_page(new_page); |
| 1814 old_page->prev_page()->set_next_page(new_page); |
| 1815 heap()->CreateFillerObjectAt(new_page->area_start(), new_page->area_size(), |
| 1816 ClearRecordedSlots::kNo); |
| 1817 } |
1805 | 1818 |
1806 void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) { | 1819 void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) { |
1807 // We won't be swapping semispaces without data in them. | 1820 // We won't be swapping semispaces without data in them. |
1808 DCHECK_NE(from->anchor_.next_page(), &from->anchor_); | 1821 DCHECK_NE(from->anchor_.next_page(), &from->anchor_); |
1809 DCHECK_NE(to->anchor_.next_page(), &to->anchor_); | 1822 DCHECK_NE(to->anchor_.next_page(), &to->anchor_); |
1810 | 1823 |
1811 intptr_t saved_to_space_flags = to->current_page()->GetFlags(); | 1824 intptr_t saved_to_space_flags = to->current_page()->GetFlags(); |
1812 | 1825 |
1813 // We swap all properties but id_. | 1826 // We swap all properties but id_. |
1814 std::swap(from->current_capacity_, to->current_capacity_); | 1827 std::swap(from->current_capacity_, to->current_capacity_); |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3117 object->ShortPrint(); | 3130 object->ShortPrint(); |
3118 PrintF("\n"); | 3131 PrintF("\n"); |
3119 } | 3132 } |
3120 printf(" --------------------------------------\n"); | 3133 printf(" --------------------------------------\n"); |
3121 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3134 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3122 } | 3135 } |
3123 | 3136 |
3124 #endif // DEBUG | 3137 #endif // DEBUG |
3125 } // namespace internal | 3138 } // namespace internal |
3126 } // namespace v8 | 3139 } // namespace v8 |
OLD | NEW |