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

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

Issue 10857035: Moving cpu profiling into its own thread. (Closed) Base URL: http://git.chromium.org/external/v8.git@master
Patch Set: added { } 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') | no next file with comments »
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static TickSampleEventRecord* cast(void* value) { 117 static TickSampleEventRecord* cast(void* value) {
118 return reinterpret_cast<TickSampleEventRecord*>(value); 118 return reinterpret_cast<TickSampleEventRecord*>(value);
119 } 119 }
120 }; 120 };
121 121
122 122
123 // This class implements both the profile events processor thread and 123 // This class implements both the profile events processor thread and
124 // methods called by event producers: VM and stack sampler threads. 124 // methods called by event producers: VM and stack sampler threads.
125 class ProfilerEventsProcessor : public Thread { 125 class ProfilerEventsProcessor : public Thread {
126 public: 126 public:
127 explicit ProfilerEventsProcessor(ProfileGenerator* generator); 127 explicit ProfilerEventsProcessor(ProfileGenerator* generator,
128 Sampler* sampler,
129 int period_in_useconds);
128 virtual ~ProfilerEventsProcessor() {} 130 virtual ~ProfilerEventsProcessor() {}
129 131
130 // Thread control. 132 // Thread control.
131 virtual void Run(); 133 virtual void Run();
132 inline void Stop() { running_ = false; } 134 inline void Stop() { running_ = false; }
133 INLINE(bool running()) { return running_; } 135 INLINE(bool running()) { return running_; }
134 136
135 // Events adding methods. Called by VM threads. 137 // Events adding methods. Called by VM threads.
136 void CallbackCreateEvent(Logger::LogEventsAndTags tag, 138 void CallbackCreateEvent(Logger::LogEventsAndTags tag,
137 const char* prefix, String* name, 139 const char* prefix, String* name,
(...skipping 27 matching lines...) Expand all
165 private: 167 private:
166 union CodeEventsContainer { 168 union CodeEventsContainer {
167 CodeEventRecord generic; 169 CodeEventRecord generic;
168 #define DECLARE_CLASS(ignore, type) type type##_; 170 #define DECLARE_CLASS(ignore, type) type type##_;
169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 171 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
170 #undef DECLARE_TYPE 172 #undef DECLARE_TYPE
171 }; 173 };
172 174
173 // Called from events processing thread (Run() method.) 175 // Called from events processing thread (Run() method.)
174 bool ProcessCodeEvent(unsigned* dequeue_order); 176 bool ProcessCodeEvent(unsigned* dequeue_order);
175 bool ProcessTicks(unsigned dequeue_order); 177 bool ProcessTicks(int64_t stop_time, unsigned dequeue_order);
178 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order);
176 179
177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); 180 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
178 181
179 ProfileGenerator* generator_; 182 ProfileGenerator* generator_;
183 Sampler* sampler_;
180 bool running_; 184 bool running_;
185 // Sampling period in microseconds.
186 const int period_in_useconds_;
181 UnboundQueue<CodeEventsContainer> events_buffer_; 187 UnboundQueue<CodeEventsContainer> events_buffer_;
182 SamplingCircularQueue ticks_buffer_; 188 SamplingCircularQueue ticks_buffer_;
183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 189 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
184 unsigned enqueue_order_; 190 unsigned enqueue_order_;
185 }; 191 };
186 192
187 } } // namespace v8::internal 193 } } // namespace v8::internal
188 194
189 195
190 #define PROFILE(isolate, Call) \ 196 #define PROFILE(isolate, Call) \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Atomic32 is_profiling_; 280 Atomic32 is_profiling_;
275 281
276 private: 282 private:
277 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 283 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
278 }; 284 };
279 285
280 } } // namespace v8::internal 286 } } // namespace v8::internal
281 287
282 288
283 #endif // V8_CPU_PROFILER_H_ 289 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698