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

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: moved installing/restoring handler of SIGPROF to Sampler::Start/Stop 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.cc » ('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 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, Sampler* sampler , int interval_in_useconds);
Jakob Kummerow 2012/09/04 11:10:51 long line. Put each argument onto its own line: ex
128 virtual ~ProfilerEventsProcessor() {} 128 virtual ~ProfilerEventsProcessor() {}
129 129
130 // Thread control. 130 // Thread control.
131 virtual void Run(); 131 virtual void Run();
132 inline void Stop() { running_ = false; } 132 inline void Stop() { running_ = false; }
133 INLINE(bool running()) { return running_; } 133 INLINE(bool running()) { return running_; }
134 134
135 // Events adding methods. Called by VM threads. 135 // Events adding methods. Called by VM threads.
136 void CallbackCreateEvent(Logger::LogEventsAndTags tag, 136 void CallbackCreateEvent(Logger::LogEventsAndTags tag,
137 const char* prefix, String* name, 137 const char* prefix, String* name,
(...skipping 27 matching lines...) Expand all
165 private: 165 private:
166 union CodeEventsContainer { 166 union CodeEventsContainer {
167 CodeEventRecord generic; 167 CodeEventRecord generic;
168 #define DECLARE_CLASS(ignore, type) type type##_; 168 #define DECLARE_CLASS(ignore, type) type type##_;
169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
170 #undef DECLARE_TYPE 170 #undef DECLARE_TYPE
171 }; 171 };
172 172
173 // Called from events processing thread (Run() method.) 173 // Called from events processing thread (Run() method.)
174 bool ProcessCodeEvent(unsigned* dequeue_order); 174 bool ProcessCodeEvent(unsigned* dequeue_order);
175 bool ProcessTicks(unsigned dequeue_order); 175 bool ProcessTicks(int64_t stop_time, unsigned dequeue_order);
176 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order);
176 177
177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); 178 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
178 179
179 ProfileGenerator* generator_; 180 ProfileGenerator* generator_;
181 Sampler* sampler_;
180 bool running_; 182 bool running_;
183 // Sampling interval in microseconds.
184 const int interval_in_useconds_;
181 UnboundQueue<CodeEventsContainer> events_buffer_; 185 UnboundQueue<CodeEventsContainer> events_buffer_;
182 SamplingCircularQueue ticks_buffer_; 186 SamplingCircularQueue ticks_buffer_;
183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 187 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
184 unsigned enqueue_order_; 188 unsigned enqueue_order_;
185 }; 189 };
186 190
187 } } // namespace v8::internal 191 } } // namespace v8::internal
188 192
189 193
190 #define PROFILE(isolate, Call) \ 194 #define PROFILE(isolate, Call) \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Atomic32 is_profiling_; 278 Atomic32 is_profiling_;
275 279
276 private: 280 private:
277 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 281 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
278 }; 282 };
279 283
280 } } // namespace v8::internal 284 } } // namespace v8::internal
281 285
282 286
283 #endif // V8_CPU_PROFILER_H_ 287 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | src/cpu-profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698