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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Ticker; |
73 class Profiler; | 73 class Profiler; |
74 class Semaphore; | 74 class Semaphore; |
75 class SlidingStateWindow; | 75 class SlidingStateWindow; |
76 class LogMessageBuilder; | 76 class LogMessageBuilder; |
| 77 class CompressionHelper; |
77 | 78 |
78 #undef LOG | 79 #undef LOG |
79 #ifdef ENABLE_LOGGING_AND_PROFILING | 80 #ifdef ENABLE_LOGGING_AND_PROFILING |
80 #define LOG(Call) \ | 81 #define LOG(Call) \ |
81 do { \ | 82 do { \ |
82 if (v8::internal::Logger::is_logging()) \ | 83 if (v8::internal::Logger::is_logging()) \ |
83 v8::internal::Logger::Call; \ | 84 v8::internal::Logger::Call; \ |
84 } while (false) | 85 } while (false) |
85 #else | 86 #else |
86 #define LOG(Call) ((void) 0) | 87 #define LOG(Call) ((void) 0) |
87 #endif | 88 #endif |
88 | 89 |
89 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 90 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
90 V(CODE_CREATION_EVENT, "code-creation") \ | 91 V(CODE_CREATION_EVENT, "code-creation", "cc") \ |
91 V(CODE_MOVE_EVENT, "code-move") \ | 92 V(CODE_MOVE_EVENT, "code-move", "cm") \ |
92 V(CODE_DELETE_EVENT, "code-delete") \ | 93 V(CODE_DELETE_EVENT, "code-delete", "cd") \ |
93 V(CODE_MOVING_GC, "code-moving-gc") \ | 94 V(CODE_MOVING_GC, "code-moving-gc", "cg") \ |
94 V(FUNCTION_CREATION_EVENT, "function-creation") \ | 95 V(FUNCTION_CREATION_EVENT, "function-creation", "fc") \ |
95 V(FUNCTION_MOVE_EVENT, "function-move") \ | 96 V(FUNCTION_MOVE_EVENT, "function-move", "fm") \ |
96 V(FUNCTION_DELETE_EVENT, "function-delete") \ | 97 V(FUNCTION_DELETE_EVENT, "function-delete", "fd") \ |
97 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ | 98 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos", "sp") \ |
98 V(TICK_EVENT, "tick") \ | 99 V(TICK_EVENT, "tick", "t") \ |
99 V(REPEAT_META_EVENT, "repeat") \ | 100 V(REPEAT_META_EVENT, "repeat", "r") \ |
100 V(BUILTIN_TAG, "Builtin") \ | 101 V(BUILTIN_TAG, "Builtin", "bi") \ |
101 V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \ | 102 V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak", "cdb") \ |
102 V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \ | 103 V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn", "cdbsi") \ |
103 V(CALL_IC_TAG, "CallIC") \ | 104 V(CALL_IC_TAG, "CallIC", "cic") \ |
104 V(CALL_INITIALIZE_TAG, "CallInitialize") \ | 105 V(CALL_INITIALIZE_TAG, "CallInitialize", "ci") \ |
105 V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \ | 106 V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic", "cmm") \ |
106 V(CALL_MISS_TAG, "CallMiss") \ | 107 V(CALL_MISS_TAG, "CallMiss", "cm") \ |
107 V(CALL_NORMAL_TAG, "CallNormal") \ | 108 V(CALL_NORMAL_TAG, "CallNormal", "cn") \ |
108 V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic") \ | 109 V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic", "cpm") \ |
109 V(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak") \ | 110 V(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak", "kcdb") \ |
110 V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, \ | 111 V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, \ |
111 "KeyedCallDebugPrepareStepIn") \ | 112 "KeyedCallDebugPrepareStepIn", \ |
112 V(KEYED_CALL_IC_TAG, "KeyedCallIC") \ | 113 "kcdbsi") \ |
113 V(KEYED_CALL_INITIALIZE_TAG, "KeyedCallInitialize") \ | 114 V(KEYED_CALL_IC_TAG, "KeyedCallIC", "kcic") \ |
114 V(KEYED_CALL_MEGAMORPHIC_TAG, "KeyedCallMegamorphic") \ | 115 V(KEYED_CALL_INITIALIZE_TAG, "KeyedCallInitialize", "kci") \ |
115 V(KEYED_CALL_MISS_TAG, "KeyedCallMiss") \ | 116 V(KEYED_CALL_MEGAMORPHIC_TAG, "KeyedCallMegamorphic", "kcmm") \ |
116 V(KEYED_CALL_NORMAL_TAG, "KeyedCallNormal") \ | 117 V(KEYED_CALL_MISS_TAG, "KeyedCallMiss", "kcm") \ |
117 V(KEYED_CALL_PRE_MONOMORPHIC_TAG, "KeyedCallPreMonomorphic") \ | 118 V(KEYED_CALL_NORMAL_TAG, "KeyedCallNormal", "kcn") \ |
118 V(CALLBACK_TAG, "Callback") \ | 119 V(KEYED_CALL_PRE_MONOMORPHIC_TAG, \ |
119 V(EVAL_TAG, "Eval") \ | 120 "KeyedCallPreMonomorphic", \ |
120 V(FUNCTION_TAG, "Function") \ | 121 "kcpm") \ |
121 V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \ | 122 V(CALLBACK_TAG, "Callback", "cb") \ |
122 V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \ | 123 V(EVAL_TAG, "Eval", "e") \ |
123 V(LAZY_COMPILE_TAG, "LazyCompile") \ | 124 V(FUNCTION_TAG, "Function", "f") \ |
124 V(LOAD_IC_TAG, "LoadIC") \ | 125 V(KEYED_LOAD_IC_TAG, "KeyedLoadIC", "klic") \ |
125 V(REG_EXP_TAG, "RegExp") \ | 126 V(KEYED_STORE_IC_TAG, "KeyedStoreIC", "ksic") \ |
126 V(SCRIPT_TAG, "Script") \ | 127 V(LAZY_COMPILE_TAG, "LazyCompile", "lc") \ |
127 V(STORE_IC_TAG, "StoreIC") \ | 128 V(LOAD_IC_TAG, "LoadIC", "lic") \ |
128 V(STUB_TAG, "Stub") \ | 129 V(REG_EXP_TAG, "RegExp", "re") \ |
129 V(NATIVE_FUNCTION_TAG, "Function") \ | 130 V(SCRIPT_TAG, "Script", "sc") \ |
130 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ | 131 V(STORE_IC_TAG, "StoreIC", "sic") \ |
131 V(NATIVE_SCRIPT_TAG, "Script") | 132 V(STUB_TAG, "Stub", "s") \ |
| 133 V(NATIVE_FUNCTION_TAG, "Function", "f") \ |
| 134 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile", "lc") \ |
| 135 V(NATIVE_SCRIPT_TAG, "Script", "sc") |
132 // Note that 'NATIVE_' cases for functions and scripts are mapped onto | 136 // Note that 'NATIVE_' cases for functions and scripts are mapped onto |
133 // original tags when writing to the log. | 137 // original tags when writing to the log. |
134 | 138 |
135 | 139 |
136 class Logger { | 140 class Logger { |
137 public: | 141 public: |
138 #define DECLARE_ENUM(enum_item, ignore) enum_item, | 142 #define DECLARE_ENUM(enum_item, ignore1, ignore2) enum_item, |
139 enum LogEventsAndTags { | 143 enum LogEventsAndTags { |
140 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) | 144 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
141 NUMBER_OF_LOG_EVENTS | 145 NUMBER_OF_LOG_EVENTS |
142 }; | 146 }; |
143 #undef DECLARE_ENUM | 147 #undef DECLARE_ENUM |
144 | 148 |
145 // Acquires resources for logging if the right flags are set. | 149 // Acquires resources for logging if the right flags are set. |
146 static bool Setup(); | 150 static bool Setup(); |
147 | 151 |
148 static void EnsureTickerStarted(); | 152 static void EnsureTickerStarted(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 static void LogCodeObjects(); | 285 static void LogCodeObjects(); |
282 | 286 |
283 // Converts tag to a corresponding NATIVE_... if the script is native. | 287 // Converts tag to a corresponding NATIVE_... if the script is native. |
284 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); | 288 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); |
285 | 289 |
286 // Profiler's sampling interval (in milliseconds). | 290 // Profiler's sampling interval (in milliseconds). |
287 static const int kSamplingIntervalMs = 1; | 291 static const int kSamplingIntervalMs = 1; |
288 | 292 |
289 private: | 293 private: |
290 | 294 |
| 295 // Size of window used for log records compression. |
| 296 static const int kCompressionWindowSize = 4; |
| 297 |
291 // Emits the profiler's first message. | 298 // Emits the profiler's first message. |
292 static void ProfilerBeginEvent(); | 299 static void ProfilerBeginEvent(); |
293 | 300 |
294 // Emits callback event messages. | 301 // Emits callback event messages. |
295 static void CallbackEventInternal(const char* prefix, | 302 static void CallbackEventInternal(const char* prefix, |
296 const char* name, | 303 const char* name, |
297 Address entry_point); | 304 Address entry_point); |
298 | 305 |
299 // Internal configurable move event. | 306 // Internal configurable move event. |
300 static void MoveEventInternal(LogEventsAndTags event, | 307 static void MoveEventInternal(LogEventsAndTags event, |
301 Address from, | 308 Address from, |
302 Address to); | 309 Address to); |
303 | 310 |
304 // Internal configurable move event. | 311 // Internal configurable move event. |
305 static void DeleteEventInternal(LogEventsAndTags event, | 312 static void DeleteEventInternal(LogEventsAndTags event, |
306 Address from); | 313 Address from); |
307 | 314 |
| 315 // Emits aliases for compressed messages. |
| 316 static void LogAliases(); |
| 317 |
308 // Emits the source code of a regexp. Used by regexp events. | 318 // Emits the source code of a regexp. Used by regexp events. |
309 static void LogRegExpSource(Handle<JSRegExp> regexp); | 319 static void LogRegExpSource(Handle<JSRegExp> regexp); |
310 | 320 |
311 // Used for logging stubs found in the snapshot. | 321 // Used for logging stubs found in the snapshot. |
312 static void LogCodeObject(Object* code_object); | 322 static void LogCodeObject(Object* code_object); |
313 | 323 |
314 // Emits general information about generated code. | 324 // Emits general information about generated code. |
315 static void LogCodeInfo(); | 325 static void LogCodeInfo(); |
316 | 326 |
317 // Handles code creation when low-level profiling is active. | 327 // Handles code creation when low-level profiling is active. |
(...skipping 22 matching lines...) Expand all Loading... |
340 | 350 |
341 // When the statistical profile is active, profiler_ | 351 // When the statistical profile is active, profiler_ |
342 // points to a Profiler, that handles collection | 352 // points to a Profiler, that handles collection |
343 // of samples. | 353 // of samples. |
344 static Profiler* profiler_; | 354 static Profiler* profiler_; |
345 | 355 |
346 // SlidingStateWindow instance keeping a sliding window of the most | 356 // SlidingStateWindow instance keeping a sliding window of the most |
347 // recent VM states. | 357 // recent VM states. |
348 static SlidingStateWindow* sliding_state_window_; | 358 static SlidingStateWindow* sliding_state_window_; |
349 | 359 |
| 360 // An array of log events names. |
| 361 static const char** log_events_; |
| 362 |
| 363 // An instance of helper created if log compression is enabled. |
| 364 static CompressionHelper* compression_helper_; |
| 365 |
350 // Internal implementation classes with access to | 366 // Internal implementation classes with access to |
351 // private members. | 367 // private members. |
| 368 friend class CompressionHelper; |
352 friend class EventLog; | 369 friend class EventLog; |
353 friend class TimeLog; | 370 friend class TimeLog; |
354 friend class Profiler; | 371 friend class Profiler; |
355 friend class SlidingStateWindow; | 372 friend class SlidingStateWindow; |
356 friend class StackTracer; | 373 friend class StackTracer; |
357 friend class VMState; | 374 friend class VMState; |
358 | 375 |
359 friend class LoggerTestHelper; | 376 friend class LoggerTestHelper; |
360 | 377 |
361 static int logging_nesting_; | 378 static int logging_nesting_; |
(...skipping 10 matching lines...) Expand all Loading... |
372 // Class that extracts stack trace, used for profiling. | 389 // Class that extracts stack trace, used for profiling. |
373 class StackTracer : public AllStatic { | 390 class StackTracer : public AllStatic { |
374 public: | 391 public: |
375 static void Trace(TickSample* sample); | 392 static void Trace(TickSample* sample); |
376 }; | 393 }; |
377 | 394 |
378 } } // namespace v8::internal | 395 } } // namespace v8::internal |
379 | 396 |
380 | 397 |
381 #endif // V8_LOG_H_ | 398 #endif // V8_LOG_H_ |
OLD | NEW |