| 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_H_ | 5 #ifndef V8_HEAP_H_ |
| 6 #define V8_HEAP_H_ | 6 #define V8_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "allocation.h" | 10 #include "allocation.h" |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 539 |
| 540 | 540 |
| 541 enum ArrayStorageAllocationMode { | 541 enum ArrayStorageAllocationMode { |
| 542 DONT_INITIALIZE_ARRAY_ELEMENTS, | 542 DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 543 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 543 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
| 544 }; | 544 }; |
| 545 | 545 |
| 546 | 546 |
| 547 class Heap { | 547 class Heap { |
| 548 public: | 548 public: |
| 549 // Configure heap size before setup. Return false if the heap has been | 549 // Configure heap size in MB before setup. Return false if the heap has been |
| 550 // set up already. | 550 // set up already. |
| 551 bool ConfigureHeap(int max_semispace_size, | 551 bool ConfigureHeap(int max_semispace_size, |
| 552 intptr_t max_old_space_size, | 552 int max_old_space_size, |
| 553 intptr_t max_executable_size, | 553 int max_executable_size, |
| 554 intptr_t code_range_size); | 554 int code_range_size); |
| 555 bool ConfigureHeapDefault(); | 555 bool ConfigureHeapDefault(); |
| 556 | 556 |
| 557 // Prepares the heap, setting up memory areas that are needed in the isolate | 557 // Prepares the heap, setting up memory areas that are needed in the isolate |
| 558 // without actually creating any objects. | 558 // without actually creating any objects. |
| 559 bool SetUp(); | 559 bool SetUp(); |
| 560 | 560 |
| 561 // Bootstraps the object heap with the core set of objects required to run. | 561 // Bootstraps the object heap with the core set of objects required to run. |
| 562 // Returns whether it succeeded. | 562 // Returns whether it succeeded. |
| 563 bool CreateHeapObjects(); | 563 bool CreateHeapObjects(); |
| 564 | 564 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 return old_generation_allocation_limit_ - PromotedTotalSize(); | 1065 return old_generation_allocation_limit_ - PromotedTotalSize(); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 inline intptr_t OldGenerationCapacityAvailable() { | 1068 inline intptr_t OldGenerationCapacityAvailable() { |
| 1069 return max_old_generation_size_ - PromotedTotalSize(); | 1069 return max_old_generation_size_ - PromotedTotalSize(); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 static const intptr_t kMinimumOldGenerationAllocationLimit = | 1072 static const intptr_t kMinimumOldGenerationAllocationLimit = |
| 1073 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | 1073 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
| 1074 | 1074 |
| 1075 static const int kLumpOfMemory = (i::kPointerSize / 4) * i::MB; | 1075 static const int kPointerMultiplier = i::kPointerSize / 4; |
| 1076 | 1076 |
| 1077 // The new space size has to be a power of 2. | 1077 // The new space size has to be a power of 2. Sizes are in MB. |
| 1078 static const int kMaxNewSpaceSizeLowMemoryDevice = 2 * kLumpOfMemory; | 1078 static const int kMaxSemiSpaceSizeLowMemoryDevice = |
| 1079 static const int kMaxNewSpaceSizeMediumMemoryDevice = 8 * kLumpOfMemory; | 1079 1 * kPointerMultiplier; |
| 1080 static const int kMaxNewSpaceSizeHighMemoryDevice = 16 * kLumpOfMemory; | 1080 static const int kMaxSemiSpaceSizeMediumMemoryDevice = |
| 1081 static const int kMaxNewSpaceSizeHugeMemoryDevice = 16 * kLumpOfMemory; | 1081 4 * kPointerMultiplier; |
| 1082 static const int kMaxSemiSpaceSizeHighMemoryDevice = |
| 1083 8 * kPointerMultiplier; |
| 1084 static const int kMaxSemiSpaceSizeHugeMemoryDevice = |
| 1085 8 * kPointerMultiplier; |
| 1082 | 1086 |
| 1083 // The old space size has to be a multiple of Page::kPageSize. | 1087 // The old space size has to be a multiple of Page::kPageSize. |
| 1084 static const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kLumpOfMemory; | 1088 // Sizes are in MB. |
| 1085 static const int kMaxOldSpaceSizeMediumMemoryDevice = 256 * kLumpOfMemory; | 1089 static const int kMaxOldSpaceSizeLowMemoryDevice = |
| 1086 static const int kMaxOldSpaceSizeHighMemoryDevice = 512 * kLumpOfMemory; | 1090 128 * kPointerMultiplier; |
| 1087 static const int kMaxOldSpaceSizeHugeMemoryDevice = 700 * kLumpOfMemory; | 1091 static const int kMaxOldSpaceSizeMediumMemoryDevice = |
| 1092 256 * kPointerMultiplier; |
| 1093 static const int kMaxOldSpaceSizeHighMemoryDevice = |
| 1094 512 * kPointerMultiplier; |
| 1095 static const int kMaxOldSpaceSizeHugeMemoryDevice = |
| 1096 700 * kPointerMultiplier; |
| 1088 | 1097 |
| 1089 // The executable size has to be a multiple of Page::kPageSize. | 1098 // The executable size has to be a multiple of Page::kPageSize. |
| 1090 static const int kMaxExecutableSizeLowMemoryDevice = 128 * kLumpOfMemory; | 1099 // Sizes are in MB. |
| 1091 static const int kMaxExecutableSizeMediumMemoryDevice = 256 * kLumpOfMemory; | 1100 static const int kMaxExecutableSizeLowMemoryDevice = |
| 1092 static const int kMaxExecutableSizeHighMemoryDevice = 512 * kLumpOfMemory; | 1101 128 * kPointerMultiplier; |
| 1093 static const int kMaxExecutableSizeHugeMemoryDevice = 700 * kLumpOfMemory; | 1102 static const int kMaxExecutableSizeMediumMemoryDevice = |
| 1103 256 * kPointerMultiplier; |
| 1104 static const int kMaxExecutableSizeHighMemoryDevice = |
| 1105 512 * kPointerMultiplier; |
| 1106 static const int kMaxExecutableSizeHugeMemoryDevice = |
| 1107 700 * kPointerMultiplier; |
| 1094 | 1108 |
| 1095 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { | 1109 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { |
| 1096 intptr_t limit = FLAG_stress_compaction | 1110 intptr_t limit = FLAG_stress_compaction |
| 1097 ? old_gen_size + old_gen_size / 10 | 1111 ? old_gen_size + old_gen_size / 10 |
| 1098 : old_gen_size * old_space_growing_factor_; | 1112 : old_gen_size * old_space_growing_factor_; |
| 1099 limit = Max(limit, kMinimumOldGenerationAllocationLimit); | 1113 limit = Max(limit, kMinimumOldGenerationAllocationLimit); |
| 1100 limit += new_space_.Capacity(); | 1114 limit += new_space_.Capacity(); |
| 1101 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 1115 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 1102 return Min(limit, halfway_to_the_max); | 1116 return Min(limit, halfway_to_the_max); |
| 1103 } | 1117 } |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2821 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2808 | 2822 |
| 2809 private: | 2823 private: |
| 2810 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2824 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2811 }; | 2825 }; |
| 2812 #endif // DEBUG | 2826 #endif // DEBUG |
| 2813 | 2827 |
| 2814 } } // namespace v8::internal | 2828 } } // namespace v8::internal |
| 2815 | 2829 |
| 2816 #endif // V8_HEAP_H_ | 2830 #endif // V8_HEAP_H_ |
| OLD | NEW |