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

Side by Side Diff: src/libsampler/sampler.h

Issue 2912773002: Rename "NoBarrier" memory operations to "Relaxed". (Closed)
Patch Set: comment Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/libplatform/tracing/tracing-controller.cc ('k') | src/libsampler/sampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 28 matching lines...) Expand all
39 // Clients should override this method in order to do something on samples, 39 // Clients should override this method in order to do something on samples,
40 // for example buffer samples in a queue. 40 // for example buffer samples in a queue.
41 virtual void SampleStack(const v8::RegisterState& regs) = 0; 41 virtual void SampleStack(const v8::RegisterState& regs) = 0;
42 42
43 // Start and stop sampler. 43 // Start and stop sampler.
44 void Start(); 44 void Start();
45 void Stop(); 45 void Stop();
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::Relaxed_Load(&profiling_) > 0 &&
50 !base::NoBarrier_Load(&has_processing_thread_); 50 !base::Relaxed_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_) != 0; } 56 bool IsActive() const { return base::Relaxed_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(&registered_) != 0; } 61 bool IsRegistered() const { return base::Relaxed_Load(&registered_) != 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::Relaxed_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_; }
72 void StartCountingSamples() { 72 void StartCountingSamples() {
73 js_sample_count_ = 0; 73 js_sample_count_ = 0;
74 external_sample_count_ = 0; 74 external_sample_count_ = 0;
75 is_counting_samples_ = true; 75 is_counting_samples_ = true;
76 } 76 }
77 77
78 class PlatformData; 78 class PlatformData;
79 PlatformData* platform_data() const { return data_; } 79 PlatformData* platform_data() const { return data_; }
80 80
81 protected: 81 protected:
82 // Counts stack samples taken in various VM states. 82 // Counts stack samples taken in various VM states.
83 bool is_counting_samples_; 83 bool is_counting_samples_;
84 unsigned js_sample_count_; 84 unsigned js_sample_count_;
85 unsigned external_sample_count_; 85 unsigned external_sample_count_;
86 86
87 private: 87 private:
88 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); } 88 void SetActive(bool value) { base::Relaxed_Store(&active_, value); }
89 void SetRegistered(bool value) { base::NoBarrier_Store(&registered_, value); } 89 void SetRegistered(bool value) { base::Relaxed_Store(&registered_, value); }
90 90
91 Isolate* isolate_; 91 Isolate* isolate_;
92 base::Atomic32 profiling_; 92 base::Atomic32 profiling_;
93 base::Atomic32 has_processing_thread_; 93 base::Atomic32 has_processing_thread_;
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_
OLDNEW
« no previous file with comments | « src/libplatform/tracing/tracing-controller.cc ('k') | src/libsampler/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698