Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: src/heap/heap.h

Issue 2895473003: [heap] Simplify and scale ResourceConstraints::ConfigureDefaults. (Closed)
Patch Set: rename Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | src/zone/accounting-allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 #if V8_OS_ANDROID 608 #if V8_OS_ANDROID
609 // Don't apply pointer multiplier on Android since it has no swap space and 609 // Don't apply pointer multiplier on Android since it has no swap space and
610 // should instead adapt it's heap size based on available physical memory. 610 // should instead adapt it's heap size based on available physical memory.
611 static const int kPointerMultiplier = 1; 611 static const int kPointerMultiplier = 1;
612 #else 612 #else
613 static const int kPointerMultiplier = i::kPointerSize / 4; 613 static const int kPointerMultiplier = i::kPointerSize / 4;
614 #endif 614 #endif
615 615
616 // The new space size has to be a power of 2. Sizes are in MB. 616 // The new space size has to be a power of 2. Sizes are in MB.
617 static const int kMaxSemiSpaceSizeLowMemoryDevice = 1 * kPointerMultiplier; 617 static const int kMinSemiSpaceSize = 1 * kPointerMultiplier;
618 static const int kMaxSemiSpaceSizeMediumMemoryDevice = 4 * kPointerMultiplier; 618 static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier;
619 static const int kMaxSemiSpaceSizeHighMemoryDevice = 8 * kPointerMultiplier;
620 static const int kMaxSemiSpaceSizeHugeMemoryDevice = 8 * kPointerMultiplier;
621 619
622 // The old space size has to be a multiple of Page::kPageSize. 620 // The old space size has to be a multiple of Page::kPageSize.
623 // Sizes are in MB. 621 // Sizes are in MB.
624 static const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kPointerMultiplier; 622 static const int kMinOldSpaceSize = 128 * kPointerMultiplier;
625 static const int kMaxOldSpaceSizeMediumMemoryDevice = 623 static const int kMaxOldSpaceSize = 1024 * kPointerMultiplier;
626 256 * kPointerMultiplier;
627 static const int kMaxOldSpaceSizeHighMemoryDevice = 512 * kPointerMultiplier;
628 static const int kMaxOldSpaceSizeHugeMemoryDevice = 1024 * kPointerMultiplier;
629 624
630 static const int kTraceRingBufferSize = 512; 625 static const int kTraceRingBufferSize = 512;
631 static const int kStacktraceBufferSize = 512; 626 static const int kStacktraceBufferSize = 512;
632 627
633 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; 628 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor;
634 V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor; 629 V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor;
635 static const double kMaxHeapGrowingFactorMemoryConstrained; 630 static const double kMaxHeapGrowingFactorMemoryConstrained;
636 static const double kMaxHeapGrowingFactorIdle; 631 static const double kMaxHeapGrowingFactorIdle;
637 static const double kConservativeHeapGrowingFactor; 632 static const double kConservativeHeapGrowingFactor;
638 static const double kTargetMutatorUtilization; 633 static const double kTargetMutatorUtilization;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 939
945 bool HasLowAllocationRate(); 940 bool HasLowAllocationRate();
946 bool HasHighFragmentation(); 941 bool HasHighFragmentation();
947 bool HasHighFragmentation(size_t used, size_t committed); 942 bool HasHighFragmentation(size_t used, size_t committed);
948 943
949 void ActivateMemoryReducerIfNeeded(); 944 void ActivateMemoryReducerIfNeeded();
950 945
951 bool ShouldOptimizeForMemoryUsage(); 946 bool ShouldOptimizeForMemoryUsage();
952 947
953 bool IsLowMemoryDevice() { 948 bool IsLowMemoryDevice() {
949 const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kPointerMultiplier;
954 return max_old_generation_size_ <= kMaxOldSpaceSizeLowMemoryDevice; 950 return max_old_generation_size_ <= kMaxOldSpaceSizeLowMemoryDevice;
955 } 951 }
956 952
957 bool IsMemoryConstrainedDevice() { 953 bool IsMemoryConstrainedDevice() {
954 const int kMaxOldSpaceSizeMediumMemoryDevice = 256 * kPointerMultiplier;
958 return max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice; 955 return max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice;
959 } 956 }
960 957
961 bool HighMemoryPressure() { 958 bool HighMemoryPressure() {
962 return memory_pressure_level_.Value() != MemoryPressureLevel::kNone; 959 return memory_pressure_level_.Value() != MemoryPressureLevel::kNone;
963 } 960 }
964 961
965 size_t HeapLimitForDebugging() { 962 size_t HeapLimitForDebugging() {
966 const size_t kDebugHeapSizeFactor = 4; 963 const size_t kDebugHeapSizeFactor = 4;
967 size_t max_limit = std::numeric_limits<size_t>::max() / 4; 964 size_t max_limit = std::numeric_limits<size_t>::max() / 4;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 // =========================================================================== 1337 // ===========================================================================
1341 1338
1342 // Returns the maximum amount of memory reserved for the heap. 1339 // Returns the maximum amount of memory reserved for the heap.
1343 size_t MaxReserved() { 1340 size_t MaxReserved() {
1344 return 2 * max_semi_space_size_ + max_old_generation_size_; 1341 return 2 * max_semi_space_size_ + max_old_generation_size_;
1345 } 1342 }
1346 size_t MaxSemiSpaceSize() { return max_semi_space_size_; } 1343 size_t MaxSemiSpaceSize() { return max_semi_space_size_; }
1347 size_t InitialSemiSpaceSize() { return initial_semispace_size_; } 1344 size_t InitialSemiSpaceSize() { return initial_semispace_size_; }
1348 size_t MaxOldGenerationSize() { return max_old_generation_size_; } 1345 size_t MaxOldGenerationSize() { return max_old_generation_size_; }
1349 1346
1347 static size_t ComputeMaxOldGenerationSize(uint64_t physical_memory) {
1348 const int old_space_physical_memory_factor = 4;
1349 int computed_size =
1350 static_cast<int>(physical_memory / i::MB /
1351 old_space_physical_memory_factor * kPointerMultiplier);
1352 return Max(Min(computed_size, kMaxOldSpaceSize), kMinOldSpaceSize);
1353 }
1354
1355 static size_t ComputeMaxSemiSpaceSize(uint64_t physical_memory) {
1356 const uint64_t min_physical_memory = 512 * MB;
1357 const uint64_t max_physical_memory = 2 * static_cast<uint64_t>(GB);
1358
1359 uint64_t capped_physical_memory =
1360 Max(Min(physical_memory, max_physical_memory), min_physical_memory);
1361 // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C
1362 return static_cast<int>(((capped_physical_memory - min_physical_memory) *
1363 (kMaxSemiSpaceSize - kMinSemiSpaceSize)) /
1364 (max_physical_memory - min_physical_memory) +
1365 kMinSemiSpaceSize);
1366 }
1367
1350 // Returns the capacity of the heap in bytes w/o growing. Heap grows when 1368 // Returns the capacity of the heap in bytes w/o growing. Heap grows when
1351 // more spaces are needed until it reaches the limit. 1369 // more spaces are needed until it reaches the limit.
1352 size_t Capacity(); 1370 size_t Capacity();
1353 1371
1354 // Returns the capacity of the old generation. 1372 // Returns the capacity of the old generation.
1355 size_t OldGenerationCapacity(); 1373 size_t OldGenerationCapacity();
1356 1374
1357 // Returns the amount of memory currently committed for the heap. 1375 // Returns the amount of memory currently committed for the heap.
1358 size_t CommittedMemory(); 1376 size_t CommittedMemory();
1359 1377
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 friend class PagedSpace; 2655 friend class PagedSpace;
2638 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); 2656 DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
2639 }; 2657 };
2640 2658
2641 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); 2659 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space);
2642 2660
2643 } // namespace internal 2661 } // namespace internal
2644 } // namespace v8 2662 } // namespace v8
2645 2663
2646 #endif // V8_HEAP_HEAP_H_ 2664 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/zone/accounting-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698