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

Side by Side Diff: src/sampler.h

Issue 21101002: Support higher CPU profiler sampling rate on posix systems (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebaseline Created 7 years, 4 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/flag-definitions.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 Isolate* isolate() const { return isolate_; } 87 Isolate* isolate() const { return isolate_; }
88 int interval() const { return interval_; } 88 int interval() const { return interval_; }
89 89
90 // Performs stack sampling. 90 // Performs stack sampling.
91 void SampleStack(const RegisterState& regs); 91 void SampleStack(const RegisterState& regs);
92 92
93 // Start and stop sampler. 93 // Start and stop sampler.
94 void Start(); 94 void Start();
95 void Stop(); 95 void Stop();
96 96
97 // Is the sampler used for profiling? 97 // Whether the sampling thread should use this Sampler for CPU profiling?
98 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } 98 bool IsProfiling() const {
99 return NoBarrier_Load(&profiling_) > 0 &&
100 !NoBarrier_Load(&has_processing_thread_);
101 }
99 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } 102 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
100 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } 103 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
101 104
102 // Whether the sampler is running (that is, consumes resources). 105 // Whether the sampler is running (that is, consumes resources).
103 bool IsActive() const { return NoBarrier_Load(&active_); } 106 bool IsActive() const { return NoBarrier_Load(&active_); }
104 107
108 // If true next sample must be initiated on the profiler event processor
109 // thread right after latest sample is processed.
110 static bool CanSampleOnProfilerEventsProcessorThread();
111 void DoSample();
112 void SetHasProcessingThread(bool value) {
113 NoBarrier_Store(&has_processing_thread_, value);
114 }
115
105 // Used in tests to make sure that stack sampling is performed. 116 // Used in tests to make sure that stack sampling is performed.
106 unsigned js_and_external_sample_count() const { 117 unsigned js_and_external_sample_count() const {
107 return js_and_external_sample_count_; 118 return js_and_external_sample_count_;
108 } 119 }
109 void StartCountingSamples() { 120 void StartCountingSamples() {
110 is_counting_samples_ = true; 121 is_counting_samples_ = true;
111 js_and_external_sample_count_ = 0; 122 js_and_external_sample_count_ = 0;
112 } 123 }
113 124
114 class PlatformData; 125 class PlatformData;
115 PlatformData* platform_data() const { return data_; } 126 PlatformData* platform_data() const { return data_; }
116 127
117 protected: 128 protected:
118 // This method is called for each sampling period with the current 129 // This method is called for each sampling period with the current
119 // program counter. 130 // program counter.
120 virtual void Tick(TickSample* sample) = 0; 131 virtual void Tick(TickSample* sample) = 0;
121 132
122 private: 133 private:
123 void SetActive(bool value) { NoBarrier_Store(&active_, value); } 134 void SetActive(bool value) { NoBarrier_Store(&active_, value); }
124 135
125 Isolate* isolate_; 136 Isolate* isolate_;
126 const int interval_; 137 const int interval_;
127 Atomic32 profiling_; 138 Atomic32 profiling_;
139 Atomic32 has_processing_thread_;
128 Atomic32 active_; 140 Atomic32 active_;
129 PlatformData* data_; // Platform specific data. 141 PlatformData* data_; // Platform specific data.
130 bool is_counting_samples_; 142 bool is_counting_samples_;
131 // Counts stack samples taken in JS VM state. 143 // Counts stack samples taken in JS VM state.
132 unsigned js_and_external_sample_count_; 144 unsigned js_and_external_sample_count_;
133 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 145 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
134 }; 146 };
135 147
136 148
137 } } // namespace v8::internal 149 } } // namespace v8::internal
138 150
139 #endif // V8_SAMPLER_H_ 151 #endif // V8_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698