Reviewers: Sven Panne,

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

BUG=321060
LOG=n
[email protected]

Please review this at https://codereview.chromium.org/73463004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -5 lines):
  M include/v8.h
  M src/api.cc
  M src/d8.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 195505854a839afe749c17923468b960e1ab0582..821ac38aef1285ed2cb1e1948817876f15da8c67 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3810,8 +3810,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; }
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 7966e2c57c95d0a987db6c15f302e3417ae22895..bd617da2f14ce168715e6055f16ddcdcbe76e6cf 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -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,13 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
     set_max_executable_size(256 * lump_of_memory);
   }

-  set_max_available_threads(0);
+  set_max_available_threads(
+      number_of_processors ? number_of_processors - 1 : 0);
+}
+
+
+void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
+  ConfigureDefaults(physical_memory, 0);
 }


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index eaec7d3c3f4d7021ac82a03bea5f57fb5b5ca9db..339cc327bd9bbf3f9d8c7c1f63e97fb4944c058d 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -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);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to