From: svenpanne@chromium.org Date: Wed, 12 Dec 2012 15:26:04 +0000 (+0000) Subject: Removed RuntimeProfilerRateLimiter class and RuntimeProfiler::IsSomeIsolateInJS. X-Git-Tag: upstream/4.7.83~15438 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23d681c50bb621a1cad3bd6ac0414f522784fa93;p=platform%2Fupstream%2Fv8.git 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 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13212 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/isolate.h b/src/isolate.h index ac2e554..2ffe669 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 diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc index 8c5e5b9..3456d32 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_; diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc index d02d668..cebdd1e 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_; diff --git a/src/platform-linux.cc b/src/platform-linux.cc index 7a18641..8022ba2 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_; diff --git a/src/platform-macos.cc b/src/platform-macos.cc index e698338..20db4e4 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_; diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc index d4ab9a6..48ca2e8 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_; diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc index 70f8659..85a08d2 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_; diff --git a/src/platform-win32.cc b/src/platform-win32.cc index f00d6b0..be0e31d 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_; diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc index 262cd1d..94a5650 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 diff --git a/src/runtime-profiler.h b/src/runtime-profiler.h index 507535f..62c48c7 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) {