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/slots-buffer.h" | 10 #include "src/heap/slots-buffer.h" |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 945 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
946 ObjectSpace::kObjectSpaceOldSpace); | 946 ObjectSpace::kObjectSpaceOldSpace); |
947 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 947 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
948 ObjectSpace::kObjectSpaceCodeSpace); | 948 ObjectSpace::kObjectSpaceCodeSpace); |
949 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 949 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
950 ObjectSpace::kObjectSpaceMapSpace); | 950 ObjectSpace::kObjectSpaceMapSpace); |
951 | 951 |
952 | 952 |
953 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, | 953 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, |
954 Executability executable) | 954 Executability executable) |
955 : Space(heap, space, executable), | 955 : Space(heap, space, executable), free_list_(this) { |
956 free_list_(this), | |
957 end_of_unswept_pages_(NULL) { | |
958 area_size_ = MemoryAllocator::PageAreaSize(space); | 956 area_size_ = MemoryAllocator::PageAreaSize(space); |
959 accounting_stats_.Clear(); | 957 accounting_stats_.Clear(); |
960 | 958 |
961 allocation_info_.Reset(nullptr, nullptr); | 959 allocation_info_.Reset(nullptr, nullptr); |
962 | 960 |
963 anchor_.InitializeAsAnchor(this); | 961 anchor_.InitializeAsAnchor(this); |
964 } | 962 } |
965 | 963 |
966 | 964 |
967 bool PagedSpace::SetUp() { return true; } | 965 bool PagedSpace::SetUp() { return true; } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 MoveOverFreeMemory(other); | 1100 MoveOverFreeMemory(other); |
1103 | 1101 |
1104 // Update and clear accounting statistics. | 1102 // Update and clear accounting statistics. |
1105 accounting_stats_.Merge(other->accounting_stats_); | 1103 accounting_stats_.Merge(other->accounting_stats_); |
1106 other->accounting_stats_.Clear(); | 1104 other->accounting_stats_.Clear(); |
1107 | 1105 |
1108 // The linear allocation area of {other} should be destroyed now. | 1106 // The linear allocation area of {other} should be destroyed now. |
1109 DCHECK(other->top() == nullptr); | 1107 DCHECK(other->top() == nullptr); |
1110 DCHECK(other->limit() == nullptr); | 1108 DCHECK(other->limit() == nullptr); |
1111 | 1109 |
1112 DCHECK(other->end_of_unswept_pages_ == nullptr); | |
1113 | |
1114 AccountCommitted(other->CommittedMemory()); | 1110 AccountCommitted(other->CommittedMemory()); |
1115 | 1111 |
1116 // Move over pages. | 1112 // Move over pages. |
1117 PageIterator it(other); | 1113 PageIterator it(other); |
1118 Page* p = nullptr; | 1114 Page* p = nullptr; |
1119 while (it.has_next()) { | 1115 while (it.has_next()) { |
1120 p = it.next(); | 1116 p = it.next(); |
1121 p->Unlink(); | 1117 p->Unlink(); |
1122 p->set_owner(this); | 1118 p->set_owner(this); |
1123 p->InsertAfter(anchor_.prev_page()); | 1119 p->InsertAfter(anchor_.prev_page()); |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2844 if (collector->sweeping_in_progress()) { | 2840 if (collector->sweeping_in_progress()) { |
2845 // First try to refill the free-list, concurrent sweeper threads | 2841 // First try to refill the free-list, concurrent sweeper threads |
2846 // may have freed some objects in the meantime. | 2842 // may have freed some objects in the meantime. |
2847 RefillFreeList(); | 2843 RefillFreeList(); |
2848 | 2844 |
2849 // Retry the free list allocation. | 2845 // Retry the free list allocation. |
2850 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2846 HeapObject* object = free_list_.Allocate(size_in_bytes); |
2851 if (object != NULL) return object; | 2847 if (object != NULL) return object; |
2852 | 2848 |
2853 // If sweeping is still in progress try to sweep pages on the main thread. | 2849 // If sweeping is still in progress try to sweep pages on the main thread. |
2854 collector->SweepInParallel(heap()->paged_space(identity()), size_in_bytes); | 2850 int max_freed = collector->SweepInParallel(heap()->paged_space(identity()), |
2855 RefillFreeList(); | 2851 size_in_bytes, 1); |
Hannes Payer (out of office)
2016/01/20 09:25:03
1 should be a constant.
Michael Lippautz
2016/01/20 11:11:16
Done: kMaxPagesSweptDuringSlowAllocation
| |
2856 object = free_list_.Allocate(size_in_bytes); | 2852 if (max_freed >= size_in_bytes) { |
Hannes Payer (out of office)
2016/01/20 09:25:03
If you add this case, you want to call RefillFreeL
Michael Lippautz
2016/01/20 11:11:16
Done. (ftr: this is to move over already freed mem
| |
2857 if (object != nullptr) return object; | 2853 RefillFreeList(); |
2854 object = free_list_.Allocate(size_in_bytes); | |
2855 if (object != nullptr) return object; | |
2856 } | |
2858 } | 2857 } |
2859 | 2858 |
2860 // Free list allocation failed and there is no next page. Fail if we have | 2859 // Free list allocation failed and there is no next page. Fail if we have |
2861 // hit the old generation size limit that should cause a garbage | 2860 // hit the old generation size limit that should cause a garbage |
2862 // collection. | 2861 // collection. |
2863 if (!heap()->always_allocate() && | 2862 if (!heap()->always_allocate() && |
2864 heap()->OldGenerationAllocationLimitReached()) { | 2863 heap()->OldGenerationAllocationLimitReached()) { |
2865 // If sweeper threads are active, wait for them at that point and steal | 2864 // If sweeper threads are active, wait for them at that point and steal |
2866 // elements form their free-lists. | 2865 // elements form their free-lists. |
2867 HeapObject* object = SweepAndRetryAllocation(size_in_bytes); | 2866 HeapObject* object = SweepAndRetryAllocation(size_in_bytes); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3363 object->ShortPrint(); | 3362 object->ShortPrint(); |
3364 PrintF("\n"); | 3363 PrintF("\n"); |
3365 } | 3364 } |
3366 printf(" --------------------------------------\n"); | 3365 printf(" --------------------------------------\n"); |
3367 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3366 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3368 } | 3367 } |
3369 | 3368 |
3370 #endif // DEBUG | 3369 #endif // DEBUG |
3371 } // namespace internal | 3370 } // namespace internal |
3372 } // namespace v8 | 3371 } // namespace v8 |
OLD | NEW |