| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 class TickSampleEventRecord { | 108 class TickSampleEventRecord { |
| 109 public: | 109 public: |
| 110 // The parameterless constructor is used when we dequeue data from | 110 // The parameterless constructor is used when we dequeue data from |
| 111 // the ticks buffer. | 111 // the ticks buffer. |
| 112 TickSampleEventRecord() { } | 112 TickSampleEventRecord() { } |
| 113 explicit TickSampleEventRecord(unsigned order) : order(order) { } | 113 explicit TickSampleEventRecord(unsigned order) : order(order) { } |
| 114 | 114 |
| 115 unsigned order; | 115 unsigned order; |
| 116 TickSample sample; | 116 TickSample sample; |
| 117 | |
| 118 static TickSampleEventRecord* cast(void* value) { | |
| 119 return reinterpret_cast<TickSampleEventRecord*>(value); | |
| 120 } | |
| 121 }; | 117 }; |
| 122 | 118 |
| 123 | 119 |
| 124 class CodeEventsContainer { | 120 class CodeEventsContainer { |
| 125 public: | 121 public: |
| 126 explicit CodeEventsContainer( | 122 explicit CodeEventsContainer( |
| 127 CodeEventRecord::Type type = CodeEventRecord::NONE) { | 123 CodeEventRecord::Type type = CodeEventRecord::NONE) { |
| 128 generic.type = type; | 124 generic.type = type; |
| 129 } | 125 } |
| 130 union { | 126 union { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 INLINE(bool running()) { return running_; } | 145 INLINE(bool running()) { return running_; } |
| 150 void Enqueue(const CodeEventsContainer& event); | 146 void Enqueue(const CodeEventsContainer& event); |
| 151 | 147 |
| 152 // Puts current stack into tick sample events buffer. | 148 // Puts current stack into tick sample events buffer. |
| 153 void AddCurrentStack(Isolate* isolate); | 149 void AddCurrentStack(Isolate* isolate); |
| 154 | 150 |
| 155 // Tick sample events are filled directly in the buffer of the circular | 151 // Tick sample events are filled directly in the buffer of the circular |
| 156 // queue (because the structure is of fixed width, but usually not all | 152 // queue (because the structure is of fixed width, but usually not all |
| 157 // stack frame entries are filled.) This method returns a pointer to the | 153 // stack frame entries are filled.) This method returns a pointer to the |
| 158 // next record of the buffer. | 154 // next record of the buffer. |
| 159 INLINE(TickSample* TickSampleEvent()); | 155 inline TickSample* StartTickSample(); |
| 156 inline void FinishTickSample(); |
| 160 | 157 |
| 161 private: | 158 private: |
| 162 // Called from events processing thread (Run() method.) | 159 // Called from events processing thread (Run() method.) |
| 163 bool ProcessCodeEvent(); | 160 bool ProcessCodeEvent(); |
| 164 bool ProcessTicks(); | 161 bool ProcessTicks(); |
| 165 | 162 |
| 166 ProfileGenerator* generator_; | 163 ProfileGenerator* generator_; |
| 167 bool running_; | 164 bool running_; |
| 168 UnboundQueue<CodeEventsContainer> events_buffer_; | 165 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 169 SamplingCircularQueue ticks_buffer_; | 166 static const size_t kTickSampleBufferSize = 1 * MB; |
| 167 static const size_t kTickSampleQueueLength = |
| 168 kTickSampleBufferSize / sizeof(TickSampleEventRecord); |
| 169 SamplingCircularQueue<TickSampleEventRecord, |
| 170 kTickSampleQueueLength> ticks_buffer_; |
| 170 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 171 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 171 unsigned last_code_event_id_; | 172 unsigned last_code_event_id_; |
| 172 unsigned last_processed_code_event_id_; | 173 unsigned last_processed_code_event_id_; |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 | 176 |
| 176 #define PROFILE(IsolateGetter, Call) \ | 177 #define PROFILE(IsolateGetter, Call) \ |
| 177 do { \ | 178 do { \ |
| 178 Isolate* cpu_profiler_isolate = (IsolateGetter); \ | 179 Isolate* cpu_profiler_isolate = (IsolateGetter); \ |
| 179 v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \ | 180 v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 198 void StartProfiling(const char* title, bool record_samples = false); | 199 void StartProfiling(const char* title, bool record_samples = false); |
| 199 void StartProfiling(String* title, bool record_samples); | 200 void StartProfiling(String* title, bool record_samples); |
| 200 CpuProfile* StopProfiling(const char* title); | 201 CpuProfile* StopProfiling(const char* title); |
| 201 CpuProfile* StopProfiling(String* title); | 202 CpuProfile* StopProfiling(String* title); |
| 202 int GetProfilesCount(); | 203 int GetProfilesCount(); |
| 203 CpuProfile* GetProfile(int index); | 204 CpuProfile* GetProfile(int index); |
| 204 void DeleteAllProfiles(); | 205 void DeleteAllProfiles(); |
| 205 void DeleteProfile(CpuProfile* profile); | 206 void DeleteProfile(CpuProfile* profile); |
| 206 | 207 |
| 207 // Invoked from stack sampler (thread or signal handler.) | 208 // Invoked from stack sampler (thread or signal handler.) |
| 208 TickSample* TickSampleEvent(); | 209 inline TickSample* StartTickSample(); |
| 210 inline void FinishTickSample(); |
| 209 | 211 |
| 210 // Must be called via PROFILE macro, otherwise will crash when | 212 // Must be called via PROFILE macro, otherwise will crash when |
| 211 // profiling is not enabled. | 213 // profiling is not enabled. |
| 212 virtual void CallbackEvent(Name* name, Address entry_point); | 214 virtual void CallbackEvent(Name* name, Address entry_point); |
| 213 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 215 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 214 Code* code, const char* comment); | 216 Code* code, const char* comment); |
| 215 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 217 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 216 Code* code, Name* name); | 218 Code* code, Name* name); |
| 217 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 219 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 218 Code* code, | 220 Code* code, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 bool need_to_stop_sampler_; | 261 bool need_to_stop_sampler_; |
| 260 bool is_profiling_; | 262 bool is_profiling_; |
| 261 | 263 |
| 262 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 264 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 263 }; | 265 }; |
| 264 | 266 |
| 265 } } // namespace v8::internal | 267 } } // namespace v8::internal |
| 266 | 268 |
| 267 | 269 |
| 268 #endif // V8_CPU_PROFILER_H_ | 270 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |