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

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

Issue 1897673002: Revert of Get rid of UnsafeCurrent in Sampler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
100 void DoSample(); 95 void DoSample();
101 // If true next sample must be initiated on the profiler event processor 96 // If true next sample must be initiated on the profiler event processor
102 // thread right after latest sample is processed. 97 // thread right after latest sample is processed.
103 void SetHasProcessingThread(bool value) { 98 void SetHasProcessingThread(bool value) {
104 base::NoBarrier_Store(&has_processing_thread_, value); 99 base::NoBarrier_Store(&has_processing_thread_, value);
105 } 100 }
106 101
107 // Used in tests to make sure that stack sampling is performed. 102 // Used in tests to make sure that stack sampling is performed.
108 unsigned js_sample_count() const { return js_sample_count_; } 103 unsigned js_sample_count() const { return js_sample_count_; }
109 unsigned external_sample_count() const { return external_sample_count_; } 104 unsigned external_sample_count() const { return external_sample_count_; }
110 void StartCountingSamples() { 105 void StartCountingSamples() {
111 js_sample_count_ = 0; 106 js_sample_count_ = 0;
112 external_sample_count_ = 0; 107 external_sample_count_ = 0;
113 is_counting_samples_ = true; 108 is_counting_samples_ = true;
114 } 109 }
115 110
116 class PlatformData; 111 class PlatformData;
117 PlatformData* platform_data() const { return data_; } 112 PlatformData* platform_data() const { return data_; }
118 113
119 protected: 114 protected:
120 // This method is called for each sampling period with the current 115 // This method is called for each sampling period with the current
121 // program counter. 116 // program counter.
122 virtual void Tick(TickSample* sample) = 0; 117 virtual void Tick(TickSample* sample) = 0;
123 118
124 private: 119 private:
125 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); } 120 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); }
126 121
127 void SetRegistered(bool value) { base::NoBarrier_Store(&registered_, value); }
128
129 Isolate* isolate_; 122 Isolate* isolate_;
130 const int interval_; 123 const int interval_;
131 base::Atomic32 profiling_; 124 base::Atomic32 profiling_;
132 base::Atomic32 has_processing_thread_; 125 base::Atomic32 has_processing_thread_;
133 base::Atomic32 active_; 126 base::Atomic32 active_;
134 base::Atomic32 registered_;
135 PlatformData* data_; // Platform specific data. 127 PlatformData* data_; // Platform specific data.
136 // Counts stack samples taken in various VM states. 128 // Counts stack samples taken in various VM states.
137 bool is_counting_samples_; 129 bool is_counting_samples_;
138 unsigned js_sample_count_; 130 unsigned js_sample_count_;
139 unsigned external_sample_count_; 131 unsigned external_sample_count_;
140 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 132 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
141 }; 133 };
142 134
143 135
144 } // namespace internal 136 } // namespace internal
145 } // namespace v8 137 } // namespace v8
146 138
147 #endif // V8_PROFILER_SAMPLER_H_ 139 #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