Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 0a38fa9f32b2b3e3932a178d756c80b44b1a0c1e..0bed005feef1b9fb61490f78ab89e1ab21cbcb53 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -633,6 +633,44 @@ bool SetResourceConstraints(ResourceConstraints* constraints) { |
| } |
| +bool ConfigureResourceConstraintsForCurrentPlatform( |
|
Hannes Payer (out of office)
2013/09/24 07:31:00
We had another discussion about that function righ
rmcilroy
2013/09/24 10:50:55
Done. Kept the implementation here in api.cc thou
|
| + ResourceConstraints* constraints) { |
| + if (constraints == NULL) { |
| + return false; |
| + } |
| + |
|
Hannes Payer (out of office)
2013/09/24 07:31:00
Please add a comment which specifies the given con
rmcilroy
2013/09/24 10:50:55
Done.
|
| +#if V8_TARGET_ARCH_X64 |
| + uintptr_t lump_of_memory = i::Max(2 * i::MB, i::Page::kPageSize); |
| +#else |
| + uintptr_t lump_of_memory = i::Max(i::MB, i::Page::kPageSize); |
| +#endif |
| + |
| + uintptr_t physical_memory = i::OS::TotalPhysicalMemory(); |
| + if (physical_memory > 2ul * i::GB) { |
| + constraints->set_max_young_space_size(8 * lump_of_memory); |
| + constraints->set_max_old_space_size(700 * lump_of_memory); |
| + constraints->set_max_executable_size(256 * lump_of_memory); |
| + } else if (physical_memory > 512ul * i::MB) { |
| + constraints->set_max_young_space_size(4 * lump_of_memory); |
| + constraints->set_max_old_space_size(192 * lump_of_memory); |
| + constraints->set_max_executable_size(192 * lump_of_memory); |
| + } else /* (physical_memory <= 512GB) */ { |
| + constraints->set_max_young_space_size(1 * lump_of_memory); |
| + constraints->set_max_old_space_size(96 * lump_of_memory); |
| + constraints->set_max_executable_size(96 * lump_of_memory); |
| + } |
| + return true; |
| +} |
| + |
| + |
| +bool SetDefaultResourceConstraintsForCurrentPlatform() { |
| + ResourceConstraints constraints; |
| + if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) |
| + return false; |
| + return SetResourceConstraints(&constraints); |
| +} |
| + |
| + |
| i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
| LOG_API(isolate, "Persistent::New"); |