| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 // This class implements both the profile events processor thread and | 150 // This class implements both the profile events processor thread and |
| 151 // methods called by event producers: VM and stack sampler threads. | 151 // methods called by event producers: VM and stack sampler threads. |
| 152 class ProfilerEventsProcessor : public Thread { | 152 class ProfilerEventsProcessor : public Thread { |
| 153 public: | 153 public: |
| 154 explicit ProfilerEventsProcessor(ProfileGenerator* generator); | 154 explicit ProfilerEventsProcessor(ProfileGenerator* generator); |
| 155 virtual ~ProfilerEventsProcessor() {} | 155 virtual ~ProfilerEventsProcessor() {} |
| 156 | 156 |
| 157 // Thread control. | 157 // Thread control. |
| 158 virtual void Run(); | 158 virtual void Run(); |
| 159 inline void Stop() { running_ = false; } | 159 void StopSynchronously(); |
| 160 INLINE(bool running()) { return running_; } | 160 INLINE(bool running()) { return running_; } |
| 161 void Enqueue(const CodeEventsContainer& event); | 161 void Enqueue(const CodeEventsContainer& event); |
| 162 | 162 |
| 163 // Puts current stack into tick sample events buffer. | 163 // Puts current stack into tick sample events buffer. |
| 164 void AddCurrentStack(Isolate* isolate); | 164 void AddCurrentStack(Isolate* isolate); |
| 165 | 165 |
| 166 // Tick sample events are filled directly in the buffer of the circular | 166 // Tick sample events are filled directly in the buffer of the circular |
| 167 // queue (because the structure is of fixed width, but usually not all | 167 // queue (because the structure is of fixed width, but usually not all |
| 168 // stack frame entries are filled.) This method returns a pointer to the | 168 // stack frame entries are filled.) This method returns a pointer to the |
| 169 // next record of the buffer. | 169 // next record of the buffer. |
| 170 INLINE(TickSample* TickSampleEvent()); | 170 INLINE(TickSample* TickSampleEvent()); |
| 171 | 171 |
| 172 private: | 172 private: |
| 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(); |
| 175 bool ProcessTicks(unsigned dequeue_order); | 175 bool ProcessTicks(); |
| 176 | 176 |
| 177 ProfileGenerator* generator_; | 177 ProfileGenerator* generator_; |
| 178 bool running_; | 178 bool running_; |
| 179 UnboundQueue<CodeEventsContainer> events_buffer_; | 179 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 180 SamplingCircularQueue ticks_buffer_; | 180 SamplingCircularQueue ticks_buffer_; |
| 181 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 181 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 182 unsigned enqueue_order_; | 182 unsigned last_code_event_id_; |
| 183 unsigned last_processed_code_event_id_; |
| 183 }; | 184 }; |
| 184 | 185 |
| 185 | 186 |
| 186 #define PROFILE(IsolateGetter, Call) \ | 187 #define PROFILE(IsolateGetter, Call) \ |
| 187 do { \ | 188 do { \ |
| 188 Isolate* cpu_profiler_isolate = (IsolateGetter); \ | 189 Isolate* cpu_profiler_isolate = (IsolateGetter); \ |
| 189 LOG_CODE_EVENT(cpu_profiler_isolate, Call); \ | 190 LOG_CODE_EVENT(cpu_profiler_isolate, Call); \ |
| 190 CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \ | 191 CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \ |
| 191 if (cpu_profiler->is_profiling()) { \ | 192 if (cpu_profiler->is_profiling()) { \ |
| 192 cpu_profiler->Call; \ | 193 cpu_profiler->Call; \ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void GetterCallbackEvent(Name* name, Address entry_point); | 245 void GetterCallbackEvent(Name* name, Address entry_point); |
| 245 void RegExpCodeCreateEvent(Code* code, String* source); | 246 void RegExpCodeCreateEvent(Code* code, String* source); |
| 246 void SetterCallbackEvent(Name* name, Address entry_point); | 247 void SetterCallbackEvent(Name* name, Address entry_point); |
| 247 void SharedFunctionInfoMoveEvent(Address from, Address to); | 248 void SharedFunctionInfoMoveEvent(Address from, Address to); |
| 248 | 249 |
| 249 INLINE(bool is_profiling() const) { return is_profiling_; } | 250 INLINE(bool is_profiling() const) { return is_profiling_; } |
| 250 bool* is_profiling_address() { | 251 bool* is_profiling_address() { |
| 251 return &is_profiling_; | 252 return &is_profiling_; |
| 252 } | 253 } |
| 253 | 254 |
| 255 ProfileGenerator* generator() const { return generator_; } |
| 256 ProfilerEventsProcessor* processor() const { return processor_; } |
| 257 |
| 254 private: | 258 private: |
| 255 void StartProcessorIfNotStarted(); | 259 void StartProcessorIfNotStarted(); |
| 256 void StopProcessorIfLastProfile(const char* title); | 260 void StopProcessorIfLastProfile(const char* title); |
| 257 void StopProcessor(); | 261 void StopProcessor(); |
| 258 void ResetProfiles(); | 262 void ResetProfiles(); |
| 259 void LogBuiltins(); | 263 void LogBuiltins(); |
| 260 | 264 |
| 261 Isolate* isolate_; | 265 Isolate* isolate_; |
| 262 CpuProfilesCollection* profiles_; | 266 CpuProfilesCollection* profiles_; |
| 263 unsigned next_profile_uid_; | 267 unsigned next_profile_uid_; |
| 264 TokenEnumerator* token_enumerator_; | 268 TokenEnumerator* token_enumerator_; |
| 265 ProfileGenerator* generator_; | 269 ProfileGenerator* generator_; |
| 266 ProfilerEventsProcessor* processor_; | 270 ProfilerEventsProcessor* processor_; |
| 267 int saved_logging_nesting_; | 271 int saved_logging_nesting_; |
| 268 bool need_to_stop_sampler_; | 272 bool need_to_stop_sampler_; |
| 269 bool is_profiling_; | 273 bool is_profiling_; |
| 270 | 274 |
| 271 private: | 275 private: |
| 272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 276 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 273 }; | 277 }; |
| 274 | 278 |
| 275 } } // namespace v8::internal | 279 } } // namespace v8::internal |
| 276 | 280 |
| 277 | 281 |
| 278 #endif // V8_CPU_PROFILER_H_ | 282 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |