Commit 34b534c9 authored by jochen@chromium.org's avatar jochen@chromium.org

Add a proper way to pass the number of processors to V8

BUG=321060
LOG=n
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/73463004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17874 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 37443768
......@@ -3809,8 +3809,13 @@ class V8_EXPORT ResourceConstraints {
*
* \param physical_memory The total amount of physical memory on the current
* device, in bytes.
* \param number_of_processors The number of CPUs available on the current
* device.
*/
void ConfigureDefaults(uint64_t physical_memory);
void ConfigureDefaults(uint64_t physical_memory,
uint32_t number_of_processors);
V8_DEPRECATED("Will be removed",
void ConfigureDefaults(uint64_t physical_memory));
int max_young_space_size() const { return max_young_space_size_; }
void set_max_young_space_size(int value) { max_young_space_size_ = value; }
......
......@@ -566,8 +566,8 @@ ResourceConstraints::ResourceConstraints()
stack_limit_(NULL),
max_available_threads_(0) { }
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
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
......@@ -601,7 +601,12 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
set_max_executable_size(256 * lump_of_memory);
}
set_max_available_threads(0);
set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
}
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
ConfigureDefaults(physical_memory, i::CPU::NumberOfProcessorsOnline());
}
......
......@@ -62,6 +62,7 @@
#ifndef V8_SHARED
#include "api.h"
#include "checks.h"
#include "cpu.h"
#include "d8-debug.h"
#include "debug.h"
#include "natives.h"
......@@ -1709,7 +1710,8 @@ int Shell::Main(int argc, char* argv[]) {
Isolate* isolate = Isolate::GetCurrent();
#ifndef V8_SHARED
v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory());
constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(),
i::CPU::NumberOfProcessorsOnline());
v8::SetResourceConstraints(isolate, &constraints);
#endif
DumbLineEditor dumb_line_editor(isolate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment