| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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_LOG_H_ | 28 #ifndef V8_LOG_H_ |
| 29 #define V8_LOG_H_ | 29 #define V8_LOG_H_ |
| 30 | 30 |
| 31 #include "platform.h" |
| 32 #include "log-utils.h" |
| 33 |
| 31 namespace v8 { | 34 namespace v8 { |
| 32 namespace internal { | 35 namespace internal { |
| 33 | 36 |
| 34 // Logger is used for collecting logging information from V8 during | 37 // Logger is used for collecting logging information from V8 during |
| 35 // execution. The result is dumped to a file. | 38 // execution. The result is dumped to a file. |
| 36 // | 39 // |
| 37 // Available command line flags: | 40 // Available command line flags: |
| 38 // | 41 // |
| 39 // --log | 42 // --log |
| 40 // Minimal logging (no API, code, or GC sample events), default is off. | 43 // Minimal logging (no API, code, or GC sample events), default is off. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 70 class Profiler; | 73 class Profiler; |
| 71 class Semaphore; | 74 class Semaphore; |
| 72 class SlidingStateWindow; | 75 class SlidingStateWindow; |
| 73 class LogMessageBuilder; | 76 class LogMessageBuilder; |
| 74 class CompressionHelper; | 77 class CompressionHelper; |
| 75 | 78 |
| 76 #undef LOG | 79 #undef LOG |
| 77 #ifdef ENABLE_LOGGING_AND_PROFILING | 80 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 78 #define LOG(Call) \ | 81 #define LOG(Call) \ |
| 79 do { \ | 82 do { \ |
| 80 if (v8::internal::Logger::IsEnabled()) \ | 83 if (v8::internal::Logger::is_logging()) \ |
| 81 v8::internal::Logger::Call; \ | 84 v8::internal::Logger::Call; \ |
| 82 } while (false) | 85 } while (false) |
| 83 #else | 86 #else |
| 84 #define LOG(Call) ((void) 0) | 87 #define LOG(Call) ((void) 0) |
| 85 #endif | 88 #endif |
| 86 | 89 |
| 87 | 90 |
| 88 class VMState BASE_EMBEDDED { | 91 class VMState BASE_EMBEDDED { |
| 89 #ifdef ENABLE_LOGGING_AND_PROFILING | 92 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 90 public: | 93 public: |
| 91 explicit VMState(StateTag state); | 94 inline explicit VMState(StateTag state); |
| 92 ~VMState(); | 95 inline ~VMState(); |
| 93 | 96 |
| 94 StateTag state() { return state_; } | 97 StateTag state() { return state_; } |
| 95 | 98 |
| 96 private: | 99 private: |
| 100 bool disabled_; |
| 97 StateTag state_; | 101 StateTag state_; |
| 98 VMState* previous_; | 102 VMState* previous_; |
| 99 #else | 103 #else |
| 100 public: | 104 public: |
| 101 explicit VMState(StateTag state) {} | 105 explicit VMState(StateTag state) {} |
| 102 #endif | 106 #endif |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 | 109 |
| 106 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 110 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 static void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 233 static void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 230 | 234 |
| 231 // Log an event reported from generated code | 235 // Log an event reported from generated code |
| 232 static void LogRuntime(Vector<const char> format, JSArray* args); | 236 static void LogRuntime(Vector<const char> format, JSArray* args); |
| 233 | 237 |
| 234 #ifdef ENABLE_LOGGING_AND_PROFILING | 238 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 235 static StateTag state() { | 239 static StateTag state() { |
| 236 return current_state_ ? current_state_->state() : OTHER; | 240 return current_state_ ? current_state_->state() : OTHER; |
| 237 } | 241 } |
| 238 | 242 |
| 239 static bool IsEnabled(); | 243 static bool is_logging() { |
| 244 return is_logging_; |
| 245 } |
| 240 | 246 |
| 241 // Pause/Resume collection of profiling data. | 247 // Pause/Resume collection of profiling data. |
| 242 // When data collection is paused, Tick events are discarded until | 248 // When data collection is paused, Tick events are discarded until |
| 243 // data collection is Resumed. | 249 // data collection is Resumed. |
| 244 static bool IsProfilerPaused(); | 250 static bool IsProfilerPaused(); |
| 245 static void PauseProfiler(); | 251 static void PauseProfiler(); |
| 246 static void ResumeProfiler(); | 252 static void ResumeProfiler(); |
| 247 | 253 |
| 248 // If logging is performed into a memory buffer, allows to | 254 // If logging is performed into a memory buffer, allows to |
| 249 // retrieve previously written messages. See v8.h. | 255 // retrieve previously written messages. See v8.h. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // Internal implementation classes with access to | 316 // Internal implementation classes with access to |
| 311 // private members. | 317 // private members. |
| 312 friend class CompressionHelper; | 318 friend class CompressionHelper; |
| 313 friend class EventLog; | 319 friend class EventLog; |
| 314 friend class TimeLog; | 320 friend class TimeLog; |
| 315 friend class Profiler; | 321 friend class Profiler; |
| 316 friend class SlidingStateWindow; | 322 friend class SlidingStateWindow; |
| 317 friend class VMState; | 323 friend class VMState; |
| 318 | 324 |
| 319 friend class LoggerTestHelper; | 325 friend class LoggerTestHelper; |
| 326 |
| 327 static bool is_logging_; |
| 320 #else | 328 #else |
| 321 static bool is_enabled() { return false; } | 329 static bool is_logging() { return false; } |
| 322 #endif | 330 #endif |
| 323 }; | 331 }; |
| 324 | 332 |
| 325 | 333 |
| 326 // Class that extracts stack trace, used for profiling. | 334 // Class that extracts stack trace, used for profiling. |
| 327 class StackTracer : public AllStatic { | 335 class StackTracer : public AllStatic { |
| 328 public: | 336 public: |
| 329 static void Trace(TickSample* sample); | 337 static void Trace(TickSample* sample); |
| 330 }; | 338 }; |
| 331 | 339 |
| 332 | 340 |
| 333 } } // namespace v8::internal | 341 } } // namespace v8::internal |
| 334 | 342 |
| 335 #endif // V8_LOG_H_ | 343 #endif // V8_LOG_H_ |
| OLD | NEW |