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
This commit is contained in:
parent
facad070e9
commit
23d681c50b
@ -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
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user