| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // | 62 // |
| 63 // --prof | 63 // --prof |
| 64 // Collect statistical profiling information (ticks), default is off. The | 64 // Collect statistical profiling information (ticks), default is off. The |
| 65 // tick profiler requires code events, so --prof implies --log-code. | 65 // tick profiler requires code events, so --prof implies --log-code. |
| 66 | 66 |
| 67 // Forward declarations. | 67 // Forward declarations. |
| 68 class Ticker; | 68 class Ticker; |
| 69 class Profiler; | 69 class Profiler; |
| 70 class Semaphore; | 70 class Semaphore; |
| 71 class SlidingStateWindow; | 71 class SlidingStateWindow; |
| 72 class LogMessageBuilder; |
| 72 | 73 |
| 73 #undef LOG | 74 #undef LOG |
| 74 #ifdef ENABLE_LOGGING_AND_PROFILING | 75 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 75 #define LOG(Call) \ | 76 #define LOG(Call) \ |
| 76 do { \ | 77 do { \ |
| 77 if (v8::internal::Logger::is_enabled()) \ | 78 if (v8::internal::Logger::is_enabled()) \ |
| 78 v8::internal::Logger::Call; \ | 79 v8::internal::Logger::Call; \ |
| 79 } while (false) | 80 } while (false) |
| 80 #else | 81 #else |
| 81 #define LOG(Call) ((void) 0) | 82 #define LOG(Call) ((void) 0) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 static void LogString(Handle<String> str, bool show_impl_info); | 221 static void LogString(Handle<String> str, bool show_impl_info); |
| 221 | 222 |
| 222 // Emits a profiler tick event. Used by the profiler thread. | 223 // Emits a profiler tick event. Used by the profiler thread. |
| 223 static void TickEvent(TickSample* sample, bool overflow); | 224 static void TickEvent(TickSample* sample, bool overflow); |
| 224 | 225 |
| 225 static void ApiEvent(const char* name, ...); | 226 static void ApiEvent(const char* name, ...); |
| 226 | 227 |
| 227 // Logs a StringEvent regardless of whether FLAG_log is true. | 228 // Logs a StringEvent regardless of whether FLAG_log is true. |
| 228 static void UncheckedStringEvent(const char* name, const char* value); | 229 static void UncheckedStringEvent(const char* name, const char* value); |
| 229 | 230 |
| 230 // When logging is active, logfile_ refers the file | 231 // Size of buffer used for formatting log messages. |
| 231 // events are written to. | 232 static const int kMessageBufferSize = 256; |
| 233 |
| 234 // Buffer used for formatting log messages. This is a singleton buffer and |
| 235 // mutex_ should be acquired before using it. |
| 236 static char* message_buffer_; |
| 237 |
| 238 // When logging is active, logfile_ refers the file events are written to. |
| 239 // mutex_ should be acquired before using logfile_. |
| 232 static FILE* logfile_; | 240 static FILE* logfile_; |
| 233 | 241 |
| 234 // The sampler used by the profiler and the sliding state window. | 242 // The sampler used by the profiler and the sliding state window. |
| 235 static Ticker* ticker_; | 243 static Ticker* ticker_; |
| 236 | 244 |
| 237 // When the statistical profile is active, profiler_ | 245 // When the statistical profile is active, profiler_ |
| 238 // points to a Profiler, that handles collection | 246 // points to a Profiler, that handles collection |
| 239 // of samples. | 247 // of samples. |
| 240 static Profiler* profiler_; | 248 static Profiler* profiler_; |
| 241 | 249 |
| 242 // mutex_ is a Mutex used for enforcing exclusive | 250 // mutex_ is a Mutex used for enforcing exclusive |
| 243 // access to the log file. | 251 // access to the formatting buffer and the log file. |
| 244 static Mutex* mutex_; | 252 static Mutex* mutex_; |
| 245 | 253 |
| 246 // A stack of VM states. | 254 // A stack of VM states. |
| 247 static VMState* current_state_; | 255 static VMState* current_state_; |
| 248 | 256 |
| 249 // SlidingStateWindow instance keeping a sliding window of the most | 257 // SlidingStateWindow instance keeping a sliding window of the most |
| 250 // recent VM states. | 258 // recent VM states. |
| 251 static SlidingStateWindow* sliding_state_window_; | 259 static SlidingStateWindow* sliding_state_window_; |
| 252 | 260 |
| 253 // Internal implementation classes with access to | 261 // Internal implementation classes with access to |
| 254 // private members. | 262 // private members. |
| 263 friend class LogMessageBuilder; |
| 255 friend class EventLog; | 264 friend class EventLog; |
| 256 friend class TimeLog; | 265 friend class TimeLog; |
| 257 friend class Profiler; | 266 friend class Profiler; |
| 258 friend class SlidingStateWindow; | 267 friend class SlidingStateWindow; |
| 259 friend class VMState; | 268 friend class VMState; |
| 260 #endif | 269 #endif |
| 261 }; | 270 }; |
| 262 | 271 |
| 263 | 272 |
| 264 } } // namespace v8::internal | 273 } } // namespace v8::internal |
| 265 | 274 |
| 266 #endif // V8_LOG_H_ | 275 #endif // V8_LOG_H_ |
| OLD | NEW |