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 2734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 if (collector->sweeping_in_progress()) { | 2745 if (collector->sweeping_in_progress()) { |
2746 // First try to refill the free-list, concurrent sweeper threads | 2746 // First try to refill the free-list, concurrent sweeper threads |
2747 // may have freed some objects in the meantime. | 2747 // may have freed some objects in the meantime. |
2748 RefillFreeList(); | 2748 RefillFreeList(); |
2749 | 2749 |
2750 // Retry the free list allocation. | 2750 // Retry the free list allocation. |
2751 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2751 HeapObject* object = free_list_.Allocate(size_in_bytes); |
2752 if (object != NULL) return object; | 2752 if (object != NULL) return object; |
2753 | 2753 |
2754 // If sweeping is still in progress try to sweep pages on the main thread. | 2754 // If sweeping is still in progress try to sweep pages on the main thread. |
2755 int free_chunk = collector->SweepInParallel(this, size_in_bytes); | 2755 collector->SweepInParallel(heap()->paged_space(identity()), size_in_bytes); |
2756 RefillFreeList(); | 2756 RefillFreeList(); |
2757 if (free_chunk >= size_in_bytes) { | 2757 object = free_list_.Allocate(size_in_bytes); |
2758 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2758 if (object != nullptr) return object; |
2759 // We should be able to allocate an object here since we just freed that | |
2760 // much memory. | |
2761 DCHECK(object != NULL); | |
2762 if (object != NULL) return object; | |
2763 } | |
2764 } | 2759 } |
2765 | 2760 |
2766 // Free list allocation failed and there is no next page. Fail if we have | 2761 // Free list allocation failed and there is no next page. Fail if we have |
2767 // hit the old generation size limit that should cause a garbage | 2762 // hit the old generation size limit that should cause a garbage |
2768 // collection. | 2763 // collection. |
2769 if (!heap()->always_allocate() && | 2764 if (!heap()->always_allocate() && |
2770 heap()->OldGenerationAllocationLimitReached()) { | 2765 heap()->OldGenerationAllocationLimitReached()) { |
2771 // If sweeper threads are active, wait for them at that point and steal | 2766 // If sweeper threads are active, wait for them at that point and steal |
2772 // elements form their free-lists. | 2767 // elements form their free-lists. |
2773 HeapObject* object = SweepAndRetryAllocation(size_in_bytes); | 2768 HeapObject* object = SweepAndRetryAllocation(size_in_bytes); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 object->ShortPrint(); | 3271 object->ShortPrint(); |
3277 PrintF("\n"); | 3272 PrintF("\n"); |
3278 } | 3273 } |
3279 printf(" --------------------------------------\n"); | 3274 printf(" --------------------------------------\n"); |
3280 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3275 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3281 } | 3276 } |
3282 | 3277 |
3283 #endif // DEBUG | 3278 #endif // DEBUG |
3284 } // namespace internal | 3279 } // namespace internal |
3285 } // namespace v8 | 3280 } // namespace v8 |
OLD | NEW |