Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 0a38fa9f32b2b3e3932a178d756c80b44b1a0c1e..36491a4c1b0713102961bece3e235423f638163b 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -633,6 +633,41 @@ bool SetResourceConstraints(ResourceConstraints* constraints) { |
} |
+bool ConfigureResourceConstraintsForCurrentPlatform( |
Hannes Payer (out of office)
2013/09/24 11:27:17
We could also move the implementation in a separat
danno
2013/09/24 11:52:24
Yes, please put this in another file to make it cl
|
+ ResourceConstraints* constraints) { |
+ if (constraints == NULL) { |
+ return false; |
+ } |
+ |
+ // young_space_size should be a power of 2 and old_generation_size should be |
+ // a multiple of Page::kPageSize. |
+ uintptr_t physical_memory = i::OS::TotalPhysicalMemory(); |
+ uintptr_t lump_of_memory = i::kIs64BitArch ? 2 * i::MB : i::MB; |
+ 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"); |