Chromium Code Reviews| Index: src/platform.h |
| diff --git a/src/platform.h b/src/platform.h |
| index 56ac61dc7b6352a7323710daf5fd2c7445d28ef4..c52679259b6ed57fa39957e44d3259e64443808e 100644 |
| --- a/src/platform.h |
| +++ b/src/platform.h |
| @@ -766,10 +766,17 @@ 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_); |
| + } |
| + void IncreaseProfilingDepth() { |
| + if (NoBarrier_AtomicIncrement(&profiling_, 1) == 1) StartProfiling(); |
| + } |
| + void DecreaseProfilingDepth() { |
| + if (!NoBarrier_AtomicIncrement(&profiling_, -1)) StopProfiling(); |
| + } |
| // Whether the sampler is running (that is, consumes resources). |
| bool IsActive() const { return NoBarrier_Load(&active_); } |
| @@ -785,6 +792,14 @@ class Sampler { |
| PlatformData* platform_data() { return data_; } |
| + // If true next sample must be initiated on the profiler event processor |
| + // thread right after latest sample is processed. |
| + static bool CanSampleOnProflerEventsProcessorThread(); |
|
Jakob Kummerow
2013/02/21 13:32:17
s/Profler/Profiler/
yurys
2013/02/21 13:45:40
Done.
|
| + void DoSample(); |
| + void SetHasProcessingThread(bool value) { |
| + NoBarrier_Store(&has_processing_thread_, value); |
| + } |
| + |
| protected: |
| virtual void DoSampleStack(TickSample* sample) = 0; |
| @@ -792,9 +807,15 @@ class Sampler { |
| void SetActive(bool value) { NoBarrier_Store(&active_, value); } |
| void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; } |
| + // Perform platform-specific initialization before DoSample() may be invoked. |
| + void StartProfiling(); |
| + // Perform platform-specific cleanup after profiling. |
| + void StopProfiling(); |
| + |
| Isolate* isolate_; |
| const int interval_; |
| Atomic32 profiling_; |
| + Atomic32 has_processing_thread_; |
| Atomic32 active_; |
| PlatformData* data_; // Platform specific data. |
| int samples_taken_; // Counts stack samples taken. |