| OLD | NEW |
| 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 Loading... |
| 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 ProfilerEventsProcessor(ProfileGenerator* generator, | 127 explicit ProfilerEventsProcessor(ProfileGenerator* generator); |
| 128 Sampler* sampler, | |
| 129 int period_in_useconds); | |
| 130 virtual ~ProfilerEventsProcessor() {} | 128 virtual ~ProfilerEventsProcessor() {} |
| 131 | 129 |
| 132 // Thread control. | 130 // Thread control. |
| 133 virtual void Run(); | 131 virtual void Run(); |
| 134 inline void Stop() { running_ = false; } | 132 inline void Stop() { running_ = false; } |
| 135 INLINE(bool running()) { return running_; } | 133 INLINE(bool running()) { return running_; } |
| 136 | 134 |
| 137 // Events adding methods. Called by VM threads. | 135 // Events adding methods. Called by VM threads. |
| 138 void CallbackCreateEvent(Logger::LogEventsAndTags tag, | 136 void CallbackCreateEvent(Logger::LogEventsAndTags tag, |
| 139 const char* prefix, Name* name, | 137 const char* prefix, Name* name, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 168 union CodeEventsContainer { | 166 union CodeEventsContainer { |
| 169 CodeEventRecord generic; | 167 CodeEventRecord generic; |
| 170 #define DECLARE_CLASS(ignore, type) type type##_; | 168 #define DECLARE_CLASS(ignore, type) type type##_; |
| 171 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) | 169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) |
| 172 #undef DECLARE_TYPE | 170 #undef DECLARE_TYPE |
| 173 }; | 171 }; |
| 174 | 172 |
| 175 // Called from events processing thread (Run() method.) | 173 // Called from events processing thread (Run() method.) |
| 176 bool ProcessCodeEvent(unsigned* dequeue_order); | 174 bool ProcessCodeEvent(unsigned* dequeue_order); |
| 177 bool ProcessTicks(unsigned dequeue_order); | 175 bool ProcessTicks(unsigned dequeue_order); |
| 178 void ProcessEventsAndDoSample(unsigned* dequeue_order); | |
| 179 void ProcessEventsAndYield(unsigned* dequeue_order); | |
| 180 | 176 |
| 181 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); | 177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); |
| 182 | 178 |
| 183 ProfileGenerator* generator_; | 179 ProfileGenerator* generator_; |
| 184 Sampler* sampler_; | |
| 185 bool running_; | 180 bool running_; |
| 186 // Sampling period in microseconds. | |
| 187 const int period_in_useconds_; | |
| 188 UnboundQueue<CodeEventsContainer> events_buffer_; | 181 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 189 SamplingCircularQueue ticks_buffer_; | 182 SamplingCircularQueue ticks_buffer_; |
| 190 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 191 unsigned enqueue_order_; | 184 unsigned enqueue_order_; |
| 192 }; | 185 }; |
| 193 | 186 |
| 194 } } // namespace v8::internal | 187 } } // namespace v8::internal |
| 195 | 188 |
| 196 | 189 |
| 197 #define PROFILE(isolate, Call) \ | 190 #define PROFILE(isolate, Call) \ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 bool is_profiling_; | 272 bool is_profiling_; |
| 280 | 273 |
| 281 private: | 274 private: |
| 282 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 275 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 283 }; | 276 }; |
| 284 | 277 |
| 285 } } // namespace v8::internal | 278 } } // namespace v8::internal |
| 286 | 279 |
| 287 | 280 |
| 288 #endif // V8_CPU_PROFILER_H_ | 281 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |