Remove support for specifying the number of available threads

The embedder can control how many threads it wants to use via the
v8::Platform implementation. V8 internally doesn't spin up threads
anymore. If the embedder doesn't want to use any threads at all, it's
v8::Platform implementation must either run the background jobs on
the foreground thread, or the embedder should specify --predictable

BUG=none
R=yangguo@chromium.org
LOG=y

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

Cr-Commit-Position: refs/heads/master@{#27833}
This commit is contained in:
jochen 2015-04-15 00:15:52 -07:00 committed by Commit bot
parent ac23150fd2
commit 47cca4684e
7 changed files with 19 additions and 26 deletions

View File

@ -4682,9 +4682,11 @@ class V8_EXPORT ResourceConstraints {
* device, in bytes.
* \param virtual_memory_limit The amount of virtual memory on the current
* device, in bytes, or zero, if there is no limit.
* \param number_of_processors The number of CPUs available on the current
* device.
*/
void ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit);
// Deprecated, will be removed soon.
void ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit,
uint32_t number_of_processors);
@ -4698,9 +4700,13 @@ class V8_EXPORT ResourceConstraints {
uint32_t* stack_limit() const { return stack_limit_; }
// Sets an address beyond which the VM's stack may not grow.
void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
int max_available_threads() const { return max_available_threads_; }
V8_DEPRECATE_SOON("Unused, will be removed",
int max_available_threads() const) {
return max_available_threads_;
}
// Set the number of threads available to V8, assuming at least 1.
void set_max_available_threads(int value) {
V8_DEPRECATE_SOON("Unused, will be removed",
void set_max_available_threads(int value)) {
max_available_threads_ = value;
}
size_t code_range_size() const { return code_range_size_; }

View File

@ -444,6 +444,11 @@ ResourceConstraints::ResourceConstraints()
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit,
uint32_t number_of_processors) {
ConfigureDefaults(physical_memory, virtual_memory_limit);
}
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit) {
#if V8_OS_ANDROID
// Android has higher physical memory requirements before raising the maximum
// heap size limits since it has no swap space.
@ -474,8 +479,6 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice);
}
set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
if (virtual_memory_limit > 0 && i::kRequiresCodeRange) {
// Reserve no more than 1/8 of the memory for the code range, but at most
// kMaximalCodeRangeSize.
@ -501,8 +504,6 @@ void SetResourceConstraints(i::Isolate* isolate,
uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit());
isolate->stack_guard()->SetStackLimit(limit);
}
isolate->set_max_available_threads(constraints.max_available_threads());
}

View File

@ -1638,8 +1638,7 @@ int Shell::Main(int argc, char* argv[]) {
#ifndef V8_SHARED
create_params.constraints.ConfigureDefaults(
base::SysInfo::AmountOfPhysicalMemory(),
base::SysInfo::AmountOfVirtualMemory(),
base::SysInfo::NumberOfProcessors());
base::SysInfo::AmountOfVirtualMemory());
Shell::counter_map_ = new CounterMap();
if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {

View File

@ -5271,8 +5271,7 @@ bool Heap::SetUp() {
if (!ConfigureHeapDefault()) return false;
}
concurrent_sweeping_enabled_ =
FLAG_concurrent_sweeping && isolate_->max_available_threads() > 1;
concurrent_sweeping_enabled_ = FLAG_concurrent_sweeping;
base::CallOnce(&initialize_gc_once, &InitializeGCOnce);

View File

@ -2122,18 +2122,9 @@ bool Isolate::Init(Deserializer* des) {
set_event_logger(Logger::DefaultEventLoggerSentinel);
}
// Set default value if not yet set.
// TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults
// once ResourceConstraints becomes an argument to the Isolate constructor.
if (max_available_threads_ < 1) {
// Choose the default between 1 and 4.
max_available_threads_ =
Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1);
}
if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
PrintF("Concurrent recompilation has been disabled for tracing.\n");
} else if (OptimizingCompileDispatcher::Enabled(max_available_threads_)) {
} else if (OptimizingCompileDispatcher::Enabled()) {
optimizing_compile_dispatcher_ = new OptimizingCompileDispatcher(this);
}

View File

@ -386,7 +386,6 @@ typedef List<HeapObject*> DebugObjectCache;
V(HTracer*, htracer, NULL) \
V(CodeTracer*, code_tracer, NULL) \
V(bool, fp_stubs_generated, false) \
V(int, max_available_threads, 0) \
V(uint32_t, per_isolate_assert_data, 0xFFFFFFFFu) \
V(PromiseRejectCallback, promise_reject_callback, NULL) \
V(const v8::StartupData*, snapshot_blob, NULL) \

View File

@ -70,9 +70,7 @@ class OptimizingCompileDispatcher {
AddToOsrBuffer(NULL);
}
static bool Enabled(int max_available) {
return (FLAG_concurrent_recompilation && max_available > 1);
}
static bool Enabled() { return FLAG_concurrent_recompilation; }
private:
class CompileTask;