From 47cca4684e18c928d5d32b290b4c1314ac156953 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 15 Apr 2015 00:15:52 -0700 Subject: [PATCH] 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} --- include/v8.h | 14 ++++++++++---- src/api.cc | 9 +++++---- src/d8.cc | 3 +-- src/heap/heap.cc | 3 +-- src/isolate.cc | 11 +---------- src/isolate.h | 1 - src/optimizing-compile-dispatcher.h | 4 +--- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/include/v8.h b/include/v8.h index d8ef81e66..e32c104d4 100644 --- a/include/v8.h +++ b/include/v8.h @@ -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_; } diff --git a/src/api.cc b/src/api.cc index 5be9daf52..14d3a823e 100644 --- a/src/api.cc +++ b/src/api.cc @@ -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(constraints.stack_limit()); isolate->stack_guard()->SetStackLimit(limit); } - - isolate->set_max_available_threads(constraints.max_available_threads()); } diff --git a/src/d8.cc b/src/d8.cc index 38a4b8ec1..f5f1b4041 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -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) { diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 192c9804d..3da4dd758 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -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); diff --git a/src/isolate.cc b/src/isolate.cc index 9a9403a79..978c52ec2 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -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); } diff --git a/src/isolate.h b/src/isolate.h index 85d25ed93..56a546197 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -386,7 +386,6 @@ typedef List 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) \ diff --git a/src/optimizing-compile-dispatcher.h b/src/optimizing-compile-dispatcher.h index 822bb40b3..ad09dfa73 100644 --- a/src/optimizing-compile-dispatcher.h +++ b/src/optimizing-compile-dispatcher.h @@ -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; -- 2.34.1