Remove support for specifying the number of available threads
authorjochen <jochen@chromium.org>
Wed, 15 Apr 2015 07:15:52 +0000 (00:15 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 15 Apr 2015 07:15:43 +0000 (07:15 +0000)
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
src/api.cc
src/d8.cc
src/heap/heap.cc
src/isolate.cc
src/isolate.h
src/optimizing-compile-dispatcher.h

index d8ef81e66facbc9db67efdf714a0a8a31aeef8ae..e32c104d484a7675a7e4700278390fa70a432d49 100644 (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_; }
index 5be9daf525cd8a32fb17b83648622653d13c8ad8..14d3a823ebf637a75322e464704085812ab6dcb5 100644 (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());
 }
 
 
index 38a4b8ec1a104cae465c7b75b898699c19589687..f5f1b4041b9e2a26ae16479d366c7f7fb75ec630 100644 (file)
--- 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) {
index 192c9804d4821c9cdf83e32c57660dd3e2f6182a..3da4dd7586446480d11cc7d8b11d4754f6c94a70 100644 (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);
 
index 9a9403a79f660441347df4f2349e2bfa59827551..978c52ec2a7d9953f2bda54c6e1a9a9e428fc736 100644 (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);
   }
 
index 85d25ed93e782894abb701a9b6f2bd367c07ee01..56a546197877008ba036636b8aa6f8209a5f3146 100644 (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)                               \
index 822bb40b317ee753dc30619d236fbc54190b9f23..ad09dfa734be336e791aef8f6360dbe642f3439a 100644 (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;