 Chromium Code Reviews
 Chromium Code Reviews Issue 2942543002:
  [heap] Allow a minimum semi-space size of 512K.  (Closed)
    
  
    Issue 2942543002:
  [heap] Allow a minimum semi-space size of 512K.  (Closed) 
  | 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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 static const int kInitalOldGenerationLimitFactor = 2; | 611 static const int kInitalOldGenerationLimitFactor = 2; | 
| 612 | 612 | 
| 613 #if V8_OS_ANDROID | 613 #if V8_OS_ANDROID | 
| 614 // Don't apply pointer multiplier on Android since it has no swap space and | 614 // Don't apply pointer multiplier on Android since it has no swap space and | 
| 615 // should instead adapt it's heap size based on available physical memory. | 615 // should instead adapt it's heap size based on available physical memory. | 
| 616 static const int kPointerMultiplier = 1; | 616 static const int kPointerMultiplier = 1; | 
| 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 // Semi-space size needs to be a multiple of page size. | 
| 622 static const int kMinSemiSpaceSize = 1 * kPointerMultiplier; | 622 static const int kMinSemiSpaceSizeInKB = | 
| 623 static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier; | 623 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); | 
| 624 static const int kMaxSemiSpaceSizeInKB = | |
| 625 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); | |
| 624 | 626 | 
| 625 // The old space size has to be a multiple of Page::kPageSize. | 627 // The old space size has to be a multiple of Page::kPageSize. | 
| 626 // Sizes are in MB. | 628 // Sizes are in MB. | 
| 627 static const int kMinOldGenerationSize = 128 * kPointerMultiplier; | 629 static const int kMinOldGenerationSize = 128 * kPointerMultiplier; | 
| 628 static const int kMaxOldGenerationSize = 1024 * kPointerMultiplier; | 630 static const int kMaxOldGenerationSize = 1024 * kPointerMultiplier; | 
| 629 | 631 | 
| 630 static const int kTraceRingBufferSize = 512; | 632 static const int kTraceRingBufferSize = 512; | 
| 631 static const int kStacktraceBufferSize = 512; | 633 static const int kStacktraceBufferSize = 512; | 
| 632 | 634 | 
| 633 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; | 635 V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; | 
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 } | 969 } | 
| 968 | 970 | 
| 969 bool IsHeapLimitIncreasedForDebugging() { | 971 bool IsHeapLimitIncreasedForDebugging() { | 
| 970 return max_old_generation_size_ == HeapLimitForDebugging(); | 972 return max_old_generation_size_ == HeapLimitForDebugging(); | 
| 971 } | 973 } | 
| 972 | 974 | 
| 973 // =========================================================================== | 975 // =========================================================================== | 
| 974 // Initialization. =========================================================== | 976 // Initialization. =========================================================== | 
| 975 // =========================================================================== | 977 // =========================================================================== | 
| 976 | 978 | 
| 977 // Configure heap size in MB before setup. Return false if the heap has been | 979 // Configure heap sizes | 
| 978 // set up already. | 980 // max_semi_space_size_in_kb: maximum semi-space size in KB | 
| 979 bool ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size, | 981 // max_old_generation_size_in_mb: maximum old generation size in MB | 
| 980 size_t code_range_size); | 982 // code_range_size_in_mb: code range size in MB | 
| 983 // Return false if the heap has been set up already. | |
| 984 bool ConfigureHeap(size_t max_semi_space_size_in_kb, | |
| 985 size_t max_old_generation_size_in_mb, | |
| 986 size_t code_range_size_in_mb); | |
| 981 bool ConfigureHeapDefault(); | 987 bool ConfigureHeapDefault(); | 
| 982 | 988 | 
| 983 // Prepares the heap, setting up memory areas that are needed in the isolate | 989 // Prepares the heap, setting up memory areas that are needed in the isolate | 
| 984 // without actually creating any objects. | 990 // without actually creating any objects. | 
| 985 bool SetUp(); | 991 bool SetUp(); | 
| 986 | 992 | 
| 987 // Bootstraps the object heap with the core set of objects required to run. | 993 // Bootstraps the object heap with the core set of objects required to run. | 
| 988 // Returns whether it succeeded. | 994 // Returns whether it succeeded. | 
| 989 bool CreateHeapObjects(); | 995 bool CreateHeapObjects(); | 
| 990 | 996 | 
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 kMinOldGenerationSize); | 1352 kMinOldGenerationSize); | 
| 1347 } | 1353 } | 
| 1348 | 1354 | 
| 1349 static size_t ComputeMaxSemiSpaceSize(uint64_t physical_memory) { | 1355 static size_t ComputeMaxSemiSpaceSize(uint64_t physical_memory) { | 
| 1350 const uint64_t min_physical_memory = 512 * MB; | 1356 const uint64_t min_physical_memory = 512 * MB; | 
| 1351 const uint64_t max_physical_memory = 2 * static_cast<uint64_t>(GB); | 1357 const uint64_t max_physical_memory = 2 * static_cast<uint64_t>(GB); | 
| 1352 | 1358 | 
| 1353 uint64_t capped_physical_memory = | 1359 uint64_t capped_physical_memory = | 
| 1354 Max(Min(physical_memory, max_physical_memory), min_physical_memory); | 1360 Max(Min(physical_memory, max_physical_memory), min_physical_memory); | 
| 1355 // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C | 1361 // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C | 
| 1356 return static_cast<int>(((capped_physical_memory - min_physical_memory) * | 1362 int semi_space_size_in_kb = | 
| 1357 (kMaxSemiSpaceSize - kMinSemiSpaceSize)) / | 1363 static_cast<int>(((capped_physical_memory - min_physical_memory) * | 
| 1358 (max_physical_memory - min_physical_memory) + | 1364 (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / | 
| 1359 kMinSemiSpaceSize); | 1365 (max_physical_memory - min_physical_memory) + | 
| 1366 kMinSemiSpaceSizeInKB); | |
| 1367 return RoundUp(semi_space_size_in_kb, (1 << kPageSizeBits) / 1024); | |
| 
Michael Lippautz
2017/06/14 07:25:08
nit: KB
 
Hannes Payer (out of office)
2017/06/14 07:57:02
Done.
 | |
| 1360 } | 1368 } | 
| 1361 | 1369 | 
| 1362 // Returns the capacity of the heap in bytes w/o growing. Heap grows when | 1370 // Returns the capacity of the heap in bytes w/o growing. Heap grows when | 
| 1363 // more spaces are needed until it reaches the limit. | 1371 // more spaces are needed until it reaches the limit. | 
| 1364 size_t Capacity(); | 1372 size_t Capacity(); | 
| 1365 | 1373 | 
| 1366 // Returns the capacity of the old generation. | 1374 // Returns the capacity of the old generation. | 
| 1367 size_t OldGenerationCapacity(); | 1375 size_t OldGenerationCapacity(); | 
| 1368 | 1376 | 
| 1369 // Returns the amount of memory currently committed for the heap. | 1377 // Returns the amount of memory currently committed for the heap. | 
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2650 friend class PagedSpace; | 2658 friend class PagedSpace; | 
| 2651 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2659 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 
| 2652 }; | 2660 }; | 
| 2653 | 2661 | 
| 2654 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 2662 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 
| 2655 | 2663 | 
| 2656 } // namespace internal | 2664 } // namespace internal | 
| 2657 } // namespace v8 | 2665 } // namespace v8 | 
| 2658 | 2666 | 
| 2659 #endif // V8_HEAP_HEAP_H_ | 2667 #endif // V8_HEAP_HEAP_H_ | 
| OLD | NEW |