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

Unified Diff: src/api.cc

Issue 228923002: Allow the embedder to pass the virtual memory limit to v8 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 8 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
« include/v8.h ('K') | « include/v8.h ('k') | src/d8.cc » ('j') | no next file with comments »
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 944c1996d86636043d5da674c7fe1de37251ff04..2b53bebcab00566ed6f61b8ff4a368f343cf099c 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -464,9 +464,11 @@ ResourceConstraints::ResourceConstraints()
max_old_space_size_(0),
max_executable_size_(0),
stack_limit_(NULL),
- max_available_threads_(0) { }
+ max_available_threads_(0),
+ code_range_size_(0) { }
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
@@ -502,6 +504,13 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
}
set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
+
+ if (virtual_memory_limit > 0 && i::kIs64BitArch) {
+ // Reserve no more than 1/8 of the memory for the code range, but at most
+ // 512 MB.
+ set_code_range_size(
+ i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3)));
+ }
}
@@ -511,12 +520,15 @@ bool SetResourceConstraints(Isolate* v8_isolate,
int young_space_size = constraints->max_young_space_size();
int old_gen_size = constraints->max_old_space_size();
int max_executable_size = constraints->max_executable_size();
- if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
+ int code_range_size = constraints->code_range_size();
+ if (young_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,
old_gen_size,
- max_executable_size);
+ max_executable_size,
+ code_range_size);
if (!result) return false;
}
if (constraints->stack_limit() != NULL) {
« include/v8.h ('K') | « include/v8.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698