OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LIBSAMPLER_SAMPLER_H_ | 5 #ifndef V8_LIBSAMPLER_SAMPLER_H_ |
6 #define V8_LIBSAMPLER_SAMPLER_H_ | 6 #define V8_LIBSAMPLER_SAMPLER_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 | 9 |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // Whether the sampling thread should use this Sampler for CPU profiling? | 47 // Whether the sampling thread should use this Sampler for CPU profiling? |
48 bool IsProfiling() const { | 48 bool IsProfiling() const { |
49 return base::NoBarrier_Load(&profiling_) > 0 && | 49 return base::NoBarrier_Load(&profiling_) > 0 && |
50 !base::NoBarrier_Load(&has_processing_thread_); | 50 !base::NoBarrier_Load(&has_processing_thread_); |
51 } | 51 } |
52 void IncreaseProfilingDepth(); | 52 void IncreaseProfilingDepth(); |
53 void DecreaseProfilingDepth(); | 53 void DecreaseProfilingDepth(); |
54 | 54 |
55 // Whether the sampler is running (that is, consumes resources). | 55 // Whether the sampler is running (that is, consumes resources). |
56 bool IsActive() const { return base::NoBarrier_Load(&active_); } | 56 bool IsActive() const { return base::NoBarrier_Load(&active_) != 0; } |
57 | 57 |
58 // CpuProfiler collects samples by calling DoSample directly | 58 // CpuProfiler collects samples by calling DoSample directly |
59 // without calling Start. To keep it working, we register the sampler | 59 // without calling Start. To keep it working, we register the sampler |
60 // with the CpuProfiler. | 60 // with the CpuProfiler. |
61 bool IsRegistered() const { return base::NoBarrier_Load(®istered_); } | 61 bool IsRegistered() const { return base::NoBarrier_Load(®istered_) != 0; } |
62 | 62 |
63 void DoSample(); | 63 void DoSample(); |
64 | 64 |
65 void SetHasProcessingThread(bool value) { | 65 void SetHasProcessingThread(bool value) { |
66 base::NoBarrier_Store(&has_processing_thread_, value); | 66 base::NoBarrier_Store(&has_processing_thread_, value); |
67 } | 67 } |
68 | 68 |
69 // Used in tests to make sure that stack sampling is performed. | 69 // Used in tests to make sure that stack sampling is performed. |
70 unsigned js_sample_count() const { return js_sample_count_; } | 70 unsigned js_sample_count() const { return js_sample_count_; } |
71 unsigned external_sample_count() const { return external_sample_count_; } | 71 unsigned external_sample_count() const { return external_sample_count_; } |
(...skipping 22 matching lines...) Expand all Loading... |
94 base::Atomic32 active_; | 94 base::Atomic32 active_; |
95 base::Atomic32 registered_; | 95 base::Atomic32 registered_; |
96 PlatformData* data_; // Platform specific data. | 96 PlatformData* data_; // Platform specific data. |
97 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace sampler | 100 } // namespace sampler |
101 } // namespace v8 | 101 } // namespace v8 |
102 | 102 |
103 #endif // V8_LIBSAMPLER_SAMPLER_H_ | 103 #endif // V8_LIBSAMPLER_SAMPLER_H_ |
OLD | NEW |