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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // --log-regexp implies --log. | 62 // --log-regexp implies --log. |
63 // | 63 // |
64 // --logfile <filename> | 64 // --logfile <filename> |
65 // Specify the name of the logfile, default is "v8.log". | 65 // Specify the name of the logfile, default is "v8.log". |
66 // | 66 // |
67 // --prof | 67 // --prof |
68 // Collect statistical profiling information (ticks), default is off. The | 68 // Collect statistical profiling information (ticks), default is off. The |
69 // tick profiler requires code events, so --prof implies --log-code. | 69 // tick profiler requires code events, so --prof implies --log-code. |
70 | 70 |
71 // Forward declarations. | 71 // Forward declarations. |
72 class Ticker; | 72 class HashMap; |
| 73 class LogMessageBuilder; |
73 class Profiler; | 74 class Profiler; |
74 class Semaphore; | 75 class Semaphore; |
75 class SlidingStateWindow; | 76 class SlidingStateWindow; |
76 class LogMessageBuilder; | 77 class Ticker; |
77 | 78 |
78 #undef LOG | 79 #undef LOG |
79 #ifdef ENABLE_LOGGING_AND_PROFILING | 80 #ifdef ENABLE_LOGGING_AND_PROFILING |
80 #define LOG(isolate, Call) \ | 81 #define LOG(isolate, Call) \ |
81 do { \ | 82 do { \ |
82 v8::internal::Logger* logger = \ | 83 v8::internal::Logger* logger = \ |
83 (isolate)->logger(); \ | 84 (isolate)->logger(); \ |
84 if (logger->is_logging()) \ | 85 if (logger->is_logging()) \ |
85 logger->Call; \ | 86 logger->Call; \ |
86 } while (false) | 87 } while (false) |
87 #else | 88 #else |
88 #define LOG(isolate, Call) ((void) 0) | 89 #define LOG(isolate, Call) ((void) 0) |
89 #endif | 90 #endif |
90 | 91 |
91 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 92 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
92 V(CODE_CREATION_EVENT, "code-creation") \ | 93 V(CODE_CREATION_EVENT, "code-creation") \ |
93 V(CODE_MOVE_EVENT, "code-move") \ | 94 V(CODE_MOVE_EVENT, "code-move") \ |
94 V(CODE_DELETE_EVENT, "code-delete") \ | 95 V(CODE_DELETE_EVENT, "code-delete") \ |
95 V(CODE_MOVING_GC, "code-moving-gc") \ | 96 V(CODE_MOVING_GC, "code-moving-gc") \ |
96 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ | 97 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ |
97 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ | 98 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ |
| 99 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ |
98 V(TICK_EVENT, "tick") \ | 100 V(TICK_EVENT, "tick") \ |
99 V(REPEAT_META_EVENT, "repeat") \ | 101 V(REPEAT_META_EVENT, "repeat") \ |
100 V(BUILTIN_TAG, "Builtin") \ | 102 V(BUILTIN_TAG, "Builtin") \ |
101 V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \ | 103 V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \ |
102 V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \ | 104 V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \ |
103 V(CALL_IC_TAG, "CallIC") \ | 105 V(CALL_IC_TAG, "CallIC") \ |
104 V(CALL_INITIALIZE_TAG, "CallInitialize") \ | 106 V(CALL_INITIALIZE_TAG, "CallInitialize") \ |
105 V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \ | 107 V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \ |
106 V(CALL_MISS_TAG, "CallMiss") \ | 108 V(CALL_MISS_TAG, "CallMiss") \ |
107 V(CALL_NORMAL_TAG, "CallNormal") \ | 109 V(CALL_NORMAL_TAG, "CallNormal") \ |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Converts tag to a corresponding NATIVE_... if the script is native. | 295 // Converts tag to a corresponding NATIVE_... if the script is native. |
294 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); | 296 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); |
295 | 297 |
296 // Profiler's sampling interval (in milliseconds). | 298 // Profiler's sampling interval (in milliseconds). |
297 static const int kSamplingIntervalMs = 1; | 299 static const int kSamplingIntervalMs = 1; |
298 | 300 |
299 // Callback from Log, stops profiling in case of insufficient resources. | 301 // Callback from Log, stops profiling in case of insufficient resources. |
300 void LogFailure(); | 302 void LogFailure(); |
301 | 303 |
302 private: | 304 private: |
| 305 class NameBuffer; |
| 306 class NameMap; |
| 307 |
303 Logger(); | 308 Logger(); |
304 ~Logger(); | 309 ~Logger(); |
305 | 310 |
306 // Emits the profiler's first message. | 311 // Emits the profiler's first message. |
307 void ProfilerBeginEvent(); | 312 void ProfilerBeginEvent(); |
308 | 313 |
309 // Emits callback event messages. | 314 // Emits callback event messages. |
310 void CallbackEventInternal(const char* prefix, | 315 void CallbackEventInternal(const char* prefix, |
311 const char* name, | 316 const char* name, |
312 Address entry_point); | 317 Address entry_point); |
313 | 318 |
314 // Internal configurable move event. | 319 // Internal configurable move event. |
315 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); | 320 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); |
316 | 321 |
317 // Internal configurable move event. | 322 // Internal configurable move event. |
318 void DeleteEventInternal(LogEventsAndTags event, Address from); | 323 void DeleteEventInternal(LogEventsAndTags event, Address from); |
319 | 324 |
320 // Emits the source code of a regexp. Used by regexp events. | 325 // Emits the source code of a regexp. Used by regexp events. |
321 void LogRegExpSource(Handle<JSRegExp> regexp); | 326 void LogRegExpSource(Handle<JSRegExp> regexp); |
322 | 327 |
323 // Used for logging stubs found in the snapshot. | 328 // Used for logging stubs found in the snapshot. |
324 void LogCodeObject(Object* code_object); | 329 void LogCodeObject(Object* code_object); |
325 | 330 |
326 // Emits general information about generated code. | 331 // Emits general information about generated code. |
327 void LogCodeInfo(); | 332 void LogCodeInfo(); |
328 | 333 |
329 // Handles code creation when low-level profiling is active. | 334 void RegisterSnapshotCodeName(Code* code, const char* name, int name_size); |
330 void LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg); | 335 |
| 336 // Low-level logging support. |
| 337 |
| 338 void LowLevelCodeCreateEvent(Code* code, const char* name, int name_size); |
| 339 |
| 340 void LowLevelCodeMoveEvent(Address from, Address to); |
| 341 |
| 342 void LowLevelCodeDeleteEvent(Address from); |
| 343 |
| 344 void LowLevelSnapshotPositionEvent(Address addr, int pos); |
| 345 |
| 346 void LowLevelLogWriteBytes(const char* bytes, int size); |
| 347 |
| 348 template <typename T> |
| 349 void LowLevelLogWriteStruct(const T& s) { |
| 350 char tag = T::kTag; |
| 351 LowLevelLogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); |
| 352 LowLevelLogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); |
| 353 } |
331 | 354 |
332 // Emits a profiler tick event. Used by the profiler thread. | 355 // Emits a profiler tick event. Used by the profiler thread. |
333 void TickEvent(TickSample* sample, bool overflow); | 356 void TickEvent(TickSample* sample, bool overflow); |
334 | 357 |
335 void ApiEvent(const char* name, ...); | 358 void ApiEvent(const char* name, ...); |
336 | 359 |
337 // Logs a StringEvent regardless of whether FLAG_log is true. | 360 // Logs a StringEvent regardless of whether FLAG_log is true. |
338 void UncheckedStringEvent(const char* name, const char* value); | 361 void UncheckedStringEvent(const char* name, const char* value); |
339 | 362 |
340 // Logs an IntEvent regardless of whether FLAG_log is true. | 363 // Logs an IntEvent regardless of whether FLAG_log is true. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 395 |
373 friend class LoggerTestHelper; | 396 friend class LoggerTestHelper; |
374 | 397 |
375 | 398 |
376 int logging_nesting_; | 399 int logging_nesting_; |
377 int cpu_profiler_nesting_; | 400 int cpu_profiler_nesting_; |
378 int heap_profiler_nesting_; | 401 int heap_profiler_nesting_; |
379 | 402 |
380 Log* log_; | 403 Log* log_; |
381 | 404 |
| 405 NameBuffer* name_buffer_; |
| 406 |
| 407 NameMap* address_to_name_map_; |
| 408 |
382 // Guards against multiple calls to TearDown() that can happen in some tests. | 409 // Guards against multiple calls to TearDown() that can happen in some tests. |
383 // 'true' between Setup() and TearDown(). | 410 // 'true' between Setup() and TearDown(). |
384 bool is_initialized_; | 411 bool is_initialized_; |
385 | 412 |
386 // Support for 'incremental addresses' in compressed logs: | 413 // Support for 'incremental addresses' in compressed logs: |
387 // LogMessageBuilder::AppendAddress(Address addr) | 414 // LogMessageBuilder::AppendAddress(Address addr) |
388 Address last_address_; | 415 Address last_address_; |
389 // Logger::TickEvent(...) | 416 // Logger::TickEvent(...) |
390 Address prev_sp_; | 417 Address prev_sp_; |
391 Address prev_function_; | 418 Address prev_function_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 // Class that extracts stack trace, used for profiling. | 464 // Class that extracts stack trace, used for profiling. |
438 class StackTracer : public AllStatic { | 465 class StackTracer : public AllStatic { |
439 public: | 466 public: |
440 static void Trace(Isolate* isolate, TickSample* sample); | 467 static void Trace(Isolate* isolate, TickSample* sample); |
441 }; | 468 }; |
442 | 469 |
443 } } // namespace v8::internal | 470 } } // namespace v8::internal |
444 | 471 |
445 | 472 |
446 #endif // V8_LOG_H_ | 473 #endif // V8_LOG_H_ |
OLD | NEW |