| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // --log-regexp implies --log. | 63 // --log-regexp implies --log. |
| 64 // | 64 // |
| 65 // --logfile <filename> | 65 // --logfile <filename> |
| 66 // Specify the name of the logfile, default is "v8.log". | 66 // Specify the name of the logfile, default is "v8.log". |
| 67 // | 67 // |
| 68 // --prof | 68 // --prof |
| 69 // Collect statistical profiling information (ticks), default is off. The | 69 // Collect statistical profiling information (ticks), default is off. The |
| 70 // tick profiler requires code events, so --prof implies --log-code. | 70 // tick profiler requires code events, so --prof implies --log-code. |
| 71 | 71 |
| 72 // Forward declarations. | 72 // Forward declarations. |
| 73 class CodeAddressMap; | 73 class CodeEventListener; |
| 74 class CompilationInfo; | 74 class CompilationInfo; |
| 75 class CpuProfiler; | 75 class CpuProfiler; |
| 76 class Isolate; | 76 class Isolate; |
| 77 class Log; | 77 class Log; |
| 78 class PositionsRecorder; | 78 class PositionsRecorder; |
| 79 class Profiler; | 79 class Profiler; |
| 80 class Semaphore; | 80 class Semaphore; |
| 81 class Ticker; | 81 class Ticker; |
| 82 struct TickSample; | 82 struct TickSample; |
| 83 | 83 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ | 148 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ |
| 149 V(NATIVE_SCRIPT_TAG, "Script") | 149 V(NATIVE_SCRIPT_TAG, "Script") |
| 150 // Note that 'NATIVE_' cases for functions and scripts are mapped onto | 150 // Note that 'NATIVE_' cases for functions and scripts are mapped onto |
| 151 // original tags when writing to the log. | 151 // original tags when writing to the log. |
| 152 | 152 |
| 153 | 153 |
| 154 class JitLogger; | 154 class JitLogger; |
| 155 class LowLevelLogger; | 155 class LowLevelLogger; |
| 156 class Sampler; | 156 class Sampler; |
| 157 | 157 |
| 158 | |
| 159 class Logger { | 158 class Logger { |
| 160 public: | 159 public: |
| 161 #define DECLARE_ENUM(enum_item, ignore) enum_item, | 160 #define DECLARE_ENUM(enum_item, ignore) enum_item, |
| 162 enum LogEventsAndTags { | 161 enum LogEventsAndTags { |
| 163 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) | 162 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
| 164 NUMBER_OF_LOG_EVENTS | 163 NUMBER_OF_LOG_EVENTS |
| 165 }; | 164 }; |
| 166 #undef DECLARE_ENUM | 165 #undef DECLARE_ENUM |
| 167 | 166 |
| 168 // Acquires resources for logging if the right flags are set. | 167 // Acquires resources for logging if the right flags are set. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 void ApiIndexedSecurityCheck(uint32_t index); | 218 void ApiIndexedSecurityCheck(uint32_t index); |
| 220 void ApiNamedPropertyAccess(const char* tag, JSObject* holder, Object* name); | 219 void ApiNamedPropertyAccess(const char* tag, JSObject* holder, Object* name); |
| 221 void ApiIndexedPropertyAccess(const char* tag, | 220 void ApiIndexedPropertyAccess(const char* tag, |
| 222 JSObject* holder, | 221 JSObject* holder, |
| 223 uint32_t index); | 222 uint32_t index); |
| 224 void ApiObjectAccess(const char* tag, JSObject* obj); | 223 void ApiObjectAccess(const char* tag, JSObject* obj); |
| 225 void ApiEntryCall(const char* name); | 224 void ApiEntryCall(const char* name); |
| 226 | 225 |
| 227 | 226 |
| 228 // ==== Events logged by --log-code. ==== | 227 // ==== Events logged by --log-code. ==== |
| 228 void addCodeEventListener(CodeEventListener* listener); |
| 229 void removeCodeEventListener(CodeEventListener* listener); |
| 230 bool hasCodeEventListener(CodeEventListener* listener); |
| 231 |
| 232 |
| 229 // Emits a code event for a callback function. | 233 // Emits a code event for a callback function. |
| 230 void CallbackEvent(Name* name, Address entry_point); | 234 void CallbackEvent(Name* name, Address entry_point); |
| 231 void GetterCallbackEvent(Name* name, Address entry_point); | 235 void GetterCallbackEvent(Name* name, Address entry_point); |
| 232 void SetterCallbackEvent(Name* name, Address entry_point); | 236 void SetterCallbackEvent(Name* name, Address entry_point); |
| 233 // Emits a code create event. | 237 // Emits a code create event. |
| 234 void CodeCreateEvent(LogEventsAndTags tag, | 238 void CodeCreateEvent(LogEventsAndTags tag, |
| 235 Code* code, const char* source); | 239 Code* code, const char* source); |
| 236 void CodeCreateEvent(LogEventsAndTags tag, | 240 void CodeCreateEvent(LogEventsAndTags tag, |
| 237 Code* code, Name* name); | 241 Code* code, Name* name); |
| 238 void CodeCreateEvent(LogEventsAndTags tag, | 242 void CodeCreateEvent(LogEventsAndTags tag, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 262 int pc_offset, | 266 int pc_offset, |
| 263 int position); | 267 int position); |
| 264 // Emits a code line info start to record event | 268 // Emits a code line info start to record event |
| 265 void CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder); | 269 void CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder); |
| 266 // Emits a code line info finish record event. | 270 // Emits a code line info finish record event. |
| 267 // It's the callee's responsibility to dispose the parameter jit_handler_data. | 271 // It's the callee's responsibility to dispose the parameter jit_handler_data. |
| 268 void CodeEndLinePosInfoRecordEvent(Code* code, void* jit_handler_data); | 272 void CodeEndLinePosInfoRecordEvent(Code* code, void* jit_handler_data); |
| 269 | 273 |
| 270 void SharedFunctionInfoMoveEvent(Address from, Address to); | 274 void SharedFunctionInfoMoveEvent(Address from, Address to); |
| 271 | 275 |
| 276 void CodeNameEvent(Address addr, int pos, const char* code_name); |
| 272 void SnapshotPositionEvent(Address addr, int pos); | 277 void SnapshotPositionEvent(Address addr, int pos); |
| 273 | 278 |
| 274 // ==== Events logged by --log-gc. ==== | 279 // ==== Events logged by --log-gc. ==== |
| 275 // Heap sampling events: start, end, and individual types. | 280 // Heap sampling events: start, end, and individual types. |
| 276 void HeapSampleBeginEvent(const char* space, const char* kind); | 281 void HeapSampleBeginEvent(const char* space, const char* kind); |
| 277 void HeapSampleEndEvent(const char* space, const char* kind); | 282 void HeapSampleEndEvent(const char* space, const char* kind); |
| 278 void HeapSampleItemEvent(const char* type, int number, int bytes); | 283 void HeapSampleItemEvent(const char* type, int number, int bytes); |
| 279 void HeapSampleJSConstructorEvent(const char* constructor, | 284 void HeapSampleJSConstructorEvent(const char* constructor, |
| 280 int number, int bytes); | 285 int number, int bytes); |
| 281 void HeapSampleJSRetainersEvent(const char* constructor, | 286 void HeapSampleJSRetainersEvent(const char* constructor, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 437 |
| 433 friend class LoggerTestHelper; | 438 friend class LoggerTestHelper; |
| 434 | 439 |
| 435 | 440 |
| 436 int logging_nesting_; | 441 int logging_nesting_; |
| 437 int cpu_profiler_nesting_; | 442 int cpu_profiler_nesting_; |
| 438 | 443 |
| 439 Log* log_; | 444 Log* log_; |
| 440 LowLevelLogger* ll_logger_; | 445 LowLevelLogger* ll_logger_; |
| 441 JitLogger* jit_logger_; | 446 JitLogger* jit_logger_; |
| 442 CodeAddressMap* code_address_map_; | 447 List<CodeEventListener*> listeners_; |
| 443 | 448 |
| 444 // Guards against multiple calls to TearDown() that can happen in some tests. | 449 // Guards against multiple calls to TearDown() that can happen in some tests. |
| 445 // 'true' between SetUp() and TearDown(). | 450 // 'true' between SetUp() and TearDown(). |
| 446 bool is_initialized_; | 451 bool is_initialized_; |
| 447 | 452 |
| 448 // Support for 'incremental addresses' in compressed logs: | 453 // Support for 'incremental addresses' in compressed logs: |
| 449 // LogMessageBuilder::AppendAddress(Address addr) | 454 // LogMessageBuilder::AppendAddress(Address addr) |
| 450 Address last_address_; | 455 Address last_address_; |
| 451 // Logger::TickEvent(...) | 456 // Logger::TickEvent(...) |
| 452 Address prev_sp_; | 457 Address prev_sp_; |
| 453 Address prev_function_; | 458 Address prev_function_; |
| 454 // Logger::MoveEventInternal(...) | 459 // Logger::MoveEventInternal(...) |
| 455 Address prev_to_; | 460 Address prev_to_; |
| 456 // Logger::FunctionCreateEvent(...) | 461 // Logger::FunctionCreateEvent(...) |
| 457 Address prev_code_; | 462 Address prev_code_; |
| 458 | 463 |
| 459 int64_t epoch_; | 464 int64_t epoch_; |
| 460 | 465 |
| 461 friend class CpuProfiler; | 466 friend class CpuProfiler; |
| 462 }; | 467 }; |
| 463 | 468 |
| 464 | 469 |
| 470 class CodeEventListener { |
| 471 public: |
| 472 virtual ~CodeEventListener() {} |
| 473 |
| 474 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 475 Code* code, |
| 476 const char* comment) = 0; |
| 477 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 478 Code* code, |
| 479 Name* name) = 0; |
| 480 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 481 Code* code, |
| 482 SharedFunctionInfo* shared, |
| 483 CompilationInfo* info, |
| 484 Name* name) = 0; |
| 485 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 486 Code* code, |
| 487 SharedFunctionInfo* shared, |
| 488 CompilationInfo* info, |
| 489 Name* source, |
| 490 int line) = 0; |
| 491 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 492 Code* code, |
| 493 int args_count) = 0; |
| 494 virtual void CallbackEvent(Name* name, Address entry_point) = 0; |
| 495 virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0; |
| 496 virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0; |
| 497 virtual void RegExpCodeCreateEvent(Code* code, String* source) = 0; |
| 498 virtual void CodeMoveEvent(Address from, Address to) = 0; |
| 499 virtual void CodeDeleteEvent(Address from) = 0; |
| 500 virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0; |
| 501 virtual void CodeMovingGCEvent() = 0; |
| 502 }; |
| 503 |
| 504 |
| 505 class CodeEventLogger : public CodeEventListener { |
| 506 public: |
| 507 CodeEventLogger(); |
| 508 virtual ~CodeEventLogger(); |
| 509 |
| 510 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 511 Code* code, |
| 512 const char* comment); |
| 513 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 514 Code* code, |
| 515 Name* name); |
| 516 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 517 Code* code, |
| 518 int args_count); |
| 519 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 520 Code* code, |
| 521 SharedFunctionInfo* shared, |
| 522 CompilationInfo* info, |
| 523 Name* name); |
| 524 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 525 Code* code, |
| 526 SharedFunctionInfo* shared, |
| 527 CompilationInfo* info, |
| 528 Name* source, |
| 529 int line); |
| 530 virtual void RegExpCodeCreateEvent(Code* code, String* source); |
| 531 |
| 532 virtual void CallbackEvent(Name* name, Address entry_point) { } |
| 533 virtual void GetterCallbackEvent(Name* name, Address entry_point) { } |
| 534 virtual void SetterCallbackEvent(Name* name, Address entry_point) { } |
| 535 virtual void SharedFunctionInfoMoveEvent(Address from, Address to) { } |
| 536 virtual void CodeMovingGCEvent() { } |
| 537 |
| 538 private: |
| 539 class NameBuffer; |
| 540 |
| 541 virtual void LogRecordedBuffer(Code* code, |
| 542 SharedFunctionInfo* shared, |
| 543 const char* name, |
| 544 int length) = 0; |
| 545 |
| 546 NameBuffer* name_buffer_; |
| 547 }; |
| 548 |
| 549 |
| 465 } } // namespace v8::internal | 550 } } // namespace v8::internal |
| 466 | 551 |
| 467 | 552 |
| 468 #endif // V8_LOG_H_ | 553 #endif // V8_LOG_H_ |
| OLD | NEW |