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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); | 177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); |
| 178 | 178 |
| 179 ProfileGenerator* generator_; | 179 ProfileGenerator* generator_; |
| 180 bool running_; | 180 bool running_; |
| 181 UnboundQueue<CodeEventsContainer> events_buffer_; | 181 UnboundQueue<CodeEventsContainer> events_buffer_; |
| 182 SamplingCircularQueue ticks_buffer_; | 182 SamplingCircularQueue ticks_buffer_; |
| 183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
| 184 unsigned enqueue_order_; | 184 unsigned enqueue_order_; |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 } } // namespace v8::internal | |
| 188 | |
| 189 | 187 |
| 190 #define PROFILE(isolate, Call) \ | 188 #define PROFILE(isolate, Call) \ |
|
Sven Panne
2013/03/19 11:54:53
Don't use a macro parameter more than once, assign
yurys
2013/03/19 12:25:11
Done.
| |
| 191 LOG_CODE_EVENT(isolate, Call); \ | 189 LOG_CODE_EVENT(isolate, Call); \ |
| 192 do { \ | 190 do { \ |
| 193 if (v8::internal::CpuProfiler::is_profiling(isolate)) { \ | 191 CpuProfiler* cpu_profiler = isolate->cpu_profiler(); \ |
|
alph
2013/03/19 11:44:28
nit: put macro argument in parentheses
yurys
2013/03/19 12:25:11
Done.
| |
| 194 v8::internal::CpuProfiler::Call; \ | 192 if (cpu_profiler->is_profiling()) { \ |
|
yurys
2013/03/19 10:42:06
I don't think we have to check if cpu_profiler is
| |
| 193 cpu_profiler->Call; \ | |
| 195 } \ | 194 } \ |
| 196 } while (false) | 195 } while (false) |
| 197 | 196 |
| 198 | 197 |
| 199 namespace v8 { | |
| 200 namespace internal { | |
| 201 | |
| 202 | |
| 203 // TODO(isolates): isolatify this class. | |
| 204 class CpuProfiler { | 198 class CpuProfiler { |
| 205 public: | 199 public: |
| 206 static void SetUp(); | 200 explicit CpuProfiler(Isolate* isolate); |
| 207 static void TearDown(); | 201 ~CpuProfiler(); |
| 208 | 202 |
| 209 static void StartProfiling(const char* title); | 203 void StartProfiling(const char* title, bool record_samples = false); |
| 210 static void StartProfiling(String* title, bool record_samples); | 204 void StartProfiling(String* title, bool record_samples); |
| 211 static CpuProfile* StopProfiling(const char* title); | 205 CpuProfile* StopProfiling(const char* title); |
| 212 static CpuProfile* StopProfiling(Object* security_token, String* title); | 206 CpuProfile* StopProfiling(Object* security_token, String* title); |
| 213 static int GetProfilesCount(); | 207 int GetProfilesCount(); |
| 214 static CpuProfile* GetProfile(Object* security_token, int index); | 208 CpuProfile* GetProfile(Object* security_token, int index); |
| 215 static CpuProfile* FindProfile(Object* security_token, unsigned uid); | 209 CpuProfile* FindProfile(Object* security_token, unsigned uid); |
| 216 static void DeleteAllProfiles(); | 210 void DeleteAllProfiles(); |
| 217 static void DeleteProfile(CpuProfile* profile); | 211 void DeleteProfile(CpuProfile* profile); |
| 218 static bool HasDetachedProfiles(); | 212 bool HasDetachedProfiles(); |
| 219 | 213 |
| 220 // Invoked from stack sampler (thread or signal handler.) | 214 // Invoked from stack sampler (thread or signal handler.) |
| 221 static TickSample* TickSampleEvent(Isolate* isolate); | 215 TickSample* TickSampleEvent(); |
| 222 | 216 |
| 223 // Must be called via PROFILE macro, otherwise will crash when | 217 // Must be called via PROFILE macro, otherwise will crash when |
| 224 // profiling is not enabled. | 218 // profiling is not enabled. |
| 225 static void CallbackEvent(Name* name, Address entry_point); | 219 void CallbackEvent(Name* name, Address entry_point); |
| 226 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 220 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 227 Code* code, const char* comment); | 221 Code* code, const char* comment); |
| 228 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 222 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 229 Code* code, Name* name); | 223 Code* code, Name* name); |
| 230 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 224 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 231 Code* code, | 225 Code* code, |
| 232 SharedFunctionInfo* shared, | 226 SharedFunctionInfo* shared, |
| 233 Name* name); | 227 Name* name); |
| 234 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 228 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 235 Code* code, | 229 Code* code, |
| 236 SharedFunctionInfo* shared, | 230 SharedFunctionInfo* shared, |
| 237 String* source, int line); | 231 String* source, int line); |
| 238 static void CodeCreateEvent(Logger::LogEventsAndTags tag, | 232 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 239 Code* code, int args_count); | 233 Code* code, int args_count); |
| 240 static void CodeMovingGCEvent() {} | 234 void CodeMovingGCEvent() {} |
| 241 static void CodeMoveEvent(Address from, Address to); | 235 void CodeMoveEvent(Address from, Address to); |
| 242 static void CodeDeleteEvent(Address from); | 236 void CodeDeleteEvent(Address from); |
| 243 static void GetterCallbackEvent(Name* name, Address entry_point); | 237 void GetterCallbackEvent(Name* name, Address entry_point); |
| 244 static void RegExpCodeCreateEvent(Code* code, String* source); | 238 void RegExpCodeCreateEvent(Code* code, String* source); |
| 245 static void SetterCallbackEvent(Name* name, Address entry_point); | 239 void SetterCallbackEvent(Name* name, Address entry_point); |
| 246 static void SharedFunctionInfoMoveEvent(Address from, Address to); | 240 void SharedFunctionInfoMoveEvent(Address from, Address to); |
| 247 | 241 |
| 248 static INLINE(bool is_profiling(Isolate* isolate)) { | 242 INLINE(bool is_profiling() const) { return is_profiling_; } |
| 249 CpuProfiler* profiler = isolate->cpu_profiler(); | |
| 250 return profiler != NULL && profiler->is_profiling_; | |
| 251 } | |
| 252 | 243 |
| 253 private: | 244 private: |
| 254 CpuProfiler(); | |
| 255 ~CpuProfiler(); | |
| 256 void StartCollectingProfile(const char* title, bool record_samples); | |
| 257 void StartCollectingProfile(String* title, bool record_samples); | |
| 258 void StartProcessorIfNotStarted(); | 245 void StartProcessorIfNotStarted(); |
| 259 CpuProfile* StopCollectingProfile(const char* title); | |
| 260 CpuProfile* StopCollectingProfile(Object* security_token, String* title); | |
| 261 void StopProcessorIfLastProfile(const char* title); | 246 void StopProcessorIfLastProfile(const char* title); |
| 262 void StopProcessor(); | 247 void StopProcessor(); |
| 263 void ResetProfiles(); | 248 void ResetProfiles(); |
| 264 | 249 |
| 250 Isolate* isolate_; | |
| 265 CpuProfilesCollection* profiles_; | 251 CpuProfilesCollection* profiles_; |
| 266 unsigned next_profile_uid_; | 252 unsigned next_profile_uid_; |
| 267 TokenEnumerator* token_enumerator_; | 253 TokenEnumerator* token_enumerator_; |
| 268 ProfileGenerator* generator_; | 254 ProfileGenerator* generator_; |
| 269 ProfilerEventsProcessor* processor_; | 255 ProfilerEventsProcessor* processor_; |
| 270 int saved_logging_nesting_; | 256 int saved_logging_nesting_; |
| 271 bool need_to_stop_sampler_; | 257 bool need_to_stop_sampler_; |
| 272 bool is_profiling_; | 258 bool is_profiling_; |
| 273 | 259 |
| 274 private: | 260 private: |
| 275 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 261 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 276 }; | 262 }; |
| 277 | 263 |
| 278 } } // namespace v8::internal | 264 } } // namespace v8::internal |
| 279 | 265 |
| 280 | 266 |
| 281 #endif // V8_CPU_PROFILER_H_ | 267 #endif // V8_CPU_PROFILER_H_ |
| OLD | NEW |