Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_CPU_PROFILER_H_ | 28 #ifndef V8_CPU_PROFILER_H_ |
| 29 #define V8_CPU_PROFILER_H_ | 29 #define V8_CPU_PROFILER_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "atomicops.h" | 32 #include "atomicops.h" |
| 33 #include "circular-queue.h" | |
| 34 #include "unbound-queue.h" | 33 #include "unbound-queue.h" |
| 35 | 34 |
| 36 namespace v8 { | 35 namespace v8 { |
| 37 namespace internal { | 36 namespace internal { |
| 38 | 37 |
| 39 // Forward declarations. | 38 // Forward declarations. |
| 40 class CodeEntry; | 39 class CodeEntry; |
| 41 class CodeMap; | 40 class CodeMap; |
| 42 class CpuProfile; | 41 class CpuProfile; |
| 43 class CpuProfilesCollection; | 42 class CpuProfilesCollection; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 Address start, unsigned size); | 148 Address start, unsigned size); |
| 150 void CodeMoveEvent(Address from, Address to); | 149 void CodeMoveEvent(Address from, Address to); |
| 151 void CodeDeleteEvent(Address from); | 150 void CodeDeleteEvent(Address from); |
| 152 void SharedFunctionInfoMoveEvent(Address from, Address to); | 151 void SharedFunctionInfoMoveEvent(Address from, Address to); |
| 153 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, | 152 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, |
| 154 const char* prefix, String* name, | 153 const char* prefix, String* name, |
| 155 Address start, unsigned size); | 154 Address start, unsigned size); |
| 156 // Puts current stack into tick sample events buffer. | 155 // Puts current stack into tick sample events buffer. |
| 157 void AddCurrentStack(); | 156 void AddCurrentStack(); |
| 158 | 157 |
| 159 // Tick sample events are filled directly in the buffer of the circular | 158 // StartTickSampleEvent returns a pointer only if the ticks_buffer_ is empty, |
| 160 // queue (because the structure is of fixed width, but usually not all | 159 // FinishTickSampleEvent marks the ticks_buffer_ as filled. |
| 161 // stack frame entries are filled.) This method returns a pointer to the | 160 // Finish should be called only after successful Start (returning non-NULL poi nter). |
|
Jakob Kummerow
2012/09/04 11:25:18
long line.
Also, can you put in an ASSERT that mak
| |
| 162 // next record of the buffer. | 161 INLINE(TickSample* StartTickSampleEvent()); |
| 163 INLINE(TickSample* TickSampleEvent()); | 162 INLINE(void FinishTickSampleEvent()) { ticks_buffer_is_empty_ = false; } |
| 164 | 163 |
| 165 private: | 164 private: |
| 166 union CodeEventsContainer { | 165 union CodeEventsContainer { |
| 167 CodeEventRecord generic; | 166 CodeEventRecord generic; |
| 168 #define DECLARE_CLASS(ignore, type) type type##_; | 167 #define DECLARE_CLASS(ignore, type) type type##_; |
| 169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) | 168 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) |
| 170 #undef DECLARE_TYPE | 169 #undef DECLARE_TYPE |
| 171 }; | 170 }; |
| 172 | 171 |
| 173 // Called from events processing thread (Run() method.) | 172 // Called from events processing thread (Run() method.) |
| 174 bool ProcessCodeEvent(unsigned* dequeue_order); | 173 bool ProcessCodeEvent(unsigned* dequeue_order); |
| 175 bool ProcessTicks(int64_t stop_time, unsigned dequeue_order); | 174 bool ProcessTicks(unsigned dequeue_order); |
| 176 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order); | 175 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order); |
| 177 | 176 |
| 178 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); | 177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); |
| 179 | 178 |
| 180 ProfileGenerator* generator_; | 179 ProfileGenerator* generator_; |
| 181 Sampler* sampler_; | 180 Sampler* sampler_; |
| 182 bool running_; | 181 bool running_; |
| 183 // Sampling interval in microseconds. | 182 // Sampling interval in microseconds. |
| 184 const int interval_in_useconds_; | 183 const int interval_in_useconds_; |
| 185 UnboundQueue<CodeEventsContainer> events_buffer_; | 184 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 186 SamplingCircularQueue ticks_buffer_; | 185 TickSampleEventRecord ticks_buffer_; |
| 186 bool ticks_buffer_is_empty_; | |
| 187 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 187 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 188 unsigned enqueue_order_; | 188 unsigned enqueue_order_; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 } } // namespace v8::internal | 191 } } // namespace v8::internal |
| 192 | 192 |
| 193 | 193 |
| 194 #define PROFILE(isolate, Call) \ | 194 #define PROFILE(isolate, Call) \ |
| 195 LOG(isolate, Call); \ | 195 LOG(isolate, Call); \ |
| 196 do { \ | 196 do { \ |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 215 static CpuProfile* StopProfiling(const char* title); | 215 static CpuProfile* StopProfiling(const char* title); |
| 216 static CpuProfile* StopProfiling(Object* security_token, String* title); | 216 static CpuProfile* StopProfiling(Object* security_token, String* title); |
| 217 static int GetProfilesCount(); | 217 static int GetProfilesCount(); |
| 218 static CpuProfile* GetProfile(Object* security_token, int index); | 218 static CpuProfile* GetProfile(Object* security_token, int index); |
| 219 static CpuProfile* FindProfile(Object* security_token, unsigned uid); | 219 static CpuProfile* FindProfile(Object* security_token, unsigned uid); |
| 220 static void DeleteAllProfiles(); | 220 static void DeleteAllProfiles(); |
| 221 static void DeleteProfile(CpuProfile* profile); | 221 static void DeleteProfile(CpuProfile* profile); |
| 222 static bool HasDetachedProfiles(); | 222 static bool HasDetachedProfiles(); |
| 223 | 223 |
| 224 // Invoked from stack sampler (thread or signal handler.) | 224 // Invoked from stack sampler (thread or signal handler.) |
| 225 static TickSample* TickSampleEvent(Isolate* isolate); | 225 // Finish should be called only after successful Start (returning non-NULL poi nter). |
|
Jakob Kummerow
2012/09/04 11:25:18
long line
| |
| 226 static TickSample* StartTickSampleEvent(Isolate* isolate); | |
| 227 static void FinishTickSampleEvent(Isolate* isolate); | |
| 226 | 228 |
| 227 // Must be called via PROFILE macro, otherwise will crash when | 229 // Must be called via PROFILE macro, otherwise will crash when |
| 228 // profiling is not enabled. | 230 // profiling is not enabled. |
| 229 static void CallbackEvent(String* name, Address entry_point); | 231 static void CallbackEvent(String* name, Address entry_point); |
| 230 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 232 static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 231 Code* code, const char* comment); | 233 Code* code, const char* comment); |
| 232 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 234 static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 233 Code* code, String* name); | 235 Code* code, String* name); |
| 234 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 236 static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 235 Code* code, | 237 Code* code, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 Atomic32 is_profiling_; | 280 Atomic32 is_profiling_; |
| 279 | 281 |
| 280 private: | 282 private: |
| 281 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 283 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 282 }; | 284 }; |
| 283 | 285 |
| 284 } } // namespace v8::internal | 286 } } // namespace v8::internal |
| 285 | 287 |
| 286 | 288 |
| 287 #endif // V8_CPU_PROFILER_H_ | 289 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |