Revision: 21501
Author:   [email protected]
Date:     Mon May 26 15:18:45 2014 UTC
Log:      Move NumberOfProcessorsOnline from CPU to OS

It's really more an OS-level information, and this way the default
platform doesn't depend on CPU-level details

BUG=none
[email protected]
LOG=n

Review URL: https://codereview.chromium.org/300713002
http://code.google.com/p/v8/source/detail?r=21501

Modified:
 /branches/bleeding_edge/src/cpu.cc
 /branches/bleeding_edge/src/cpu.h
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/libplatform/default-platform.cc
 /branches/bleeding_edge/src/platform-posix.cc
 /branches/bleeding_edge/src/platform-win32.cc
 /branches/bleeding_edge/src/platform.h
 /branches/bleeding_edge/test/cctest/test-cpu.cc

=======================================
--- /branches/bleeding_edge/src/cpu.cc  Tue May 13 09:55:26 2014 UTC
+++ /branches/bleeding_edge/src/cpu.cc  Mon May 26 15:18:45 2014 UTC
@@ -495,17 +495,5 @@

 #endif
 }
-
-
-// static
-int CPU::NumberOfProcessorsOnline() {
-#if V8_OS_WIN
-  SYSTEM_INFO info;
-  GetSystemInfo(&info);
-  return info.dwNumberOfProcessors;
-#else
-  return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
-#endif
-}

 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/cpu.h   Fri May  9 12:51:52 2014 UTC
+++ /branches/bleeding_edge/src/cpu.h   Mon May 26 15:18:45 2014 UTC
@@ -76,9 +76,6 @@
   bool has_vfp() const { return has_vfp_; }
   bool has_vfp3() const { return has_vfp3_; }
   bool has_vfp3_d32() const { return has_vfp3_d32_; }
-
-  // Returns the number of processors online.
-  static int NumberOfProcessorsOnline();

   // Flush instruction cache.
   static void FlushICache(void* start, size_t size);
=======================================
--- /branches/bleeding_edge/src/d8.cc   Mon May 26 13:31:55 2014 UTC
+++ /branches/bleeding_edge/src/d8.cc   Mon May 26 15:18:45 2014 UTC
@@ -1476,7 +1476,7 @@
   v8::ResourceConstraints constraints;
   constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(),
                                 i::OS::MaxVirtualMemory(),
-                                i::CPU::NumberOfProcessorsOnline());
+                                i::OS::NumberOfProcessorsOnline());
   v8::SetResourceConstraints(isolate, &constraints);
 #endif
   DumbLineEditor dumb_line_editor(isolate);
=======================================
--- /branches/bleeding_edge/src/isolate.cc      Mon May 26 08:05:04 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc      Mon May 26 15:18:45 2014 UTC
@@ -1900,7 +1900,7 @@
// 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(CPU::NumberOfProcessorsOnline(), 4), 1); + max_available_threads_ = Max(Min(OS::NumberOfProcessorsOnline(), 4), 1);
   }

   if (!FLAG_job_based_sweeping) {
=======================================
--- /branches/bleeding_edge/src/libplatform/default-platform.cc Tue Apr 29 06:42:26 2014 UTC +++ /branches/bleeding_edge/src/libplatform/default-platform.cc Mon May 26 15:18:45 2014 UTC
@@ -9,8 +9,7 @@

 // TODO(jochen): We should have our own version of checks.h.
 #include "../checks.h"
-// TODO(jochen): Why is cpu.h not in platform/?
-#include "../cpu.h"
+#include "../platform.h"
 #include "worker-thread.h"

 namespace v8 {
@@ -40,7 +39,7 @@
   LockGuard<Mutex> guard(&lock_);
   ASSERT(thread_pool_size >= 0);
   if (thread_pool_size < 1)
-    thread_pool_size = CPU::NumberOfProcessorsOnline();
+    thread_pool_size = OS::NumberOfProcessorsOnline();
   thread_pool_size_ =
       std::max(std::min(thread_pool_size, kMaxThreadPoolSize), 1);
 }
=======================================
--- /branches/bleeding_edge/src/platform-posix.cc Fri May 23 16:37:27 2014 UTC +++ /branches/bleeding_edge/src/platform-posix.cc Mon May 26 15:18:45 2014 UTC
@@ -55,6 +55,11 @@
 unsigned OS::CpuFeaturesImpliedByPlatform() {
   return 0;  // Nothing special.
 }
+
+
+int OS::NumberOfProcessorsOnline() {
+  return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
+}


 // Maximum size of the virtual memory.  0 means there is no artificial
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc Fri May 23 16:37:27 2014 UTC +++ /branches/bleeding_edge/src/platform-win32.cc Mon May 26 15:18:45 2014 UTC
@@ -1194,6 +1194,13 @@
 unsigned OS::CpuFeaturesImpliedByPlatform() {
   return 0;  // Windows runs on anything.
 }
+
+
+int OS::NumberOfProcessorsOnline() {
+  SYSTEM_INFO info;
+  GetSystemInfo(&info);
+  return info.dwNumberOfProcessors;
+}


 double OS::nan_value() {
=======================================
--- /branches/bleeding_edge/src/platform.h      Mon May 26 11:28:08 2014 UTC
+++ /branches/bleeding_edge/src/platform.h      Mon May 26 15:18:45 2014 UTC
@@ -274,6 +274,9 @@
// positions indicated by the members of the CpuFeature enum from globals.h
   static unsigned CpuFeaturesImpliedByPlatform();

+  // Returns the number of processors online.
+  static int NumberOfProcessorsOnline();
+
   // The total amount of physical memory available on the current system.
   static uint64_t TotalPhysicalMemory();

=======================================
--- /branches/bleeding_edge/test/cctest/test-cpu.cc Wed Aug 28 12:32:56 2013 UTC +++ /branches/bleeding_edge/test/cctest/test-cpu.cc Mon May 26 15:18:45 2014 UTC
@@ -51,5 +51,5 @@


 TEST(NumberOfProcessorsOnline) {
-  CHECK_GT(CPU::NumberOfProcessorsOnline(), 0);
+  CHECK_GT(OS::NumberOfProcessorsOnline(), 0);
 }

--
--
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/d/optout.

Reply via email to