| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 #undef LOG | 80 #undef LOG |
| 81 #define LOG(isolate, Call) \ | 81 #define LOG(isolate, Call) \ |
| 82 do { \ | 82 do { \ |
| 83 v8::internal::Logger* logger = \ | 83 v8::internal::Logger* logger = \ |
| 84 (isolate)->logger(); \ | 84 (isolate)->logger(); \ |
| 85 if (logger->is_logging()) \ | 85 if (logger->is_logging()) \ |
| 86 logger->Call; \ | 86 logger->Call; \ |
| 87 } while (false) | 87 } while (false) |
| 88 | 88 |
| 89 #define LOG_CODE_EVENT(isolate, Call) \ | |
| 90 do { \ | |
| 91 v8::internal::Logger* logger = \ | |
| 92 (isolate)->logger(); \ | |
| 93 if (logger->is_logging_code_events()) \ | |
| 94 logger->Call; \ | |
| 95 } while (false) | |
| 96 | |
| 97 | |
| 98 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 89 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
| 99 V(CODE_CREATION_EVENT, "code-creation") \ | 90 V(CODE_CREATION_EVENT, "code-creation") \ |
| 100 V(CODE_MOVE_EVENT, "code-move") \ | 91 V(CODE_MOVE_EVENT, "code-move") \ |
| 101 V(CODE_DELETE_EVENT, "code-delete") \ | 92 V(CODE_DELETE_EVENT, "code-delete") \ |
| 102 V(CODE_MOVING_GC, "code-moving-gc") \ | 93 V(CODE_MOVING_GC, "code-moving-gc") \ |
| 103 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ | 94 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ |
| 104 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ | 95 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ |
| 105 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ | 96 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ |
| 106 V(TICK_EVENT, "tick") \ | 97 V(TICK_EVENT, "tick") \ |
| 107 V(REPEAT_META_EVENT, "repeat") \ | 98 V(REPEAT_META_EVENT, "repeat") \ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 #define DECLARE_ENUM(enum_item, ignore) enum_item, | 144 #define DECLARE_ENUM(enum_item, ignore) enum_item, |
| 154 enum LogEventsAndTags { | 145 enum LogEventsAndTags { |
| 155 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) | 146 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
| 156 NUMBER_OF_LOG_EVENTS | 147 NUMBER_OF_LOG_EVENTS |
| 157 }; | 148 }; |
| 158 #undef DECLARE_ENUM | 149 #undef DECLARE_ENUM |
| 159 | 150 |
| 160 // Acquires resources for logging if the right flags are set. | 151 // Acquires resources for logging if the right flags are set. |
| 161 bool SetUp(); | 152 bool SetUp(); |
| 162 | 153 |
| 163 // Sets the current code event handler. | |
| 164 void SetCodeEventHandler(uint32_t options, | |
| 165 JitCodeEventHandler event_handler); | |
| 166 | |
| 167 void EnsureTickerStarted(); | 154 void EnsureTickerStarted(); |
| 168 void EnsureTickerStopped(); | 155 void EnsureTickerStopped(); |
| 169 | 156 |
| 170 Sampler* sampler(); | 157 Sampler* sampler(); |
| 171 | 158 |
| 172 // Frees resources acquired in SetUp. | 159 // Frees resources acquired in SetUp. |
| 173 // When a temporary file is used for the log, returns its stream descriptor, | 160 // When a temporary file is used for the log, returns its stream descriptor, |
| 174 // leaving the file open. | 161 // leaving the file open. |
| 175 FILE* TearDown(); | 162 FILE* TearDown(); |
| 176 | 163 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 267 |
| 281 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 268 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 282 | 269 |
| 283 // Log an event reported from generated code | 270 // Log an event reported from generated code |
| 284 void LogRuntime(Vector<const char> format, JSArray* args); | 271 void LogRuntime(Vector<const char> format, JSArray* args); |
| 285 | 272 |
| 286 bool is_logging() { | 273 bool is_logging() { |
| 287 return logging_nesting_ > 0; | 274 return logging_nesting_ > 0; |
| 288 } | 275 } |
| 289 | 276 |
| 290 bool is_logging_code_events() { | |
| 291 return is_logging() || code_event_handler_ != NULL; | |
| 292 } | |
| 293 | |
| 294 // Pause/Resume collection of profiling data. | 277 // Pause/Resume collection of profiling data. |
| 295 // When data collection is paused, CPU Tick events are discarded until | 278 // When data collection is paused, CPU Tick events are discarded until |
| 296 // data collection is Resumed. | 279 // data collection is Resumed. |
| 297 void PauseProfiler(); | 280 void PauseProfiler(); |
| 298 void ResumeProfiler(); | 281 void ResumeProfiler(); |
| 299 bool IsProfilerPaused(); | 282 bool IsProfilerPaused(); |
| 300 | 283 |
| 301 void LogExistingFunction(Handle<SharedFunctionInfo> shared, | 284 void LogExistingFunction(Handle<SharedFunctionInfo> shared, |
| 302 Handle<Code> code); | 285 Handle<Code> code); |
| 303 // Logs all compiled functions found in the heap. | 286 // Logs all compiled functions found in the heap. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 322 // Callback from Log, stops profiling in case of insufficient resources. | 305 // Callback from Log, stops profiling in case of insufficient resources. |
| 323 void LogFailure(); | 306 void LogFailure(); |
| 324 | 307 |
| 325 private: | 308 private: |
| 326 class NameBuffer; | 309 class NameBuffer; |
| 327 class NameMap; | 310 class NameMap; |
| 328 | 311 |
| 329 Logger(); | 312 Logger(); |
| 330 ~Logger(); | 313 ~Logger(); |
| 331 | 314 |
| 332 // Issue code notifications. | |
| 333 void IssueCodeAddedEvent(Code* code, const char* name, size_t name_len); | |
| 334 void IssueCodeMovedEvent(Address from, Address to); | |
| 335 void IssueCodeRemovedEvent(Address from); | |
| 336 | |
| 337 // Emits the profiler's first message. | 315 // Emits the profiler's first message. |
| 338 void ProfilerBeginEvent(); | 316 void ProfilerBeginEvent(); |
| 339 | 317 |
| 340 // Emits callback event messages. | 318 // Emits callback event messages. |
| 341 void CallbackEventInternal(const char* prefix, | 319 void CallbackEventInternal(const char* prefix, |
| 342 const char* name, | 320 const char* name, |
| 343 Address entry_point); | 321 Address entry_point); |
| 344 | 322 |
| 345 // Internal configurable move event. | 323 // Internal configurable move event. |
| 346 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); | 324 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 Log* log_; | 406 Log* log_; |
| 429 | 407 |
| 430 NameBuffer* name_buffer_; | 408 NameBuffer* name_buffer_; |
| 431 | 409 |
| 432 NameMap* address_to_name_map_; | 410 NameMap* address_to_name_map_; |
| 433 | 411 |
| 434 // Guards against multiple calls to TearDown() that can happen in some tests. | 412 // Guards against multiple calls to TearDown() that can happen in some tests. |
| 435 // 'true' between SetUp() and TearDown(). | 413 // 'true' between SetUp() and TearDown(). |
| 436 bool is_initialized_; | 414 bool is_initialized_; |
| 437 | 415 |
| 438 // The code event handler - if any. | |
| 439 JitCodeEventHandler code_event_handler_; | |
| 440 | |
| 441 // Support for 'incremental addresses' in compressed logs: | 416 // Support for 'incremental addresses' in compressed logs: |
| 442 // LogMessageBuilder::AppendAddress(Address addr) | 417 // LogMessageBuilder::AppendAddress(Address addr) |
| 443 Address last_address_; | 418 Address last_address_; |
| 444 // Logger::TickEvent(...) | 419 // Logger::TickEvent(...) |
| 445 Address prev_sp_; | 420 Address prev_sp_; |
| 446 Address prev_function_; | 421 Address prev_function_; |
| 447 // Logger::MoveEventInternal(...) | 422 // Logger::MoveEventInternal(...) |
| 448 Address prev_to_; | 423 Address prev_to_; |
| 449 // Logger::FunctionCreateEvent(...) | 424 // Logger::FunctionCreateEvent(...) |
| 450 Address prev_code_; | 425 Address prev_code_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // Class that extracts stack trace, used for profiling. | 465 // Class that extracts stack trace, used for profiling. |
| 491 class StackTracer : public AllStatic { | 466 class StackTracer : public AllStatic { |
| 492 public: | 467 public: |
| 493 static void Trace(Isolate* isolate, TickSample* sample); | 468 static void Trace(Isolate* isolate, TickSample* sample); |
| 494 }; | 469 }; |
| 495 | 470 |
| 496 } } // namespace v8::internal | 471 } } // namespace v8::internal |
| 497 | 472 |
| 498 | 473 |
| 499 #endif // V8_LOG_H_ | 474 #endif // V8_LOG_H_ |
| OLD | NEW |