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