Reviewers: Michael Starzinger,

Description:
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.


Please review this at https://chromiumcodereview.appspot.com/11543020/

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

Affected files:
  M src/isolate.h
  M src/platform-cygwin.cc
  src/platform-freebsd.cc
  M src/platform-linux.cc
  M src/platform-macos.cc
  M src/platform-openbsd.cc
  src/platform-solaris.cc
  M src/platform-win32.cc
  M src/runtime-profiler.h
  M src/runtime-profiler.cc


Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index ac2e554f85e5112b1a1d72efb0dfe7047eb20969..2ffe66994ca919761c0d91c886e9459a49c341ae 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -1015,7 +1015,6 @@ class Isolate {
         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
Index: src/platform-cygwin.cc
diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc
index 8c5e5b9083bb5a7931833eb69ca5782267dc32d9..3456d32a6e3b3e528d8b854f2d0ce4d540827421 100644
--- a/src/platform-cygwin.cc
+++ b/src/platform-cygwin.cc
@@ -660,7 +660,7 @@ class SamplerThread : public Thread {
       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 @@ class SamplerThread : public Thread {
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-freebsd.cc
diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
index d02d668422ca9171a5120ac4d67bf11f35082bae..cebdd1ed57f43f270727751685a75b4b9b1a0bb1 100644
--- a/src/platform-freebsd.cc
+++ b/src/platform-freebsd.cc
@@ -767,7 +767,7 @@ class SignalSender : public Thread {
       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 @@ class SignalSender : public Thread {
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index 7a186413b5f3c7c059fd9e09f50abd7490dbedbf..8022ba2d5af110ab24f155872736ed3d9a6b5f9d 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -1153,7 +1153,7 @@ class SignalSender : public Thread {
         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 @@ class SignalSender : public Thread {

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

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index e69833885cbaad2284feac6d93f7b32fa0573c98..20db4e4738433fba1794a9fd7c716896f71c7f8d 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -792,7 +792,7 @@ class SamplerThread : public Thread {
       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 @@ class SamplerThread : public Thread {
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-openbsd.cc
diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc
index d4ab9a66ee7e6c50b8f7ddedde0907b680265ade..48ca2e88008bab89f9d1ee187411e05193e063e9 100644
--- a/src/platform-openbsd.cc
+++ b/src/platform-openbsd.cc
@@ -846,7 +846,7 @@ class SignalSender : public Thread {
         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 @@ class SignalSender : public Thread {

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

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-solaris.cc
diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc
index 70f86596e838444e5e2481eab14b44496dd9fb7f..85a08d20568e2123eec3bab14bb98fac9d631cca 100644
--- a/src/platform-solaris.cc
+++ b/src/platform-solaris.cc
@@ -762,7 +762,7 @@ class SignalSender : public Thread {
         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 @@ class SignalSender : public Thread {
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index f00d6b01b256da75211592df4fd9d40c434bbe30..be0e31d68bfcebdd5d3595a826572fa2fcd434fe 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -2015,7 +2015,7 @@ class SamplerThread : public Thread {
       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 @@ class SamplerThread : public Thread {
   }

   const int interval_;
-  RuntimeProfilerRateLimiter rate_limiter_;

   // Protects the process wide state below.
   static Mutex* mutex_;
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index 262cd1d582de28735d0458249eddd3d70743dd2d..94a56509077320cfd83756d6c4e7e01e808f00fa 100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -430,11 +430,6 @@ void RuntimeProfiler::HandleWakeUp(Isolate* isolate) {
 }


-bool RuntimeProfiler::IsSomeIsolateInJS() {
-  return NoBarrier_Load(&state_) > 0;
-}
-
-
 bool RuntimeProfiler::WaitForSomeIsolateToEnterJS() {
   Atomic32 old_state = NoBarrier_CompareAndSwap(&state_, 0, -1);
   ASSERT(old_state >= -1);
@@ -484,12 +479,4 @@ void RuntimeProfiler::UpdateSamplesAfterCompact(ObjectVisitor* visitor) {
 }


-bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
-  if (!RuntimeProfiler::IsSomeIsolateInJS()) {
-    return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
-  }
-  return false;
-}
-
-
 } }  // namespace v8::internal
Index: src/runtime-profiler.h
diff --git a/src/runtime-profiler.h b/src/runtime-profiler.h
index 507535f0b4d38e3e0c87e97064eec7f4979077be..62c48c7a49bdfb49350eefb636c3d44371324c9b 100644
--- a/src/runtime-profiler.h
+++ b/src/runtime-profiler.h
@@ -71,17 +71,12 @@ class RuntimeProfiler {

   // 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 @@ class RuntimeProfiler {
 };


-// 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