| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // Forward declarations. | 72 // Forward declarations. |
| 73 class HashMap; | 73 class HashMap; |
| 74 class LogMessageBuilder; | 74 class LogMessageBuilder; |
| 75 class Profiler; | 75 class Profiler; |
| 76 class Semaphore; | 76 class Semaphore; |
| 77 class SlidingStateWindow; | 77 class SlidingStateWindow; |
| 78 class Ticker; | 78 class Ticker; |
| 79 | 79 |
| 80 #undef LOG | 80 #undef LOG |
| 81 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 82 #define LOG(isolate, Call) \ | 81 #define LOG(isolate, Call) \ |
| 83 do { \ | 82 do { \ |
| 84 v8::internal::Logger* logger = \ | 83 v8::internal::Logger* logger = \ |
| 85 (isolate)->logger(); \ | 84 (isolate)->logger(); \ |
| 86 if (logger->is_logging()) \ | 85 if (logger->is_logging()) \ |
| 87 logger->Call; \ | 86 logger->Call; \ |
| 88 } while (false) | 87 } while (false) |
| 89 #else | |
| 90 #define LOG(isolate, Call) ((void) 0) | |
| 91 #endif | |
| 92 | 88 |
| 93 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 89 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
| 94 V(CODE_CREATION_EVENT, "code-creation") \ | 90 V(CODE_CREATION_EVENT, "code-creation") \ |
| 95 V(CODE_MOVE_EVENT, "code-move") \ | 91 V(CODE_MOVE_EVENT, "code-move") \ |
| 96 V(CODE_DELETE_EVENT, "code-delete") \ | 92 V(CODE_DELETE_EVENT, "code-delete") \ |
| 97 V(CODE_MOVING_GC, "code-moving-gc") \ | 93 V(CODE_MOVING_GC, "code-moving-gc") \ |
| 98 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ | 94 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ |
| 99 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ | 95 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ |
| 100 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ | 96 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ |
| 101 V(TICK_EVENT, "tick") \ | 97 V(TICK_EVENT, "tick") \ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 150 |
| 155 // Acquires resources for logging if the right flags are set. | 151 // Acquires resources for logging if the right flags are set. |
| 156 bool Setup(); | 152 bool Setup(); |
| 157 | 153 |
| 158 void EnsureTickerStarted(); | 154 void EnsureTickerStarted(); |
| 159 void EnsureTickerStopped(); | 155 void EnsureTickerStopped(); |
| 160 | 156 |
| 161 Sampler* sampler(); | 157 Sampler* sampler(); |
| 162 | 158 |
| 163 // Frees resources acquired in Setup. | 159 // Frees resources acquired in Setup. |
| 164 void TearDown(); | 160 // When a temporary file is used for the log, returns its stream descriptor, |
| 161 // leaving the file open. |
| 162 FILE* TearDown(); |
| 165 | 163 |
| 166 // Enable the computation of a sliding window of states. | 164 // Enable the computation of a sliding window of states. |
| 167 void EnableSlidingStateWindow(); | 165 void EnableSlidingStateWindow(); |
| 168 | 166 |
| 169 // Emits an event with a string value -> (name, value). | 167 // Emits an event with a string value -> (name, value). |
| 170 void StringEvent(const char* name, const char* value); | 168 void StringEvent(const char* name, const char* value); |
| 171 | 169 |
| 172 // Emits an event with an int value -> (name, value). | 170 // Emits an event with an int value -> (name, value). |
| 173 void IntEvent(const char* name, int value); | 171 void IntEvent(const char* name, int value); |
| 174 void IntPtrTEvent(const char* name, intptr_t value); | 172 void IntPtrTEvent(const char* name, intptr_t value); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 uintptr_t end); | 263 uintptr_t end); |
| 266 | 264 |
| 267 // ==== Events logged by --log-regexp ==== | 265 // ==== Events logged by --log-regexp ==== |
| 268 // Regexp compilation and execution events. | 266 // Regexp compilation and execution events. |
| 269 | 267 |
| 270 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 268 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 271 | 269 |
| 272 // Log an event reported from generated code | 270 // Log an event reported from generated code |
| 273 void LogRuntime(Vector<const char> format, JSArray* args); | 271 void LogRuntime(Vector<const char> format, JSArray* args); |
| 274 | 272 |
| 275 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 276 bool is_logging() { | 273 bool is_logging() { |
| 277 return logging_nesting_ > 0; | 274 return logging_nesting_ > 0; |
| 278 } | 275 } |
| 279 | 276 |
| 280 // Pause/Resume collection of profiling data. | 277 // Pause/Resume collection of profiling data. |
| 281 // When data collection is paused, CPU Tick events are discarded until | 278 // When data collection is paused, CPU Tick events are discarded until |
| 282 // data collection is Resumed. | 279 // data collection is Resumed. |
| 283 void PauseProfiler(); | 280 void PauseProfiler(); |
| 284 void ResumeProfiler(); | 281 void ResumeProfiler(); |
| 285 bool IsProfilerPaused(); | 282 bool IsProfilerPaused(); |
| 286 | 283 |
| 287 // If logging is performed into a memory buffer, allows to | |
| 288 // retrieve previously written messages. See v8.h. | |
| 289 int GetLogLines(int from_pos, char* dest_buf, int max_size); | |
| 290 | |
| 291 // Logs all compiled functions found in the heap. | 284 // Logs all compiled functions found in the heap. |
| 292 void LogCompiledFunctions(); | 285 void LogCompiledFunctions(); |
| 293 // Logs all accessor callbacks found in the heap. | 286 // Logs all accessor callbacks found in the heap. |
| 294 void LogAccessorCallbacks(); | 287 void LogAccessorCallbacks(); |
| 295 // Used for logging stubs found in the snapshot. | 288 // Used for logging stubs found in the snapshot. |
| 296 void LogCodeObjects(); | 289 void LogCodeObjects(); |
| 297 | 290 |
| 298 // Converts tag to a corresponding NATIVE_... if the script is native. | 291 // Converts tag to a corresponding NATIVE_... if the script is native. |
| 299 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); | 292 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); |
| 300 | 293 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 Address last_address_; | 410 Address last_address_; |
| 418 // Logger::TickEvent(...) | 411 // Logger::TickEvent(...) |
| 419 Address prev_sp_; | 412 Address prev_sp_; |
| 420 Address prev_function_; | 413 Address prev_function_; |
| 421 // Logger::MoveEventInternal(...) | 414 // Logger::MoveEventInternal(...) |
| 422 Address prev_to_; | 415 Address prev_to_; |
| 423 // Logger::FunctionCreateEvent(...) | 416 // Logger::FunctionCreateEvent(...) |
| 424 Address prev_code_; | 417 Address prev_code_; |
| 425 | 418 |
| 426 friend class CpuProfiler; | 419 friend class CpuProfiler; |
| 427 #else | |
| 428 bool is_logging() { return false; } | |
| 429 #endif | |
| 430 }; | 420 }; |
| 431 | 421 |
| 432 | 422 |
| 433 // Process wide registry of samplers. | 423 // Process wide registry of samplers. |
| 434 class SamplerRegistry : public AllStatic { | 424 class SamplerRegistry : public AllStatic { |
| 435 public: | 425 public: |
| 436 enum State { | 426 enum State { |
| 437 HAS_NO_SAMPLERS, | 427 HAS_NO_SAMPLERS, |
| 438 HAS_SAMPLERS, | 428 HAS_SAMPLERS, |
| 439 HAS_CPU_PROFILING_SAMPLERS | 429 HAS_CPU_PROFILING_SAMPLERS |
| (...skipping 26 matching lines...) Expand all Loading... |
| 466 // Class that extracts stack trace, used for profiling. | 456 // Class that extracts stack trace, used for profiling. |
| 467 class StackTracer : public AllStatic { | 457 class StackTracer : public AllStatic { |
| 468 public: | 458 public: |
| 469 static void Trace(Isolate* isolate, TickSample* sample); | 459 static void Trace(Isolate* isolate, TickSample* sample); |
| 470 }; | 460 }; |
| 471 | 461 |
| 472 } } // namespace v8::internal | 462 } } // namespace v8::internal |
| 473 | 463 |
| 474 | 464 |
| 475 #endif // V8_LOG_H_ | 465 #endif // V8_LOG_H_ |
| OLD | NEW |