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

Side by Side Diff: src/cpu-profiler.h

Issue 10871039: Replacing circular queue by single buffer in CPU Profiler. (Closed) Base URL: http://git.chromium.org/external/v8.git@profiling
Patch Set: an attempt to fix a test that strangely crashed only once Created 8 years, 3 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 | « no previous file | src/cpu-profiler.cc » ('j') | src/cpu-profiler-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_CPU_PROFILER_H_ 28 #ifndef V8_CPU_PROFILER_H_
29 #define V8_CPU_PROFILER_H_ 29 #define V8_CPU_PROFILER_H_
30 30
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "atomicops.h" 32 #include "atomicops.h"
33 #include "circular-queue.h"
Jakob Kummerow 2012/10/02 10:56:51 We still need this for the ASSERT in line 104.
34 #include "unbound-queue.h" 33 #include "unbound-queue.h"
35 34
36 namespace v8 { 35 namespace v8 {
37 namespace internal { 36 namespace internal {
38 37
39 // Forward declarations. 38 // Forward declarations.
40 class CodeEntry; 39 class CodeEntry;
41 class CodeMap; 40 class CodeMap;
42 class CpuProfile; 41 class CpuProfile;
43 class CpuProfilesCollection; 42 class CpuProfilesCollection;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 Address start, unsigned size); 150 Address start, unsigned size);
152 void CodeMoveEvent(Address from, Address to); 151 void CodeMoveEvent(Address from, Address to);
153 void CodeDeleteEvent(Address from); 152 void CodeDeleteEvent(Address from);
154 void SharedFunctionInfoMoveEvent(Address from, Address to); 153 void SharedFunctionInfoMoveEvent(Address from, Address to);
155 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, 154 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag,
156 const char* prefix, String* name, 155 const char* prefix, String* name,
157 Address start, unsigned size); 156 Address start, unsigned size);
158 // Puts current stack into tick sample events buffer. 157 // Puts current stack into tick sample events buffer.
159 void AddCurrentStack(); 158 void AddCurrentStack();
160 159
161 // Tick sample events are filled directly in the buffer of the circular 160 // StartTickSampleEvent returns a pointer only if the ticks_buffer_ is empty,
162 // queue (because the structure is of fixed width, but usually not all 161 // FinishTickSampleEvent marks the ticks_buffer_ as filled.
163 // stack frame entries are filled.) This method returns a pointer to the 162 // Finish should be called only after successful Start (returning non-NULL
164 // next record of the buffer. 163 // pointer).
165 INLINE(TickSample* TickSampleEvent()); 164 INLINE(TickSample* StartTickSampleEvent());
165 INLINE(void FinishTickSampleEvent());
166 166
167 private: 167 private:
168 union CodeEventsContainer { 168 union CodeEventsContainer {
169 CodeEventRecord generic; 169 CodeEventRecord generic;
170 #define DECLARE_CLASS(ignore, type) type type##_; 170 #define DECLARE_CLASS(ignore, type) type type##_;
171 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 171 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
172 #undef DECLARE_TYPE 172 #undef DECLARE_TYPE
173 }; 173 };
174 174
175 // Called from events processing thread (Run() method.) 175 // Called from events processing thread (Run() method.)
176 bool ProcessCodeEvent(unsigned* dequeue_order); 176 bool ProcessCodeEvent(unsigned* dequeue_order);
177 bool ProcessTicks(int64_t stop_time, unsigned dequeue_order); 177 bool ProcessTicks(unsigned dequeue_order);
178 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order); 178 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order);
179 179
180 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); 180 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
181 181
182 ProfileGenerator* generator_; 182 ProfileGenerator* generator_;
183 Sampler* sampler_; 183 Sampler* sampler_;
184 bool running_; 184 bool running_;
185 // Sampling period in microseconds. 185 // Sampling period in microseconds.
186 const int period_in_useconds_; 186 const int period_in_useconds_;
187 UnboundQueue<CodeEventsContainer> events_buffer_; 187 UnboundQueue<CodeEventsContainer> events_buffer_;
188 SamplingCircularQueue ticks_buffer_; 188 TickSampleEventRecord ticks_buffer_;
189 bool ticks_buffer_is_empty_;
190 bool ticks_buffer_is_initialized_;
189 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 191 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
190 unsigned enqueue_order_; 192 unsigned enqueue_order_;
191 }; 193 };
192 194
193 } } // namespace v8::internal 195 } } // namespace v8::internal
194 196
195 197
196 #define PROFILE(isolate, Call) \ 198 #define PROFILE(isolate, Call) \
197 LOG_CODE_EVENT(isolate, Call); \ 199 LOG_CODE_EVENT(isolate, Call); \
198 do { \ 200 do { \
(...skipping 18 matching lines...) Expand all
217 static CpuProfile* StopProfiling(const char* title); 219 static CpuProfile* StopProfiling(const char* title);
218 static CpuProfile* StopProfiling(Object* security_token, String* title); 220 static CpuProfile* StopProfiling(Object* security_token, String* title);
219 static int GetProfilesCount(); 221 static int GetProfilesCount();
220 static CpuProfile* GetProfile(Object* security_token, int index); 222 static CpuProfile* GetProfile(Object* security_token, int index);
221 static CpuProfile* FindProfile(Object* security_token, unsigned uid); 223 static CpuProfile* FindProfile(Object* security_token, unsigned uid);
222 static void DeleteAllProfiles(); 224 static void DeleteAllProfiles();
223 static void DeleteProfile(CpuProfile* profile); 225 static void DeleteProfile(CpuProfile* profile);
224 static bool HasDetachedProfiles(); 226 static bool HasDetachedProfiles();
225 227
226 // Invoked from stack sampler (thread or signal handler.) 228 // Invoked from stack sampler (thread or signal handler.)
227 static TickSample* TickSampleEvent(Isolate* isolate); 229 // Finish should be called only after successful Start (returning non-NULL
230 // pointer).
231 static TickSample* StartTickSampleEvent(Isolate* isolate);
232 static void FinishTickSampleEvent(Isolate* isolate);
228 233
229 // Must be called via PROFILE macro, otherwise will crash when 234 // Must be called via PROFILE macro, otherwise will crash when
230 // profiling is not enabled. 235 // profiling is not enabled.
231 static void CallbackEvent(String* name, Address entry_point); 236 static void CallbackEvent(String* name, Address entry_point);
232 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 237 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
233 Code* code, const char* comment); 238 Code* code, const char* comment);
234 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 239 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
235 Code* code, String* name); 240 Code* code, String* name);
236 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 241 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
237 Code* code, 242 Code* code,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 Atomic32 is_profiling_; 285 Atomic32 is_profiling_;
281 286
282 private: 287 private:
283 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 288 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
284 }; 289 };
285 290
286 } } // namespace v8::internal 291 } } // namespace v8::internal
287 292
288 293
289 #endif // V8_CPU_PROFILER_H_ 294 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | src/cpu-profiler-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698