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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 #else | 617 #else |
618 static const int kPointerMultiplier = i::kPointerSize / 4; | 618 static const int kPointerMultiplier = i::kPointerSize / 4; |
619 #endif | 619 #endif |
620 | 620 |
621 // The new space size has to be a power of 2. Sizes are in MB. | 621 // The new space size has to be a power of 2. Sizes are in MB. |
622 static const int kMinSemiSpaceSize = 1 * kPointerMultiplier; | 622 static const int kMinSemiSpaceSize = 1 * kPointerMultiplier; |
623 static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier; | 623 static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier; |
624 | 624 |
625 // The old space size has to be a multiple of Page::kPageSize. | 625 // The old space size has to be a multiple of Page::kPageSize. |
626 // Sizes are in MB. | 626 // Sizes are in MB. |
627 static const int kMinOldSpaceSize = 128 * kPointerMultiplier; | 627 static const int kMinOldGenerationSize = 128 * kPointerMultiplier; |
628 static const int kMaxOldSpaceSize = 1024 * kPointerMultiplier; | 628 static const int kMaxOldGenerationSize = 1024 * kPointerMultiplier; |
629 | 629 |
630 static const int kTraceRingBufferSize = 512; | 630 static const int kTraceRingBufferSize = 512; |
631 static const int kStacktraceBufferSize = 512; | 631 static const int kStacktraceBufferSize = 512; |
632 | 632 |
633 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; | 633 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; |
634 V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor; | 634 V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor; |
635 static const double kMaxHeapGrowingFactorMemoryConstrained; | 635 static const double kMaxHeapGrowingFactorMemoryConstrained; |
636 static const double kMaxHeapGrowingFactorIdle; | 636 static const double kMaxHeapGrowingFactorIdle; |
637 static const double kConservativeHeapGrowingFactor; | 637 static const double kConservativeHeapGrowingFactor; |
638 static const double kTargetMutatorUtilization; | 638 static const double kTargetMutatorUtilization; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 case SCAVENGER: | 709 case SCAVENGER: |
710 return "Scavenger"; | 710 return "Scavenger"; |
711 case MARK_COMPACTOR: | 711 case MARK_COMPACTOR: |
712 return "Mark-Compact"; | 712 return "Mark-Compact"; |
713 case MINOR_MARK_COMPACTOR: | 713 case MINOR_MARK_COMPACTOR: |
714 return "Minor Mark-Compact"; | 714 return "Minor Mark-Compact"; |
715 } | 715 } |
716 return "Unknown collector"; | 716 return "Unknown collector"; |
717 } | 717 } |
718 | 718 |
| 719 V8_EXPORT_PRIVATE static double MaxHeapGrowingFactor( |
| 720 size_t max_old_generation_size); |
719 V8_EXPORT_PRIVATE static double HeapGrowingFactor(double gc_speed, | 721 V8_EXPORT_PRIVATE static double HeapGrowingFactor(double gc_speed, |
720 double mutator_speed); | 722 double mutator_speed, |
| 723 double max_factor); |
721 | 724 |
722 // Copy block of memory from src to dst. Size of block should be aligned | 725 // Copy block of memory from src to dst. Size of block should be aligned |
723 // by pointer size. | 726 // by pointer size. |
724 static inline void CopyBlock(Address dst, Address src, int byte_size); | 727 static inline void CopyBlock(Address dst, Address src, int byte_size); |
725 | 728 |
726 // Determines a static visitor id based on the given {map} that can then be | 729 // Determines a static visitor id based on the given {map} that can then be |
727 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. | 730 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. |
728 static int GetStaticVisitorIdForMap(Map* map); | 731 static int GetStaticVisitorIdForMap(Map* map); |
729 | 732 |
730 // Notifies the heap that is ok to start marking or other activities that | 733 // Notifies the heap that is ok to start marking or other activities that |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 bool deserialization_complete() const { return deserialization_complete_; } | 935 bool deserialization_complete() const { return deserialization_complete_; } |
933 | 936 |
934 bool HasLowAllocationRate(); | 937 bool HasLowAllocationRate(); |
935 bool HasHighFragmentation(); | 938 bool HasHighFragmentation(); |
936 bool HasHighFragmentation(size_t used, size_t committed); | 939 bool HasHighFragmentation(size_t used, size_t committed); |
937 | 940 |
938 void ActivateMemoryReducerIfNeeded(); | 941 void ActivateMemoryReducerIfNeeded(); |
939 | 942 |
940 bool ShouldOptimizeForMemoryUsage(); | 943 bool ShouldOptimizeForMemoryUsage(); |
941 | 944 |
942 bool IsLowMemoryDevice() { | |
943 const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kPointerMultiplier; | |
944 return max_old_generation_size_ <= kMaxOldSpaceSizeLowMemoryDevice; | |
945 } | |
946 | |
947 bool IsMemoryConstrainedDevice() { | |
948 const int kMaxOldSpaceSizeMediumMemoryDevice = 256 * kPointerMultiplier; | |
949 return max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice; | |
950 } | |
951 | |
952 bool HighMemoryPressure() { | 945 bool HighMemoryPressure() { |
953 return memory_pressure_level_.Value() != MemoryPressureLevel::kNone; | 946 return memory_pressure_level_.Value() != MemoryPressureLevel::kNone; |
954 } | 947 } |
955 | 948 |
956 size_t HeapLimitForDebugging() { | 949 size_t HeapLimitForDebugging() { |
957 const size_t kDebugHeapSizeFactor = 4; | 950 const size_t kDebugHeapSizeFactor = 4; |
958 size_t max_limit = std::numeric_limits<size_t>::max() / 4; | 951 size_t max_limit = std::numeric_limits<size_t>::max() / 4; |
959 return Min(max_limit, | 952 return Min(max_limit, |
960 initial_max_old_generation_size_ * kDebugHeapSizeFactor); | 953 initial_max_old_generation_size_ * kDebugHeapSizeFactor); |
961 } | 954 } |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 } | 1335 } |
1343 size_t MaxSemiSpaceSize() { return max_semi_space_size_; } | 1336 size_t MaxSemiSpaceSize() { return max_semi_space_size_; } |
1344 size_t InitialSemiSpaceSize() { return initial_semispace_size_; } | 1337 size_t InitialSemiSpaceSize() { return initial_semispace_size_; } |
1345 size_t MaxOldGenerationSize() { return max_old_generation_size_; } | 1338 size_t MaxOldGenerationSize() { return max_old_generation_size_; } |
1346 | 1339 |
1347 static size_t ComputeMaxOldGenerationSize(uint64_t physical_memory) { | 1340 static size_t ComputeMaxOldGenerationSize(uint64_t physical_memory) { |
1348 const int old_space_physical_memory_factor = 4; | 1341 const int old_space_physical_memory_factor = 4; |
1349 int computed_size = | 1342 int computed_size = |
1350 static_cast<int>(physical_memory / i::MB / | 1343 static_cast<int>(physical_memory / i::MB / |
1351 old_space_physical_memory_factor * kPointerMultiplier); | 1344 old_space_physical_memory_factor * kPointerMultiplier); |
1352 return Max(Min(computed_size, kMaxOldSpaceSize), kMinOldSpaceSize); | 1345 return Max(Min(computed_size, kMaxOldGenerationSize), |
| 1346 kMinOldGenerationSize); |
1353 } | 1347 } |
1354 | 1348 |
1355 static size_t ComputeMaxSemiSpaceSize(uint64_t physical_memory) { | 1349 static size_t ComputeMaxSemiSpaceSize(uint64_t physical_memory) { |
1356 const uint64_t min_physical_memory = 512 * MB; | 1350 const uint64_t min_physical_memory = 512 * MB; |
1357 const uint64_t max_physical_memory = 2 * static_cast<uint64_t>(GB); | 1351 const uint64_t max_physical_memory = 2 * static_cast<uint64_t>(GB); |
1358 | 1352 |
1359 uint64_t capped_physical_memory = | 1353 uint64_t capped_physical_memory = |
1360 Max(Min(physical_memory, max_physical_memory), min_physical_memory); | 1354 Max(Min(physical_memory, max_physical_memory), min_physical_memory); |
1361 // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C | 1355 // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C |
1362 return static_cast<int>(((capped_physical_memory - min_physical_memory) * | 1356 return static_cast<int>(((capped_physical_memory - min_physical_memory) * |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 friend class PagedSpace; | 2658 friend class PagedSpace; |
2665 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2659 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2666 }; | 2660 }; |
2667 | 2661 |
2668 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 2662 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
2669 | 2663 |
2670 } // namespace internal | 2664 } // namespace internal |
2671 } // namespace v8 | 2665 } // namespace v8 |
2672 | 2666 |
2673 #endif // V8_HEAP_HEAP_H_ | 2667 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |