| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 private: | 95 private: |
| 96 StateTag state_; | 96 StateTag state_; |
| 97 VMState* previous_; | 97 VMState* previous_; |
| 98 #else | 98 #else |
| 99 public: | 99 public: |
| 100 explicit VMState(StateTag state) {} | 100 explicit VMState(StateTag state) {} |
| 101 #endif | 101 #endif |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 | 104 |
| 105 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
| 106 V(CODE_CREATION_EVENT, "code-creation", "cc") \ |
| 107 V(CODE_MOVE_EVENT, "code-move", "cm") \ |
| 108 V(CODE_DELETE_EVENT, "code-delete", "cd") \ |
| 109 V(TICK_EVENT, "tick", "t") \ |
| 110 V(BUILTIN_TAG, "Builtin", "bi") \ |
| 111 V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak", "cdb") \ |
| 112 V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn", "cdbsi") \ |
| 113 V(CALL_IC_TAG, "CallIC", "cic") \ |
| 114 V(CALL_INITIALIZE_TAG, "CallInitialize", "ci") \ |
| 115 V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic", "cmm") \ |
| 116 V(CALL_MISS_TAG, "CallMiss", "cm") \ |
| 117 V(CALL_NORMAL_TAG, "CallNormal", "cn") \ |
| 118 V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic", "cpm") \ |
| 119 V(EVAL_TAG, "Eval", "e") \ |
| 120 V(FUNCTION_TAG, "Function", "f") \ |
| 121 V(KEYED_LOAD_IC_TAG, "KeyedLoadIC", "klic") \ |
| 122 V(KEYED_STORE_IC_TAG, "KeyedStoreIC", "ksic") \ |
| 123 V(LAZY_COMPILE_TAG, "LazyCompile", "lc") \ |
| 124 V(LOAD_IC_TAG, "LoadIC", "lic") \ |
| 125 V(REG_EXP_TAG, "RegExp", "re") \ |
| 126 V(SCRIPT_TAG, "Script", "sc") \ |
| 127 V(STORE_IC_TAG, "StoreIC", "sic") \ |
| 128 V(STUB_TAG, "Stub", "s") |
| 129 |
| 105 class Logger { | 130 class Logger { |
| 106 public: | 131 public: |
| 132 #define DECLARE_ENUM(enum_item, ignore1, ignore2) enum_item, |
| 133 enum LogEventsAndTags { |
| 134 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
| 135 NUMBER_OF_LOG_EVENTS |
| 136 }; |
| 137 #undef DECLARE_ENUM |
| 138 |
| 107 // Acquires resources for logging if the right flags are set. | 139 // Acquires resources for logging if the right flags are set. |
| 108 static bool Setup(); | 140 static bool Setup(); |
| 109 | 141 |
| 110 // Frees resources acquired in Setup. | 142 // Frees resources acquired in Setup. |
| 111 static void TearDown(); | 143 static void TearDown(); |
| 112 | 144 |
| 113 // Enable the computation of a sliding window of states. | 145 // Enable the computation of a sliding window of states. |
| 114 static void EnableSlidingStateWindow(); | 146 static void EnableSlidingStateWindow(); |
| 115 | 147 |
| 116 // Write a raw string to the log to be used as a preamble. | 148 // Write a raw string to the log to be used as a preamble. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 Object* name); | 188 Object* name); |
| 157 static void ApiIndexedPropertyAccess(const char* tag, | 189 static void ApiIndexedPropertyAccess(const char* tag, |
| 158 JSObject* holder, | 190 JSObject* holder, |
| 159 uint32_t index); | 191 uint32_t index); |
| 160 static void ApiObjectAccess(const char* tag, JSObject* obj); | 192 static void ApiObjectAccess(const char* tag, JSObject* obj); |
| 161 static void ApiEntryCall(const char* name); | 193 static void ApiEntryCall(const char* name); |
| 162 | 194 |
| 163 | 195 |
| 164 // ==== Events logged by --log-code. ==== | 196 // ==== Events logged by --log-code. ==== |
| 165 // Emits a code create event. | 197 // Emits a code create event. |
| 166 static void CodeCreateEvent(const char* tag, Code* code, const char* source); | 198 static void CodeCreateEvent(LogEventsAndTags tag, |
| 167 static void CodeCreateEvent(const char* tag, Code* code, String* name); | 199 Code* code, const char* source); |
| 168 static void CodeCreateEvent(const char* tag, Code* code, String* name, | 200 static void CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name); |
| 201 static void CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name, |
| 169 String* source, int line); | 202 String* source, int line); |
| 170 static void CodeCreateEvent(const char* tag, Code* code, int args_count); | 203 static void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count); |
| 171 // Emits a code create event for a RegExp. | 204 // Emits a code create event for a RegExp. |
| 172 static void RegExpCodeCreateEvent(Code* code, String* source); | 205 static void RegExpCodeCreateEvent(Code* code, String* source); |
| 173 static void CodeAllocateEvent(Code* code, Assembler* assem); | |
| 174 // Emits a code move event. | 206 // Emits a code move event. |
| 175 static void CodeMoveEvent(Address from, Address to); | 207 static void CodeMoveEvent(Address from, Address to); |
| 176 // Emits a code delete event. | 208 // Emits a code delete event. |
| 177 static void CodeDeleteEvent(Address from); | 209 static void CodeDeleteEvent(Address from); |
| 178 | 210 |
| 179 // ==== Events logged by --log-gc. ==== | 211 // ==== Events logged by --log-gc. ==== |
| 180 // Heap sampling events: start, end, and individual types. | 212 // Heap sampling events: start, end, and individual types. |
| 181 static void HeapSampleBeginEvent(const char* space, const char* kind); | 213 static void HeapSampleBeginEvent(const char* space, const char* kind); |
| 182 static void HeapSampleEndEvent(const char* space, const char* kind); | 214 static void HeapSampleEndEvent(const char* space, const char* kind); |
| 183 static void HeapSampleItemEvent(const char* type, int number, int bytes); | 215 static void HeapSampleItemEvent(const char* type, int number, int bytes); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 static void LogCompiledFunctions(); | 251 static void LogCompiledFunctions(); |
| 220 | 252 |
| 221 private: | 253 private: |
| 222 | 254 |
| 223 // Profiler's sampling interval (in milliseconds). | 255 // Profiler's sampling interval (in milliseconds). |
| 224 static const int kSamplingIntervalMs = 1; | 256 static const int kSamplingIntervalMs = 1; |
| 225 | 257 |
| 226 // Emits the profiler's first message. | 258 // Emits the profiler's first message. |
| 227 static void ProfilerBeginEvent(); | 259 static void ProfilerBeginEvent(); |
| 228 | 260 |
| 261 // Emits aliases for compressed messages. |
| 262 static void LogAliases(); |
| 263 |
| 229 // Emits the source code of a regexp. Used by regexp events. | 264 // Emits the source code of a regexp. Used by regexp events. |
| 230 static void LogRegExpSource(Handle<JSRegExp> regexp); | 265 static void LogRegExpSource(Handle<JSRegExp> regexp); |
| 231 | 266 |
| 232 // Emits a profiler tick event. Used by the profiler thread. | 267 // Emits a profiler tick event. Used by the profiler thread. |
| 233 static void TickEvent(TickSample* sample, bool overflow); | 268 static void TickEvent(TickSample* sample, bool overflow); |
| 234 | 269 |
| 235 static void ApiEvent(const char* name, ...); | 270 static void ApiEvent(const char* name, ...); |
| 236 | 271 |
| 237 // Logs a StringEvent regardless of whether FLAG_log is true. | 272 // Logs a StringEvent regardless of whether FLAG_log is true. |
| 238 static void UncheckedStringEvent(const char* name, const char* value); | 273 static void UncheckedStringEvent(const char* name, const char* value); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 254 // A stack of VM states. | 289 // A stack of VM states. |
| 255 static VMState* current_state_; | 290 static VMState* current_state_; |
| 256 | 291 |
| 257 // Singleton bottom or default vm state. | 292 // Singleton bottom or default vm state. |
| 258 static VMState bottom_state_; | 293 static VMState bottom_state_; |
| 259 | 294 |
| 260 // SlidingStateWindow instance keeping a sliding window of the most | 295 // SlidingStateWindow instance keeping a sliding window of the most |
| 261 // recent VM states. | 296 // recent VM states. |
| 262 static SlidingStateWindow* sliding_state_window_; | 297 static SlidingStateWindow* sliding_state_window_; |
| 263 | 298 |
| 299 // An array of log events names. |
| 300 static const char** log_events_; |
| 301 |
| 264 // Internal implementation classes with access to | 302 // Internal implementation classes with access to |
| 265 // private members. | 303 // private members. |
| 266 friend class EventLog; | 304 friend class EventLog; |
| 267 friend class TimeLog; | 305 friend class TimeLog; |
| 268 friend class Profiler; | 306 friend class Profiler; |
| 269 friend class SlidingStateWindow; | 307 friend class SlidingStateWindow; |
| 270 friend class VMState; | 308 friend class VMState; |
| 271 | 309 |
| 272 friend class LoggerTestHelper; | 310 friend class LoggerTestHelper; |
| 273 #else | 311 #else |
| 274 static bool is_enabled() { return false; } | 312 static bool is_enabled() { return false; } |
| 275 #endif | 313 #endif |
| 276 }; | 314 }; |
| 277 | 315 |
| 278 | 316 |
| 279 // Class that extracts stack trace, used for profiling. | 317 // Class that extracts stack trace, used for profiling. |
| 280 class StackTracer : public AllStatic { | 318 class StackTracer : public AllStatic { |
| 281 public: | 319 public: |
| 282 static void Trace(TickSample* sample); | 320 static void Trace(TickSample* sample); |
| 283 }; | 321 }; |
| 284 | 322 |
| 285 | 323 |
| 286 } } // namespace v8::internal | 324 } } // namespace v8::internal |
| 287 | 325 |
| 288 #endif // V8_LOG_H_ | 326 #endif // V8_LOG_H_ |
| OLD | NEW |