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

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

Issue 1858143003: Get rid of UnsafeCurrent in Sampler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 8 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/isolate.h ('k') | src/profiler/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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_PROFILER_SAMPLER_H_ 5 #ifndef V8_PROFILER_SAMPLER_H_
6 #define V8_PROFILER_SAMPLER_H_ 6 #define V8_PROFILER_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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool IsProfiling() const { 85 bool IsProfiling() const {
86 return base::NoBarrier_Load(&profiling_) > 0 && 86 return base::NoBarrier_Load(&profiling_) > 0 &&
87 !base::NoBarrier_Load(&has_processing_thread_); 87 !base::NoBarrier_Load(&has_processing_thread_);
88 } 88 }
89 void IncreaseProfilingDepth(); 89 void IncreaseProfilingDepth();
90 void DecreaseProfilingDepth(); 90 void DecreaseProfilingDepth();
91 91
92 // Whether the sampler is running (that is, consumes resources). 92 // Whether the sampler is running (that is, consumes resources).
93 bool IsActive() const { return base::NoBarrier_Load(&active_); } 93 bool IsActive() const { return base::NoBarrier_Load(&active_); }
94 94
95 // CpuProfiler collects samples by calling DoSample directly
96 // without calling Start. To keep it working, we register the sampler
97 // with the CpuProfiler.
98 bool IsRegistered() const { return base::NoBarrier_Load(&registered_); }
99
95 void DoSample(); 100 void DoSample();
96 // If true next sample must be initiated on the profiler event processor 101 // If true next sample must be initiated on the profiler event processor
97 // thread right after latest sample is processed. 102 // thread right after latest sample is processed.
98 void SetHasProcessingThread(bool value) { 103 void SetHasProcessingThread(bool value) {
99 base::NoBarrier_Store(&has_processing_thread_, value); 104 base::NoBarrier_Store(&has_processing_thread_, value);
100 } 105 }
101 106
102 // Used in tests to make sure that stack sampling is performed. 107 // Used in tests to make sure that stack sampling is performed.
103 unsigned js_sample_count() const { return js_sample_count_; } 108 unsigned js_sample_count() const { return js_sample_count_; }
104 unsigned external_sample_count() const { return external_sample_count_; } 109 unsigned external_sample_count() const { return external_sample_count_; }
105 void StartCountingSamples() { 110 void StartCountingSamples() {
106 js_sample_count_ = 0; 111 js_sample_count_ = 0;
107 external_sample_count_ = 0; 112 external_sample_count_ = 0;
108 is_counting_samples_ = true; 113 is_counting_samples_ = true;
109 } 114 }
110 115
111 class PlatformData; 116 class PlatformData;
112 PlatformData* platform_data() const { return data_; } 117 PlatformData* platform_data() const { return data_; }
113 118
114 protected: 119 protected:
115 // This method is called for each sampling period with the current 120 // This method is called for each sampling period with the current
116 // program counter. 121 // program counter.
117 virtual void Tick(TickSample* sample) = 0; 122 virtual void Tick(TickSample* sample) = 0;
118 123
119 private: 124 private:
120 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); } 125 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); }
121 126
127 void SetRegistered(bool value) { base::NoBarrier_Store(&registered_, value); }
128
122 Isolate* isolate_; 129 Isolate* isolate_;
123 const int interval_; 130 const int interval_;
124 base::Atomic32 profiling_; 131 base::Atomic32 profiling_;
125 base::Atomic32 has_processing_thread_; 132 base::Atomic32 has_processing_thread_;
126 base::Atomic32 active_; 133 base::Atomic32 active_;
134 base::Atomic32 registered_;
127 PlatformData* data_; // Platform specific data. 135 PlatformData* data_; // Platform specific data.
128 // Counts stack samples taken in various VM states. 136 // Counts stack samples taken in various VM states.
129 bool is_counting_samples_; 137 bool is_counting_samples_;
130 unsigned js_sample_count_; 138 unsigned js_sample_count_;
131 unsigned external_sample_count_; 139 unsigned external_sample_count_;
132 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 140 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
133 }; 141 };
134 142
135 143
136 } // namespace internal 144 } // namespace internal
137 } // namespace v8 145 } // namespace v8
138 146
139 #endif // V8_PROFILER_SAMPLER_H_ 147 #endif // V8_PROFILER_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/profiler/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698