uint64_t virtual_memory_limit,
uint32_t number_of_processors);
- int max_young_space_size() const { return max_young_space_size_; }
- void set_max_young_space_size(int value) { max_young_space_size_ = value; }
+ int max_new_space_size() const { return max_new_space_size_; }
+ void set_max_new_space_size(int value) { max_new_space_size_ = value; }
int max_old_space_size() const { return max_old_space_size_; }
void set_max_old_space_size(int value) { max_old_space_size_ = value; }
int max_executable_size() const { return max_executable_size_; }
}
private:
- int max_young_space_size_;
+ int max_new_space_size_;
int max_old_space_size_;
int max_executable_size_;
uint32_t* stack_limit_;
ResourceConstraints::ResourceConstraints()
- : max_young_space_size_(0),
+ : max_new_space_size_(0),
max_old_space_size_(0),
max_executable_size_(0),
stack_limit_(NULL),
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit,
uint32_t number_of_processors) {
- const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
#if V8_OS_ANDROID
// Android has higher physical memory requirements before raising the maximum
// heap size limits since it has no swap space.
const uint64_t high_limit = 1ul * i::GB;
#endif
- // The young_space_size should be a power of 2 and old_generation_size should
- // be a multiple of Page::kPageSize.
if (physical_memory <= low_limit) {
- set_max_young_space_size(2 * lump_of_memory);
- set_max_old_space_size(128 * lump_of_memory);
- set_max_executable_size(96 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeLowMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice);
} else if (physical_memory <= medium_limit) {
- set_max_young_space_size(8 * lump_of_memory);
- set_max_old_space_size(256 * lump_of_memory);
- set_max_executable_size(192 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeMediumMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice);
} else if (physical_memory <= high_limit) {
- set_max_young_space_size(16 * lump_of_memory);
- set_max_old_space_size(512 * lump_of_memory);
- set_max_executable_size(256 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHighMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice);
} else {
- set_max_young_space_size(16 * lump_of_memory);
- set_max_old_space_size(700 * lump_of_memory);
- set_max_executable_size(256 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHugeMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice);
}
set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
bool SetResourceConstraints(Isolate* v8_isolate,
ResourceConstraints* constraints) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
- int young_space_size = constraints->max_young_space_size();
+ int new_space_size = constraints->max_new_space_size();
int old_gen_size = constraints->max_old_space_size();
int max_executable_size = constraints->max_executable_size();
int code_range_size = constraints->code_range_size();
- if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 ||
+ if (new_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 ||
code_range_size != 0) {
// After initialization it's too late to change Heap constraints.
ASSERT(!isolate->IsInitialized());
- bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
+ bool result = isolate->heap()->ConfigureHeap(new_space_size / 2,
old_gen_size,
max_executable_size,
code_range_size);
// Will be 4 * reserved_semispace_size_ to ensure that young
// generation can be aligned to its size.
maximum_committed_(0),
+ old_space_growing_factor_(4),
survived_since_last_expansion_(0),
sweep_generation_(0),
always_allocate_scope_depth_(0),
code_range_size_ = code_range_size;
+ // We set the old generation growing factor to 2 to grow the heap slower on
+ // memory-constrained devices.
+ if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice) {
+ old_space_growing_factor_ = 2;
+ }
+
configured_ = true;
return true;
}
static const intptr_t kMinimumOldGenerationAllocationLimit =
8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
+ static const int kLumpOfMemory = (i::kPointerSize / 4) * i::MB;
+
+ // The new space size has to be a power of 2.
+ static const int kMaxNewSpaceSizeLowMemoryDevice = 2 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeMediumMemoryDevice = 8 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeHighMemoryDevice = 16 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeHugeMemoryDevice = 16 * kLumpOfMemory;
+
+ // The old space size has to be a multiple of Page::kPageSize.
+ static const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kLumpOfMemory;
+ static const int kMaxOldSpaceSizeMediumMemoryDevice = 256 * kLumpOfMemory;
+ static const int kMaxOldSpaceSizeHighMemoryDevice = 512 * kLumpOfMemory;
+ static const int kMaxOldSpaceSizeHugeMemoryDevice = 700 * kLumpOfMemory;
+
+ // The executable size has to be a multiple of Page::kPageSize.
+ static const int kMaxExecutableSizeLowMemoryDevice = 128 * kLumpOfMemory;
+ static const int kMaxExecutableSizeMediumMemoryDevice = 256 * kLumpOfMemory;
+ static const int kMaxExecutableSizeHighMemoryDevice = 512 * kLumpOfMemory;
+ static const int kMaxExecutableSizeHugeMemoryDevice = 700 * kLumpOfMemory;
+
intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) {
- intptr_t limit = FLAG_stress_compaction ?
- old_gen_size + old_gen_size / 10 : old_gen_size * 4;
+ intptr_t limit = FLAG_stress_compaction
+ ? old_gen_size + old_gen_size / 10
+ : old_gen_size * old_space_growing_factor_;
limit = Max(limit, kMinimumOldGenerationAllocationLimit);
limit += new_space_.Capacity();
intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
intptr_t max_executable_size_;
intptr_t maximum_committed_;
+ // The old space growing factor is used in the old space heap growing
+ // strategy. The new old space size is the current old space size times
+ // old_space_growing_factor_.
+ int old_space_growing_factor_;
+
// For keeping track of how much data has survived
// scavenge since last new space expansion.
int survived_since_last_expansion_;
case SetResourceConstraints: {
static const int K = 1024;
v8::ResourceConstraints constraints;
- constraints.set_max_young_space_size(256 * K);
+ constraints.set_max_new_space_size(256 * K);
constraints.set_max_old_space_size(4 * K * K);
v8::SetResourceConstraints(CcTest::isolate(), &constraints);
break;
// Set heap limits.
static const int K = 1024;
v8::ResourceConstraints constraints;
- constraints.set_max_young_space_size(256 * K);
+ constraints.set_max_new_space_size(256 * K);
constraints.set_max_old_space_size(4 * K * K);
v8::SetResourceConstraints(CcTest::isolate(), &constraints);