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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 574 |
575 // Support for partial snapshots. After calling this we have a linear | 575 // Support for partial snapshots. After calling this we have a linear |
576 // space to write objects in each space. | 576 // space to write objects in each space. |
577 struct Chunk { | 577 struct Chunk { |
578 uint32_t size; | 578 uint32_t size; |
579 Address start; | 579 Address start; |
580 Address end; | 580 Address end; |
581 }; | 581 }; |
582 typedef List<Chunk> Reservation; | 582 typedef List<Chunk> Reservation; |
583 | 583 |
584 static const int kInitalOldGenerationLimitFactor = 2; | |
585 | |
586 #if V8_OS_ANDROID | 584 #if V8_OS_ANDROID |
587 // Don't apply pointer multiplier on Android since it has no swap space and | 585 // Don't apply pointer multiplier on Android since it has no swap space and |
588 // should instead adapt it's heap size based on available physical memory. | 586 // should instead adapt it's heap size based on available physical memory. |
589 static const int kPointerMultiplier = 1; | 587 static const int kPointerMultiplier = 1; |
590 #else | 588 #else |
591 static const int kPointerMultiplier = i::kPointerSize / 4; | 589 static const int kPointerMultiplier = i::kPointerSize / 4; |
592 #endif | 590 #endif |
593 | 591 |
594 // The new space size has to be a power of 2. Sizes are in MB. | 592 // The new space size has to be a power of 2. Sizes are in MB. |
595 static const int kMaxSemiSpaceSizeLowMemoryDevice = 1 * kPointerMultiplier; | 593 static const int kMaxSemiSpaceSizeLowMemoryDevice = 1 * kPointerMultiplier; |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 | 1712 |
1715 // Record statistics before and after garbage collection. | 1713 // Record statistics before and after garbage collection. |
1716 void ReportStatisticsBeforeGC(); | 1714 void ReportStatisticsBeforeGC(); |
1717 void ReportStatisticsAfterGC(); | 1715 void ReportStatisticsAfterGC(); |
1718 | 1716 |
1719 // Creates and installs the full-sized number string cache. | 1717 // Creates and installs the full-sized number string cache. |
1720 int FullSizeNumberStringCacheLength(); | 1718 int FullSizeNumberStringCacheLength(); |
1721 // Flush the number to string cache. | 1719 // Flush the number to string cache. |
1722 void FlushNumberStringCache(); | 1720 void FlushNumberStringCache(); |
1723 | 1721 |
1724 void ConfigureInitialOldGenerationSize(); | |
1725 | |
1726 bool HasLowYoungGenerationAllocationRate(); | 1722 bool HasLowYoungGenerationAllocationRate(); |
1727 bool HasLowOldGenerationAllocationRate(); | 1723 bool HasLowOldGenerationAllocationRate(); |
1728 double YoungGenerationMutatorUtilization(); | 1724 double YoungGenerationMutatorUtilization(); |
1729 double OldGenerationMutatorUtilization(); | 1725 double OldGenerationMutatorUtilization(); |
1730 | 1726 |
1731 void ReduceNewSpaceSize(); | 1727 void ReduceNewSpaceSize(); |
1732 | 1728 |
1733 GCIdleTimeHeapState ComputeHeapState(); | 1729 GCIdleTimeHeapState ComputeHeapState(); |
1734 | 1730 |
1735 bool PerformIdleTimeAction(GCIdleTimeAction action, | 1731 bool PerformIdleTimeAction(GCIdleTimeAction action, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 void ProcessAllWeakReferences(WeakObjectRetainer* retainer); | 1802 void ProcessAllWeakReferences(WeakObjectRetainer* retainer); |
1807 void ProcessYoungWeakReferences(WeakObjectRetainer* retainer); | 1803 void ProcessYoungWeakReferences(WeakObjectRetainer* retainer); |
1808 void ProcessNativeContexts(WeakObjectRetainer* retainer); | 1804 void ProcessNativeContexts(WeakObjectRetainer* retainer); |
1809 void ProcessAllocationSites(WeakObjectRetainer* retainer); | 1805 void ProcessAllocationSites(WeakObjectRetainer* retainer); |
1810 void ProcessWeakListRoots(WeakObjectRetainer* retainer); | 1806 void ProcessWeakListRoots(WeakObjectRetainer* retainer); |
1811 | 1807 |
1812 // =========================================================================== | 1808 // =========================================================================== |
1813 // GC statistics. ============================================================ | 1809 // GC statistics. ============================================================ |
1814 // =========================================================================== | 1810 // =========================================================================== |
1815 | 1811 |
1816 inline size_t OldGenerationSpaceAvailable() { | 1812 size_t OldGenerationSpaceAvailable(); |
1817 if (old_generation_allocation_limit_ <= PromotedTotalSize()) return 0; | |
1818 return old_generation_allocation_limit_ - | |
1819 static_cast<size_t>(PromotedTotalSize()); | |
1820 } | |
1821 | 1813 |
1822 void UpdateTotalGCTime(double duration); | 1814 void UpdateTotalGCTime(double duration); |
1823 | 1815 |
1824 bool MaximumSizeScavenge() { return maximum_size_scavenges_ > 0; } | 1816 bool MaximumSizeScavenge() { return maximum_size_scavenges_ > 0; } |
1825 | 1817 |
1826 // =========================================================================== | 1818 // =========================================================================== |
1827 // Growing strategy. ========================================================= | 1819 // Growing strategy. ========================================================= |
1828 // =========================================================================== | 1820 // =========================================================================== |
1829 | 1821 |
| 1822 static const int kInitalOldGenerationLimitFactor = 2; |
| 1823 |
| 1824 // For some webpages RAIL mode does not switch from PERFORMANCE_LOAD. |
| 1825 // This constant limits the effect of load RAIL mode on GC. |
| 1826 // The value is arbitrary and chosen as the largest load time observed in |
| 1827 // v8 browsing benchmarks. |
| 1828 static const int kMaxLoadTimeMs = 3000; |
| 1829 |
| 1830 bool ShouldOptimizeForLoadTime(); |
| 1831 |
1830 // Decrease the allocation limit if the new limit based on the given | 1832 // Decrease the allocation limit if the new limit based on the given |
1831 // parameters is lower than the current limit. | 1833 // parameters is lower than the current limit. |
1832 void DampenOldGenerationAllocationLimit(size_t old_gen_size, double gc_speed, | 1834 void DampenOldGenerationAllocationLimit(size_t old_gen_size, double gc_speed, |
1833 double mutator_speed); | 1835 double mutator_speed); |
1834 | 1836 |
1835 // Calculates the allocation limit based on a given growing factor and a | 1837 // Calculates the allocation limit based on a given growing factor and a |
1836 // given old generation size. | 1838 // given old generation size. |
1837 size_t CalculateOldGenerationAllocationLimit(double factor, | 1839 size_t CalculateOldGenerationAllocationLimit(double factor, |
1838 size_t old_gen_size); | 1840 size_t old_gen_size); |
1839 | 1841 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 // more expedient to get at the isolate directly from within Heap methods. | 2111 // more expedient to get at the isolate directly from within Heap methods. |
2110 Isolate* isolate_; | 2112 Isolate* isolate_; |
2111 | 2113 |
2112 Object* roots_[kRootListLength]; | 2114 Object* roots_[kRootListLength]; |
2113 | 2115 |
2114 size_t code_range_size_; | 2116 size_t code_range_size_; |
2115 size_t max_semi_space_size_; | 2117 size_t max_semi_space_size_; |
2116 size_t initial_semispace_size_; | 2118 size_t initial_semispace_size_; |
2117 size_t max_old_generation_size_; | 2119 size_t max_old_generation_size_; |
2118 size_t initial_old_generation_size_; | 2120 size_t initial_old_generation_size_; |
2119 bool old_generation_size_configured_; | |
2120 size_t max_executable_size_; | 2121 size_t max_executable_size_; |
2121 size_t maximum_committed_; | 2122 size_t maximum_committed_; |
2122 | 2123 |
2123 // For keeping track of how much data has survived | 2124 // For keeping track of how much data has survived |
2124 // scavenge since last new space expansion. | 2125 // scavenge since last new space expansion. |
2125 size_t survived_since_last_expansion_; | 2126 size_t survived_since_last_expansion_; |
2126 | 2127 |
2127 // ... and since the last scavenge. | 2128 // ... and since the last scavenge. |
2128 size_t survived_last_scavenge_; | 2129 size_t survived_last_scavenge_; |
2129 | 2130 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 friend class LargeObjectSpace; | 2646 friend class LargeObjectSpace; |
2646 friend class NewSpace; | 2647 friend class NewSpace; |
2647 friend class PagedSpace; | 2648 friend class PagedSpace; |
2648 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2649 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2649 }; | 2650 }; |
2650 | 2651 |
2651 } // namespace internal | 2652 } // namespace internal |
2652 } // namespace v8 | 2653 } // namespace v8 |
2653 | 2654 |
2654 #endif // V8_HEAP_HEAP_H_ | 2655 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |