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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 if (page->next_chunk() != NULL) { | 1424 if (page->next_chunk() != NULL) { |
1425 DCHECK(page->prev_chunk() != NULL); | 1425 DCHECK(page->prev_chunk() != NULL); |
1426 page->Unlink(); | 1426 page->Unlink(); |
1427 } | 1427 } |
1428 | 1428 |
1429 AccountUncommitted(static_cast<intptr_t>(page->size())); | 1429 AccountUncommitted(static_cast<intptr_t>(page->size())); |
1430 accounting_stats_.ShrinkSpace(page->area_size()); | 1430 accounting_stats_.ShrinkSpace(page->area_size()); |
1431 heap()->memory_allocator()->Free<MemoryAllocator::kPreFreeAndQueue>(page); | 1431 heap()->memory_allocator()->Free<MemoryAllocator::kPreFreeAndQueue>(page); |
1432 } | 1432 } |
1433 | 1433 |
| 1434 std::unique_ptr<ObjectIterator> PagedSpace::GetObjectIterator() { |
| 1435 return std::unique_ptr<ObjectIterator>(new HeapObjectIterator(this)); |
| 1436 } |
| 1437 |
1434 #ifdef DEBUG | 1438 #ifdef DEBUG |
1435 void PagedSpace::Print() {} | 1439 void PagedSpace::Print() {} |
1436 #endif | 1440 #endif |
1437 | 1441 |
1438 #ifdef VERIFY_HEAP | 1442 #ifdef VERIFY_HEAP |
1439 void PagedSpace::Verify(ObjectVisitor* visitor) { | 1443 void PagedSpace::Verify(ObjectVisitor* visitor) { |
1440 bool allocation_pointer_found_in_space = | 1444 bool allocation_pointer_found_in_space = |
1441 (allocation_info_.top() == allocation_info_.limit()); | 1445 (allocation_info_.top() == allocation_info_.limit()); |
1442 for (Page* page : *this) { | 1446 for (Page* page : *this) { |
1443 CHECK(page->owner() == this); | 1447 CHECK(page->owner() == this); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 if (top_on_previous_step_) { | 1823 if (top_on_previous_step_) { |
1820 int bytes_allocated = static_cast<int>(top - top_on_previous_step_); | 1824 int bytes_allocated = static_cast<int>(top - top_on_previous_step_); |
1821 for (int i = 0; i < allocation_observers_->length(); ++i) { | 1825 for (int i = 0; i < allocation_observers_->length(); ++i) { |
1822 (*allocation_observers_)[i]->AllocationStep(bytes_allocated, soon_object, | 1826 (*allocation_observers_)[i]->AllocationStep(bytes_allocated, soon_object, |
1823 size); | 1827 size); |
1824 } | 1828 } |
1825 top_on_previous_step_ = new_top; | 1829 top_on_previous_step_ = new_top; |
1826 } | 1830 } |
1827 } | 1831 } |
1828 | 1832 |
| 1833 std::unique_ptr<ObjectIterator> NewSpace::GetObjectIterator() { |
| 1834 return std::unique_ptr<ObjectIterator>(new SemiSpaceIterator(this)); |
| 1835 } |
| 1836 |
1829 #ifdef VERIFY_HEAP | 1837 #ifdef VERIFY_HEAP |
1830 // We do not use the SemiSpaceIterator because verification doesn't assume | 1838 // We do not use the SemiSpaceIterator because verification doesn't assume |
1831 // that it works (it depends on the invariants we are checking). | 1839 // that it works (it depends on the invariants we are checking). |
1832 void NewSpace::Verify() { | 1840 void NewSpace::Verify() { |
1833 // The allocation pointer should be in the space or at the very end. | 1841 // The allocation pointer should be in the space or at the very end. |
1834 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1842 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
1835 | 1843 |
1836 // There should be objects packed in from the low address up to the | 1844 // There should be objects packed in from the low address up to the |
1837 // allocation pointer. | 1845 // allocation pointer. |
1838 Address current = to_space_.first_page()->area_start(); | 1846 Address current = to_space_.first_page()->area_start(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 allocation_info_.Reset(to_space_.page_high(), to_space_.page_high()); | 2120 allocation_info_.Reset(to_space_.page_high(), to_space_.page_high()); |
2113 } | 2121 } |
2114 } | 2122 } |
2115 if (FLAG_trace_gc_verbose) { | 2123 if (FLAG_trace_gc_verbose) { |
2116 PrintIsolate(heap()->isolate(), | 2124 PrintIsolate(heap()->isolate(), |
2117 "Sealing intermediate generation: bytes_lost=%zu\n", | 2125 "Sealing intermediate generation: bytes_lost=%zu\n", |
2118 fragmentation_in_intermediate_generation_); | 2126 fragmentation_in_intermediate_generation_); |
2119 } | 2127 } |
2120 } | 2128 } |
2121 | 2129 |
| 2130 std::unique_ptr<ObjectIterator> SemiSpace::GetObjectIterator() { |
| 2131 // Use the NewSpace::NewObjectIterator to iterate the ToSpace. |
| 2132 UNREACHABLE(); |
| 2133 return std::unique_ptr<ObjectIterator>(); |
| 2134 } |
| 2135 |
2122 #ifdef DEBUG | 2136 #ifdef DEBUG |
2123 void SemiSpace::Print() {} | 2137 void SemiSpace::Print() {} |
2124 #endif | 2138 #endif |
2125 | 2139 |
2126 #ifdef VERIFY_HEAP | 2140 #ifdef VERIFY_HEAP |
2127 void SemiSpace::Verify() { | 2141 void SemiSpace::Verify() { |
2128 bool is_from_space = (id_ == kFromSpace); | 2142 bool is_from_space = (id_ == kFromSpace); |
2129 Page* page = anchor_.next_page(); | 2143 Page* page = anchor_.next_page(); |
2130 CHECK(anchor_.owner() == this); | 2144 CHECK(anchor_.owner() == this); |
2131 while (page != &anchor_) { | 2145 while (page != &anchor_) { |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 Address address = object->address(); | 3177 Address address = object->address(); |
3164 MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 3178 MemoryChunk* chunk = MemoryChunk::FromAddress(address); |
3165 | 3179 |
3166 bool owned = (chunk->owner() == this); | 3180 bool owned = (chunk->owner() == this); |
3167 | 3181 |
3168 SLOW_DCHECK(!owned || FindObject(address)->IsHeapObject()); | 3182 SLOW_DCHECK(!owned || FindObject(address)->IsHeapObject()); |
3169 | 3183 |
3170 return owned; | 3184 return owned; |
3171 } | 3185 } |
3172 | 3186 |
| 3187 std::unique_ptr<ObjectIterator> LargeObjectSpace::GetObjectIterator() { |
| 3188 return std::unique_ptr<ObjectIterator>(new LargeObjectIterator(this)); |
| 3189 } |
3173 | 3190 |
3174 #ifdef VERIFY_HEAP | 3191 #ifdef VERIFY_HEAP |
3175 // We do not assume that the large object iterator works, because it depends | 3192 // We do not assume that the large object iterator works, because it depends |
3176 // on the invariants we are checking during verification. | 3193 // on the invariants we are checking during verification. |
3177 void LargeObjectSpace::Verify() { | 3194 void LargeObjectSpace::Verify() { |
3178 for (LargePage* chunk = first_page_; chunk != NULL; | 3195 for (LargePage* chunk = first_page_; chunk != NULL; |
3179 chunk = chunk->next_page()) { | 3196 chunk = chunk->next_page()) { |
3180 // Each chunk contains an object that starts at the large object page's | 3197 // Each chunk contains an object that starts at the large object page's |
3181 // object area start. | 3198 // object area start. |
3182 HeapObject* object = chunk->GetObject(); | 3199 HeapObject* object = chunk->GetObject(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3264 object->ShortPrint(); | 3281 object->ShortPrint(); |
3265 PrintF("\n"); | 3282 PrintF("\n"); |
3266 } | 3283 } |
3267 printf(" --------------------------------------\n"); | 3284 printf(" --------------------------------------\n"); |
3268 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3285 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3269 } | 3286 } |
3270 | 3287 |
3271 #endif // DEBUG | 3288 #endif // DEBUG |
3272 } // namespace internal | 3289 } // namespace internal |
3273 } // namespace v8 | 3290 } // namespace v8 |
OLD | NEW |