OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 inline size_t OldGenerationSpaceAvailable() { | 1820 inline size_t OldGenerationSpaceAvailable() { |
1821 if (old_generation_allocation_limit_ <= PromotedTotalSize()) return 0; | 1821 if (old_generation_allocation_limit_ <= PromotedTotalSize()) return 0; |
1822 return old_generation_allocation_limit_ - | 1822 return old_generation_allocation_limit_ - |
1823 static_cast<size_t>(PromotedTotalSize()); | 1823 static_cast<size_t>(PromotedTotalSize()); |
1824 } | 1824 } |
1825 | 1825 |
1826 // We allow incremental marking to overshoot the allocation limit for | 1826 // We allow incremental marking to overshoot the allocation limit for |
1827 // performace reasons. If the overshoot is too large then we are more | 1827 // performace reasons. If the overshoot is too large then we are more |
1828 // eager to finalize incremental marking. | 1828 // eager to finalize incremental marking. |
1829 inline bool AllocationLimitOvershotByLargeMargin() { | 1829 inline bool AllocationLimitOvershotByLargeMargin() { |
| 1830 // This guards against too eager finalization in small heaps. |
| 1831 // The number is chosen based on v8.browsing_mobile on Nexus 7v2. |
| 1832 size_t kMarginForSmallHeaps = 32u * MB; |
1830 if (old_generation_allocation_limit_ >= PromotedTotalSize()) return false; | 1833 if (old_generation_allocation_limit_ >= PromotedTotalSize()) return false; |
1831 uint64_t overshoot = PromotedTotalSize() - old_generation_allocation_limit_; | 1834 uint64_t overshoot = PromotedTotalSize() - old_generation_allocation_limit_; |
1832 // Overshoot margin is 50% of allocation limit or half-way to the max heap. | 1835 // Overshoot margin is 50% of allocation limit or half-way to the max heap |
| 1836 // with special handling of small heaps. |
1833 uint64_t margin = | 1837 uint64_t margin = |
1834 Min(old_generation_allocation_limit_ / 2, | 1838 Min(Max(old_generation_allocation_limit_ / 2, kMarginForSmallHeaps), |
1835 (max_old_generation_size_ - old_generation_allocation_limit_) / 2); | 1839 (max_old_generation_size_ - old_generation_allocation_limit_) / 2); |
1836 return overshoot >= margin; | 1840 return overshoot >= margin; |
1837 } | 1841 } |
1838 | 1842 |
1839 void UpdateTotalGCTime(double duration); | 1843 void UpdateTotalGCTime(double duration); |
1840 | 1844 |
1841 bool MaximumSizeScavenge() { return maximum_size_scavenges_ > 0; } | 1845 bool MaximumSizeScavenge() { return maximum_size_scavenges_ > 0; } |
1842 | 1846 |
1843 // =========================================================================== | 1847 // =========================================================================== |
1844 // Growing strategy. ========================================================= | 1848 // Growing strategy. ========================================================= |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 friend class LargeObjectSpace; | 2666 friend class LargeObjectSpace; |
2663 friend class NewSpace; | 2667 friend class NewSpace; |
2664 friend class PagedSpace; | 2668 friend class PagedSpace; |
2665 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2669 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2666 }; | 2670 }; |
2667 | 2671 |
2668 } // namespace internal | 2672 } // namespace internal |
2669 } // namespace v8 | 2673 } // namespace v8 |
2670 | 2674 |
2671 #endif // V8_HEAP_HEAP_H_ | 2675 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |