| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 TickSample sample; | 115 TickSample sample; |
| 116 | 116 |
| 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 CpuProfilerThread { |
| 126 public: | 126 public: |
| 127 explicit ProfilerEventsProcessor(ProfileGenerator* generator); | 127 explicit ProfilerEventsProcessor(ProfileGenerator* generator, Sampler* sampler
, int interval); |
| 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 26 matching lines...) Expand all Loading... |
| 164 | 164 |
| 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(unsigned dequeue_order, int64_t start, int64_t time_limit); |
| 176 void ProcessEventsQueue(unsigned& dequeue_order, int64_t start, int64_t time_l
imit); |
| 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_; |
| 180 bool running_; | 181 bool running_; |
| 182 // Sampling interval in microseconds. |
| 183 const int interval_; |
| 181 UnboundQueue<CodeEventsContainer> events_buffer_; | 184 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 182 SamplingCircularQueue ticks_buffer_; | 185 SamplingCircularQueue ticks_buffer_; |
| 183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 186 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 184 unsigned enqueue_order_; | 187 unsigned enqueue_order_; |
| 185 }; | 188 }; |
| 186 | 189 |
| 187 } } // namespace v8::internal | 190 } } // namespace v8::internal |
| 188 | 191 |
| 189 | 192 |
| 190 #define PROFILE(isolate, Call) \ | 193 #define PROFILE(isolate, Call) \ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 Atomic32 is_profiling_; | 277 Atomic32 is_profiling_; |
| 275 | 278 |
| 276 private: | 279 private: |
| 277 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 280 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 278 }; | 281 }; |
| 279 | 282 |
| 280 } } // namespace v8::internal | 283 } } // namespace v8::internal |
| 281 | 284 |
| 282 | 285 |
| 283 #endif // V8_CPU_PROFILER_H_ | 286 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |