| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #define LOG_CODE_EVENT(isolate, Call) \ | 82 #define LOG_CODE_EVENT(isolate, Call) \ |
| 83 do { \ | 83 do { \ |
| 84 v8::internal::Logger* logger = (isolate)->logger(); \ | 84 v8::internal::Logger* logger = (isolate)->logger(); \ |
| 85 if (logger->is_logging_code_events()) logger->Call; \ | 85 if (logger->is_logging_code_events()) logger->Call; \ |
| 86 } while (false) | 86 } while (false) |
| 87 | 87 |
| 88 class JitLogger; | 88 class JitLogger; |
| 89 class PerfBasicLogger; | 89 class PerfBasicLogger; |
| 90 class LowLevelLogger; | 90 class LowLevelLogger; |
| 91 class PerfJitLogger; | 91 class PerfJitLogger; |
| 92 class ProfilerListener; | |
| 93 | 92 |
| 94 class Logger : public CodeEventListener { | 93 class Logger : public CodeEventListener { |
| 95 public: | 94 public: |
| 96 enum StartEnd { START = 0, END = 1 }; | 95 enum StartEnd { START = 0, END = 1 }; |
| 97 | 96 |
| 98 // Acquires resources for logging if the right flags are set. | 97 // Acquires resources for logging if the right flags are set. |
| 99 bool SetUp(Isolate* isolate); | 98 bool SetUp(Isolate* isolate); |
| 100 | 99 |
| 101 // Sets the current code event handler. | 100 // Sets the current code event handler. |
| 102 void SetCodeEventHandler(uint32_t options, | 101 void SetCodeEventHandler(uint32_t options, |
| 103 JitCodeEventHandler event_handler); | 102 JitCodeEventHandler event_handler); |
| 104 | 103 |
| 105 // Sets up ProfilerListener. | |
| 106 void SetUpProfilerListener(); | |
| 107 | |
| 108 // Tear down ProfilerListener if it has no observers. | |
| 109 void TearDownProfilerListener(); | |
| 110 | |
| 111 sampler::Sampler* sampler(); | 104 sampler::Sampler* sampler(); |
| 112 | 105 |
| 113 ProfilerListener* profiler_listener() { return profiler_listener_.get(); } | |
| 114 | |
| 115 // Frees resources acquired in SetUp. | 106 // Frees resources acquired in SetUp. |
| 116 // When a temporary file is used for the log, returns its stream descriptor, | 107 // When a temporary file is used for the log, returns its stream descriptor, |
| 117 // leaving the file open. | 108 // leaving the file open. |
| 118 FILE* TearDown(); | 109 FILE* TearDown(); |
| 119 | 110 |
| 120 // Emits an event with a string value -> (name, value). | 111 // Emits an event with a string value -> (name, value). |
| 121 void StringEvent(const char* name, const char* value); | 112 void StringEvent(const char* name, const char* value); |
| 122 | 113 |
| 123 // Emits an event with an int value -> (name, value). | 114 // Emits an event with an int value -> (name, value). |
| 124 void IntEvent(const char* name, int value); | 115 void IntEvent(const char* name, int value); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 friend class Profiler; | 325 friend class Profiler; |
| 335 template <StateTag Tag> friend class VMState; | 326 template <StateTag Tag> friend class VMState; |
| 336 friend class LoggerTestHelper; | 327 friend class LoggerTestHelper; |
| 337 | 328 |
| 338 bool is_logging_; | 329 bool is_logging_; |
| 339 Log* log_; | 330 Log* log_; |
| 340 PerfBasicLogger* perf_basic_logger_; | 331 PerfBasicLogger* perf_basic_logger_; |
| 341 PerfJitLogger* perf_jit_logger_; | 332 PerfJitLogger* perf_jit_logger_; |
| 342 LowLevelLogger* ll_logger_; | 333 LowLevelLogger* ll_logger_; |
| 343 JitLogger* jit_logger_; | 334 JitLogger* jit_logger_; |
| 344 std::unique_ptr<ProfilerListener> profiler_listener_; | |
| 345 List<CodeEventListener*> listeners_; | 335 List<CodeEventListener*> listeners_; |
| 346 | 336 |
| 347 // Guards against multiple calls to TearDown() that can happen in some tests. | 337 // Guards against multiple calls to TearDown() that can happen in some tests. |
| 348 // 'true' between SetUp() and TearDown(). | 338 // 'true' between SetUp() and TearDown(). |
| 349 bool is_initialized_; | 339 bool is_initialized_; |
| 350 | 340 |
| 351 base::ElapsedTimer timer_; | 341 base::ElapsedTimer timer_; |
| 352 | 342 |
| 353 friend class CpuProfiler; | 343 friend class CpuProfiler; |
| 354 }; | 344 }; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 434 |
| 445 NameBuffer* name_buffer_; | 435 NameBuffer* name_buffer_; |
| 446 }; | 436 }; |
| 447 | 437 |
| 448 | 438 |
| 449 } // namespace internal | 439 } // namespace internal |
| 450 } // namespace v8 | 440 } // namespace v8 |
| 451 | 441 |
| 452 | 442 |
| 453 #endif // V8_LOG_H_ | 443 #endif // V8_LOG_H_ |
| OLD | NEW |