Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: src/platform.h

Issue 11231002: Perform CPU sampling by CPU sampling thread only iff processing thread is not running. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform.h
diff --git a/src/platform.h b/src/platform.h
index 5a403aab9149a78162347bcb9592f184909abd28..4a5a2e147672c37bea1bc3551b87d1b130386cc0 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -755,10 +755,26 @@ class Sampler {
void Start();
void Stop();
- // Is the sampler used for profiling?
- bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
- void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
- void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
+ // Whether the sampling thread should use this Sampler for CPU profiling?
+ bool IsProfiling() const {
+ return NoBarrier_Load(&profiling_) > 0 &&
+ !NoBarrier_Load(&has_processing_thread_);
+ }
+ // Perform platform-specific initialization before DoSample() may be involed.
Jakob Kummerow 2012/10/19 15:56:42 typo: invoked
+ void StartSampling();
+ // Perform platform-specific cleanup after samping.
+ void StopSampling();
+ void IncreaseProfilingDepth() {
+ if (NoBarrier_AtomicIncrement(&profiling_, 1) == 1)
+ StartSampling();
Jakob Kummerow 2012/10/19 15:56:42 nit: {} please
+ }
+ void DecreaseProfilingDepth() {
+ if (!NoBarrier_AtomicIncrement(&profiling_, -1))
+ StopSampling();
Jakob Kummerow 2012/10/19 15:56:42 nit: {} please
+ }
+ void SetHasProcessingThread(bool value) {
+ NoBarrier_Store(&has_processing_thread_, value);
+ }
// Whether the sampler is running (that is, consumes resources).
bool IsActive() const { return NoBarrier_Load(&active_); }
@@ -785,6 +801,7 @@ class Sampler {
const int interval_;
Atomic32 profiling_;
Atomic32 active_;
+ Atomic32 has_processing_thread_;
PlatformData* data_; // Platform specific data.
int samples_taken_; // Counts stack samples taken.
DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
« no previous file with comments | « src/cpu-profiler.cc ('k') | src/platform-cygwin.cc » ('j') | src/platform-cygwin.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698