| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_LOG_H_ | 5 #ifndef V8_LOG_H_ |
| 6 #define V8_LOG_H_ | 6 #define V8_LOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 | 145 |
| 146 class JitLogger; | 146 class JitLogger; |
| 147 class PerfBasicLogger; | 147 class PerfBasicLogger; |
| 148 class LowLevelLogger; | 148 class LowLevelLogger; |
| 149 class PerfJitLogger; | 149 class PerfJitLogger; |
| 150 class Sampler; | 150 class Sampler; |
| 151 | 151 |
| 152 class Logger { | 152 class Logger { |
| 153 public: | 153 public: |
| 154 enum StartEnd { START = 0, END = 1 }; |
| 155 |
| 154 #define DECLARE_ENUM(enum_item, ignore) enum_item, | 156 #define DECLARE_ENUM(enum_item, ignore) enum_item, |
| 155 enum LogEventsAndTags { | 157 enum LogEventsAndTags { |
| 156 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) | 158 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
| 157 NUMBER_OF_LOG_EVENTS | 159 NUMBER_OF_LOG_EVENTS |
| 158 }; | 160 }; |
| 159 #undef DECLARE_ENUM | 161 #undef DECLARE_ENUM |
| 160 | 162 |
| 161 // Acquires resources for logging if the right flags are set. | 163 // Acquires resources for logging if the right flags are set. |
| 162 bool SetUp(Isolate* isolate); | 164 bool SetUp(Isolate* isolate); |
| 163 | 165 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const char* event); | 285 const char* event); |
| 284 void HeapSampleJSProducerEvent(const char* constructor, | 286 void HeapSampleJSProducerEvent(const char* constructor, |
| 285 Address* stack); | 287 Address* stack); |
| 286 void HeapSampleStats(const char* space, const char* kind, | 288 void HeapSampleStats(const char* space, const char* kind, |
| 287 intptr_t capacity, intptr_t used); | 289 intptr_t capacity, intptr_t used); |
| 288 | 290 |
| 289 void SharedLibraryEvent(const std::string& library_path, | 291 void SharedLibraryEvent(const std::string& library_path, |
| 290 uintptr_t start, | 292 uintptr_t start, |
| 291 uintptr_t end); | 293 uintptr_t end); |
| 292 | 294 |
| 293 // ==== Events logged by --log-timer-events. ==== | |
| 294 enum StartEnd { START, END }; | |
| 295 | |
| 296 void CodeDeoptEvent(Code* code); | 295 void CodeDeoptEvent(Code* code); |
| 297 void CurrentTimeEvent(); | 296 void CurrentTimeEvent(); |
| 298 | 297 |
| 299 void TimerEvent(StartEnd se, const char* name); | 298 void TimerEvent(StartEnd se, const char* name); |
| 300 | 299 |
| 301 static void EnterExternal(Isolate* isolate); | 300 static void EnterExternal(Isolate* isolate); |
| 302 static void LeaveExternal(Isolate* isolate); | 301 static void LeaveExternal(Isolate* isolate); |
| 303 | 302 |
| 304 static void EmptyLogInternalEvents(const char* name, int se) { } | 303 static void EmptyTimerEventsLogger(const char* name, int se) {} |
| 305 static void LogInternalEvents(const char* name, int se); | 304 static void DefaultTimerEventsLogger(const char* name, int se); |
| 306 | |
| 307 class TimerEventScope { | |
| 308 public: | |
| 309 TimerEventScope(Isolate* isolate, const char* name) | |
| 310 : isolate_(isolate), name_(name) { | |
| 311 LogTimerEvent(START); | |
| 312 } | |
| 313 | |
| 314 ~TimerEventScope() { | |
| 315 LogTimerEvent(END); | |
| 316 } | |
| 317 | |
| 318 void LogTimerEvent(StartEnd se); | |
| 319 | |
| 320 static const char* v8_recompile_synchronous; | |
| 321 static const char* v8_recompile_concurrent; | |
| 322 static const char* v8_compile_full_code; | |
| 323 static const char* v8_execute; | |
| 324 static const char* v8_external; | |
| 325 static const char* v8_ic_miss; | |
| 326 | |
| 327 private: | |
| 328 Isolate* isolate_; | |
| 329 const char* name_; | |
| 330 }; | |
| 331 | 305 |
| 332 // ==== Events logged by --log-regexp ==== | 306 // ==== Events logged by --log-regexp ==== |
| 333 // Regexp compilation and execution events. | 307 // Regexp compilation and execution events. |
| 334 | 308 |
| 335 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 309 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 336 | 310 |
| 337 bool is_logging() { | 311 bool is_logging() { |
| 338 return is_logging_; | 312 return is_logging_; |
| 339 } | 313 } |
| 340 | 314 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // Guards against multiple calls to TearDown() that can happen in some tests. | 413 // Guards against multiple calls to TearDown() that can happen in some tests. |
| 440 // 'true' between SetUp() and TearDown(). | 414 // 'true' between SetUp() and TearDown(). |
| 441 bool is_initialized_; | 415 bool is_initialized_; |
| 442 | 416 |
| 443 base::ElapsedTimer timer_; | 417 base::ElapsedTimer timer_; |
| 444 | 418 |
| 445 friend class CpuProfiler; | 419 friend class CpuProfiler; |
| 446 }; | 420 }; |
| 447 | 421 |
| 448 | 422 |
| 423 #define TIMER_EVENTS_LIST(V) \ |
| 424 V(RecompileSynchronous, true) \ |
| 425 V(RecompileConcurrent, true) \ |
| 426 V(CompileFullCode, true) \ |
| 427 V(Execute, true) \ |
| 428 V(External, true) \ |
| 429 V(IcMiss, false) |
| 430 |
| 431 #define V(TimerName, expose) \ |
| 432 class TimerEvent##TimerName : public AllStatic { \ |
| 433 public: \ |
| 434 static const char* name(void* unused = NULL) { return "V8." #TimerName; } \ |
| 435 static bool expose_to_api() { return expose; } \ |
| 436 }; |
| 437 TIMER_EVENTS_LIST(V) |
| 438 #undef V |
| 439 |
| 440 |
| 441 template <class TimerEvent> |
| 442 class TimerEventScope { |
| 443 public: |
| 444 explicit TimerEventScope(Isolate* isolate) : isolate_(isolate) { |
| 445 LogTimerEvent(Logger::START); |
| 446 } |
| 447 |
| 448 ~TimerEventScope() { LogTimerEvent(Logger::END); } |
| 449 |
| 450 void LogTimerEvent(Logger::StartEnd se); |
| 451 |
| 452 private: |
| 453 Isolate* isolate_; |
| 454 }; |
| 455 |
| 456 |
| 449 class CodeEventListener { | 457 class CodeEventListener { |
| 450 public: | 458 public: |
| 451 virtual ~CodeEventListener() {} | 459 virtual ~CodeEventListener() {} |
| 452 | 460 |
| 453 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 461 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 454 Code* code, | 462 Code* code, |
| 455 const char* comment) = 0; | 463 const char* comment) = 0; |
| 456 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 464 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 457 Code* code, | 465 Code* code, |
| 458 Name* name) = 0; | 466 Name* name) = 0; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 int length) = 0; | 532 int length) = 0; |
| 525 | 533 |
| 526 NameBuffer* name_buffer_; | 534 NameBuffer* name_buffer_; |
| 527 }; | 535 }; |
| 528 | 536 |
| 529 | 537 |
| 530 } } // namespace v8::internal | 538 } } // namespace v8::internal |
| 531 | 539 |
| 532 | 540 |
| 533 #endif // V8_LOG_H_ | 541 #endif // V8_LOG_H_ |
| OLD | NEW |