| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 72 |
| 73 #undef LOG | 73 #undef LOG |
| 74 #ifdef ENABLE_LOGGING_AND_PROFILING | 74 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 75 #define LOG(Call) v8::internal::Logger::Call | 75 #define LOG(Call) \ |
| 76 do { \ |
| 77 if (v8::internal::Logger::is_enabled()) \ |
| 78 v8::internal::Logger::Call; \ |
| 79 } while (false) |
| 76 #else | 80 #else |
| 77 #define LOG(Call) ((void) 0) | 81 #define LOG(Call) ((void) 0) |
| 78 #endif | 82 #endif |
| 79 | 83 |
| 80 | 84 |
| 81 class VMState { | 85 class VMState { |
| 82 #ifdef ENABLE_LOGGING_AND_PROFILING | 86 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 83 public: | 87 public: |
| 84 explicit VMState(StateTag state); | 88 explicit VMState(StateTag state); |
| 85 ~VMState(); | 89 ~VMState(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 unsigned end); | 186 unsigned end); |
| 183 static void SharedLibraryEvent(const wchar_t* library_path, | 187 static void SharedLibraryEvent(const wchar_t* library_path, |
| 184 unsigned start, | 188 unsigned start, |
| 185 unsigned end); | 189 unsigned end); |
| 186 | 190 |
| 187 // ==== Events logged by --log-regexp ==== | 191 // ==== Events logged by --log-regexp ==== |
| 188 // Regexp compilation and execution events. | 192 // Regexp compilation and execution events. |
| 189 | 193 |
| 190 static void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 194 static void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 191 | 195 |
| 192 static void RegExpExecEvent(Handle<JSRegExp> regexp, | 196 // Log an event reported from generated code |
| 193 int start_index, | 197 static void LogRuntime(Vector<const char> format, JSArray* args); |
| 194 Handle<String> input_string); | |
| 195 | 198 |
| 196 #ifdef ENABLE_LOGGING_AND_PROFILING | 199 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 197 static StateTag state() { | 200 static StateTag state() { |
| 198 return current_state_ ? current_state_->state() : OTHER; | 201 return current_state_ ? current_state_->state() : OTHER; |
| 199 } | 202 } |
| 200 #endif | 203 #endif |
| 201 | 204 |
| 205 static bool is_enabled() { return logfile_ != NULL; } |
| 206 |
| 202 #ifdef ENABLE_LOGGING_AND_PROFILING | 207 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 203 private: | 208 private: |
| 204 | 209 |
| 205 // Emits the source code of a regexp. Used by regexp events. | 210 // Emits the source code of a regexp. Used by regexp events. |
| 206 static void LogRegExpSource(Handle<JSRegExp> regexp); | 211 static void LogRegExpSource(Handle<JSRegExp> regexp); |
| 207 | 212 |
| 208 static void LogString(Handle<String> str); | 213 static void LogString(Handle<String> str, bool show_impl_info); |
| 209 | 214 |
| 210 // Emits a profiler tick event. Used by the profiler thread. | 215 // Emits a profiler tick event. Used by the profiler thread. |
| 211 static void TickEvent(TickSample* sample, bool overflow); | 216 static void TickEvent(TickSample* sample, bool overflow); |
| 212 | 217 |
| 213 static void ApiEvent(const char* name, ...); | 218 static void ApiEvent(const char* name, ...); |
| 214 | 219 |
| 215 // When logging is active, logfile_ refers the file | 220 // When logging is active, logfile_ refers the file |
| 216 // events are written to. | 221 // events are written to. |
| 217 static FILE* logfile_; | 222 static FILE* logfile_; |
| 218 | 223 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 242 friend class Profiler; | 247 friend class Profiler; |
| 243 friend class SlidingStateWindow; | 248 friend class SlidingStateWindow; |
| 244 friend class VMState; | 249 friend class VMState; |
| 245 #endif | 250 #endif |
| 246 }; | 251 }; |
| 247 | 252 |
| 248 | 253 |
| 249 } } // namespace v8::internal | 254 } } // namespace v8::internal |
| 250 | 255 |
| 251 #endif // V8_LOG_H_ | 256 #endif // V8_LOG_H_ |
| OLD | NEW |