Revision: 13212
Author:   [email protected]
Date:     Wed Dec 12 07:26:04 2012
Log: Removed RuntimeProfilerRateLimiter class and RuntimeProfiler::IsSomeIsolateInJS.

Removing the former was basically a consequence of removing the latter. The net
effect is, apart from less code, that the signal sender thread is much more
explicit about its logic now.

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

Modified:
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/platform-cygwin.cc
 /branches/bleeding_edge/src/platform-freebsd.cc
 /branches/bleeding_edge/src/platform-linux.cc
 /branches/bleeding_edge/src/platform-macos.cc
 /branches/bleeding_edge/src/platform-openbsd.cc
 /branches/bleeding_edge/src/platform-solaris.cc
 /branches/bleeding_edge/src/platform-win32.cc
 /branches/bleeding_edge/src/runtime-profiler.cc
 /branches/bleeding_edge/src/runtime-profiler.h

=======================================
--- /branches/bleeding_edge/src/isolate.h       Mon Dec 10 03:09:12 2012
+++ /branches/bleeding_edge/src/isolate.h       Wed Dec 12 07:26:04 2012
@@ -1015,7 +1015,6 @@
         RuntimeProfiler::IsolateEnteredJS(this);
       } else if (current_state == JS && state != JS) {
         // JS -> non-JS transition.
-        ASSERT(RuntimeProfiler::IsSomeIsolateInJS());
         RuntimeProfiler::IsolateExitedJS(this);
       } else {
         // Other types of state transitions are not interesting to the
=======================================
--- /branches/bleeding_edge/src/platform-cygwin.cc      Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-cygwin.cc      Wed Dec 12 07:26:04 2012
@@ -660,7 +660,7 @@
       if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
       OS::Sleep(interval_);
     }
@@ -708,7 +708,6 @@
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-freebsd.cc     Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-freebsd.cc     Wed Dec 12 07:26:04 2012
@@ -767,7 +767,7 @@
       if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough.
     }
@@ -802,7 +802,6 @@
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-linux.cc       Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-linux.cc       Wed Dec 12 07:26:04 2012
@@ -1153,7 +1153,7 @@
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
         if (signal_handler_installed_) RestoreSignalHandler();
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough.
     }
@@ -1198,7 +1198,6 @@

   const int vm_tgid_;
   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-macos.cc       Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-macos.cc       Wed Dec 12 07:26:04 2012
@@ -792,7 +792,7 @@
       if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
       OS::Sleep(interval_);
     }
@@ -851,7 +851,6 @@
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-openbsd.cc     Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-openbsd.cc     Wed Dec 12 07:26:04 2012
@@ -846,7 +846,7 @@
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
         if (signal_handler_installed_) RestoreSignalHandler();
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough.
     }
@@ -882,7 +882,6 @@

   const int vm_tgid_;
   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc     Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-solaris.cc     Wed Dec 12 07:26:04 2012
@@ -762,7 +762,7 @@
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
         if (signal_handler_installed_) RestoreSignalHandler();
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough.
     }
@@ -797,7 +797,6 @@
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc       Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/platform-win32.cc       Wed Dec 12 07:26:04 2012
@@ -2015,7 +2015,7 @@
       if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
         SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
       } else {
-        if (rate_limiter_.SuspendIfNecessary()) continue;
+        if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue;
       }
       OS::Sleep(interval_);
     }
@@ -2063,7 +2063,6 @@
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
=======================================
--- /branches/bleeding_edge/src/runtime-profiler.cc     Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/runtime-profiler.cc     Wed Dec 12 07:26:04 2012
@@ -428,11 +428,6 @@
   NoBarrier_AtomicIncrement(&state_, 1);
   semaphore.Pointer()->Signal();
 }
-
-
-bool RuntimeProfiler::IsSomeIsolateInJS() {
-  return NoBarrier_Load(&state_) > 0;
-}


 bool RuntimeProfiler::WaitForSomeIsolateToEnterJS() {
@@ -482,14 +477,6 @@
     visitor->VisitPointer(&sampler_window_[i]);
   }
 }
-
-
-bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
-  if (!RuntimeProfiler::IsSomeIsolateInJS()) {
-    return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
-  }
-  return false;
-}


 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/runtime-profiler.h      Fri Dec  7 00:55:06 2012
+++ /branches/bleeding_edge/src/runtime-profiler.h      Wed Dec 12 07:26:04 2012
@@ -71,17 +71,12 @@

   // Profiler thread interface.
   //
-  // IsSomeIsolateInJS():
-  // The profiler thread can query whether some isolate is currently
-  // running JavaScript code.
-  //
   // WaitForSomeIsolateToEnterJS():
   // When no isolates are running JavaScript code for some time the
   // profiler thread suspends itself by calling the wait function. The
   // wait function returns true after it waited or false immediately.
   // While the function was waiting the profiler may have been
   // disabled so it *must check* whether it is allowed to continue.
-  static bool IsSomeIsolateInJS();
   static bool WaitForSomeIsolateToEnterJS();

   // Stops the runtime profiler thread when profiling support is being
@@ -134,24 +129,6 @@
 };


-// Rate limiter intended to be used in the profiler thread.
-class RuntimeProfilerRateLimiter BASE_EMBEDDED {
- public:
-  RuntimeProfilerRateLimiter() {}
-
-  // Suspends the current thread (which must be the profiler thread)
-  // when not executing JavaScript to minimize CPU usage. Returns
-  // whether the thread was suspended (and so must check whether
-  // profiling is still active.)
-  //
-  // Does nothing when runtime profiling is not enabled.
-  bool SuspendIfNecessary();
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(RuntimeProfilerRateLimiter);
-};
-
-
 // Implementation of RuntimeProfiler inline functions.

 void RuntimeProfiler::IsolateEnteredJS(Isolate* isolate) {

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to