Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: src/api.cc

Issue 24269003: Add methods to enable configuration of ResourceConstraints based on limits derived at runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Move device-specific defaults into ConfigureResourceConstraintsForCurrentPlatform Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/d8.cc » ('j') | src/heap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « include/v8.h ('k') | src/d8.cc » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698