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

Side by Side Diff: src/sampler.h

Issue 316133002: Move atomic ops and related files to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime-profiler.h ('k') | src/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_SAMPLER_H_ 5 #ifndef V8_SAMPLER_H_
6 #define V8_SAMPLER_H_ 6 #define V8_SAMPLER_H_
7 7
8 #include "src/atomicops.h" 8 #include "src/base/atomicops.h"
9 #include "src/frames.h" 9 #include "src/frames.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 class Isolate; 15 class Isolate;
16 16
17 // ---------------------------------------------------------------------------- 17 // ----------------------------------------------------------------------------
18 // Sampler 18 // Sampler
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // Performs stack sampling. 68 // Performs stack sampling.
69 void SampleStack(const RegisterState& regs); 69 void SampleStack(const RegisterState& regs);
70 70
71 // Start and stop sampler. 71 // Start and stop sampler.
72 void Start(); 72 void Start();
73 void Stop(); 73 void Stop();
74 74
75 // Whether the sampling thread should use this Sampler for CPU profiling? 75 // Whether the sampling thread should use this Sampler for CPU profiling?
76 bool IsProfiling() const { 76 bool IsProfiling() const {
77 return NoBarrier_Load(&profiling_) > 0 && 77 return base::NoBarrier_Load(&profiling_) > 0 &&
78 !NoBarrier_Load(&has_processing_thread_); 78 !base::NoBarrier_Load(&has_processing_thread_);
79 } 79 }
80 void IncreaseProfilingDepth(); 80 void IncreaseProfilingDepth();
81 void DecreaseProfilingDepth(); 81 void DecreaseProfilingDepth();
82 82
83 // Whether the sampler is running (that is, consumes resources). 83 // Whether the sampler is running (that is, consumes resources).
84 bool IsActive() const { return NoBarrier_Load(&active_); } 84 bool IsActive() const { return base::NoBarrier_Load(&active_); }
85 85
86 void DoSample(); 86 void DoSample();
87 // If true next sample must be initiated on the profiler event processor 87 // If true next sample must be initiated on the profiler event processor
88 // thread right after latest sample is processed. 88 // thread right after latest sample is processed.
89 void SetHasProcessingThread(bool value) { 89 void SetHasProcessingThread(bool value) {
90 NoBarrier_Store(&has_processing_thread_, value); 90 base::NoBarrier_Store(&has_processing_thread_, value);
91 } 91 }
92 92
93 // Used in tests to make sure that stack sampling is performed. 93 // Used in tests to make sure that stack sampling is performed.
94 unsigned js_and_external_sample_count() const { 94 unsigned js_and_external_sample_count() const {
95 return js_and_external_sample_count_; 95 return js_and_external_sample_count_;
96 } 96 }
97 void StartCountingSamples() { 97 void StartCountingSamples() {
98 is_counting_samples_ = true; 98 is_counting_samples_ = true;
99 js_and_external_sample_count_ = 0; 99 js_and_external_sample_count_ = 0;
100 } 100 }
101 101
102 class PlatformData; 102 class PlatformData;
103 PlatformData* platform_data() const { return data_; } 103 PlatformData* platform_data() const { return data_; }
104 104
105 protected: 105 protected:
106 // This method is called for each sampling period with the current 106 // This method is called for each sampling period with the current
107 // program counter. 107 // program counter.
108 virtual void Tick(TickSample* sample) = 0; 108 virtual void Tick(TickSample* sample) = 0;
109 109
110 private: 110 private:
111 void SetActive(bool value) { NoBarrier_Store(&active_, value); } 111 void SetActive(bool value) { base::NoBarrier_Store(&active_, value); }
112 112
113 Isolate* isolate_; 113 Isolate* isolate_;
114 const int interval_; 114 const int interval_;
115 Atomic32 profiling_; 115 base::Atomic32 profiling_;
116 Atomic32 has_processing_thread_; 116 base::Atomic32 has_processing_thread_;
117 Atomic32 active_; 117 base::Atomic32 active_;
118 PlatformData* data_; // Platform specific data. 118 PlatformData* data_; // Platform specific data.
119 bool is_counting_samples_; 119 bool is_counting_samples_;
120 // Counts stack samples taken in JS VM state. 120 // Counts stack samples taken in JS VM state.
121 unsigned js_and_external_sample_count_; 121 unsigned js_and_external_sample_count_;
122 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 122 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
123 }; 123 };
124 124
125 125
126 } } // namespace v8::internal 126 } } // namespace v8::internal
127 127
128 #endif // V8_SAMPLER_H_ 128 #endif // V8_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/runtime-profiler.h ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698