| 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 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2882 // If sweeping is still in progress try to sweep pages on the main thread. | 2882 // If sweeping is still in progress try to sweep pages on the main thread. |
| 2883 int max_freed = collector->sweeper().ParallelSweepSpace( | 2883 int max_freed = collector->sweeper().ParallelSweepSpace( |
| 2884 identity(), size_in_bytes, kMaxPagesToSweep); | 2884 identity(), size_in_bytes, kMaxPagesToSweep); |
| 2885 RefillFreeList(); | 2885 RefillFreeList(); |
| 2886 if (max_freed >= size_in_bytes) { | 2886 if (max_freed >= size_in_bytes) { |
| 2887 object = free_list_.Allocate(size_in_bytes); | 2887 object = free_list_.Allocate(size_in_bytes); |
| 2888 if (object != nullptr) return object; | 2888 if (object != nullptr) return object; |
| 2889 } | 2889 } |
| 2890 } | 2890 } |
| 2891 | 2891 |
| 2892 // Free list allocation failed and there is no next page. Fail if we have | 2892 if (heap()->ShouldExpandOldGenerationOnAllocationFailure() && Expand()) { |
| 2893 // hit the old generation size limit that should cause a garbage | |
| 2894 // collection. | |
| 2895 if (!heap()->always_allocate() && | |
| 2896 heap()->OldGenerationAllocationLimitReached()) { | |
| 2897 // If sweeper threads are active, wait for them at that point and steal | |
| 2898 // elements form their free-lists. | |
| 2899 HeapObject* object = SweepAndRetryAllocation(size_in_bytes); | |
| 2900 return object; | |
| 2901 } | |
| 2902 | |
| 2903 // Try to expand the space and allocate in the new next page. | |
| 2904 if (Expand()) { | |
| 2905 DCHECK((CountTotalPages() > 1) || | 2893 DCHECK((CountTotalPages() > 1) || |
| 2906 (size_in_bytes <= free_list_.Available())); | 2894 (size_in_bytes <= free_list_.Available())); |
| 2907 return free_list_.Allocate(size_in_bytes); | 2895 return free_list_.Allocate(size_in_bytes); |
| 2908 } | 2896 } |
| 2909 | 2897 |
| 2910 // If sweeper threads are active, wait for them at that point and steal | 2898 // If sweeper threads are active, wait for them at that point and steal |
| 2911 // elements form their free-lists. Allocation may still fail their which | 2899 // elements form their free-lists. Allocation may still fail their which |
| 2912 // would indicate that there is not enough memory for the given allocation. | 2900 // would indicate that there is not enough memory for the given allocation. |
| 2913 return SweepAndRetryAllocation(size_in_bytes); | 2901 return SweepAndRetryAllocation(size_in_bytes); |
| 2914 } | 2902 } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3281 object->ShortPrint(); | 3269 object->ShortPrint(); |
| 3282 PrintF("\n"); | 3270 PrintF("\n"); |
| 3283 } | 3271 } |
| 3284 printf(" --------------------------------------\n"); | 3272 printf(" --------------------------------------\n"); |
| 3285 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3273 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3286 } | 3274 } |
| 3287 | 3275 |
| 3288 #endif // DEBUG | 3276 #endif // DEBUG |
| 3289 } // namespace internal | 3277 } // namespace internal |
| 3290 } // namespace v8 | 3278 } // namespace v8 |
| OLD | NEW |