| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // Forward declarations. | 72 // Forward declarations. |
| 73 class Ticker; | 73 class Ticker; |
| 74 class Profiler; | 74 class Profiler; |
| 75 class Semaphore; | 75 class Semaphore; |
| 76 class SlidingStateWindow; | 76 class SlidingStateWindow; |
| 77 class LogMessageBuilder; | 77 class LogMessageBuilder; |
| 78 | 78 |
| 79 #undef LOG | 79 #undef LOG |
| 80 #ifdef ENABLE_LOGGING_AND_PROFILING | 80 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 81 #define LOG(Call) \ | 81 #define LOG(isolate, Call) \ |
| 82 do { \ | 82 do { \ |
| 83 if (v8::internal::Logger::is_logging()) \ | 83 v8::internal::Logger* logger = \ |
| 84 v8::internal::Logger::Call; \ | 84 (isolate)->logger(); \ |
| 85 if (logger->is_logging()) \ |
| 86 logger->Call; \ |
| 85 } while (false) | 87 } while (false) |
| 86 #else | 88 #else |
| 87 #define LOG(Call) ((void) 0) | 89 #define LOG(isolate, Call) ((void) 0) |
| 88 #endif | 90 #endif |
| 89 | 91 |
| 90 #define LOG_EVENTS_AND_TAGS_LIST(V) \ | 92 #define LOG_EVENTS_AND_TAGS_LIST(V) \ |
| 91 V(CODE_CREATION_EVENT, "code-creation") \ | 93 V(CODE_CREATION_EVENT, "code-creation") \ |
| 92 V(CODE_MOVE_EVENT, "code-move") \ | 94 V(CODE_MOVE_EVENT, "code-move") \ |
| 93 V(CODE_DELETE_EVENT, "code-delete") \ | 95 V(CODE_DELETE_EVENT, "code-delete") \ |
| 94 V(CODE_MOVING_GC, "code-moving-gc") \ | 96 V(CODE_MOVING_GC, "code-moving-gc") \ |
| 95 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ | 97 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ |
| 96 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ | 98 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ |
| 97 V(TICK_EVENT, "tick") \ | 99 V(TICK_EVENT, "tick") \ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 127 V(SCRIPT_TAG, "Script") \ | 129 V(SCRIPT_TAG, "Script") \ |
| 128 V(STORE_IC_TAG, "StoreIC") \ | 130 V(STORE_IC_TAG, "StoreIC") \ |
| 129 V(STUB_TAG, "Stub") \ | 131 V(STUB_TAG, "Stub") \ |
| 130 V(NATIVE_FUNCTION_TAG, "Function") \ | 132 V(NATIVE_FUNCTION_TAG, "Function") \ |
| 131 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ | 133 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ |
| 132 V(NATIVE_SCRIPT_TAG, "Script") | 134 V(NATIVE_SCRIPT_TAG, "Script") |
| 133 // Note that 'NATIVE_' cases for functions and scripts are mapped onto | 135 // Note that 'NATIVE_' cases for functions and scripts are mapped onto |
| 134 // original tags when writing to the log. | 136 // original tags when writing to the log. |
| 135 | 137 |
| 136 | 138 |
| 139 class Sampler; |
| 140 |
| 141 |
| 137 class Logger { | 142 class Logger { |
| 138 public: | 143 public: |
| 139 #define DECLARE_ENUM(enum_item, ignore) enum_item, | 144 #define DECLARE_ENUM(enum_item, ignore) enum_item, |
| 140 enum LogEventsAndTags { | 145 enum LogEventsAndTags { |
| 141 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) | 146 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
| 142 NUMBER_OF_LOG_EVENTS | 147 NUMBER_OF_LOG_EVENTS |
| 143 }; | 148 }; |
| 144 #undef DECLARE_ENUM | 149 #undef DECLARE_ENUM |
| 145 | 150 |
| 146 // Acquires resources for logging if the right flags are set. | 151 // Acquires resources for logging if the right flags are set. |
| 147 static bool Setup(); | 152 bool Setup(); |
| 148 | 153 |
| 149 static void EnsureTickerStarted(); | 154 void EnsureTickerStarted(); |
| 150 static void EnsureTickerStopped(); | 155 void EnsureTickerStopped(); |
| 156 |
| 157 Sampler* sampler(); |
| 151 | 158 |
| 152 // Frees resources acquired in Setup. | 159 // Frees resources acquired in Setup. |
| 153 static void TearDown(); | 160 void TearDown(); |
| 154 | 161 |
| 155 // Enable the computation of a sliding window of states. | 162 // Enable the computation of a sliding window of states. |
| 156 static void EnableSlidingStateWindow(); | 163 void EnableSlidingStateWindow(); |
| 157 | 164 |
| 158 // Emits an event with a string value -> (name, value). | 165 // Emits an event with a string value -> (name, value). |
| 159 static void StringEvent(const char* name, const char* value); | 166 void StringEvent(const char* name, const char* value); |
| 160 | 167 |
| 161 // Emits an event with an int value -> (name, value). | 168 // Emits an event with an int value -> (name, value). |
| 162 static void IntEvent(const char* name, int value); | 169 void IntEvent(const char* name, int value); |
| 163 static void IntPtrTEvent(const char* name, intptr_t value); | 170 void IntPtrTEvent(const char* name, intptr_t value); |
| 164 | 171 |
| 165 // Emits an event with an handle value -> (name, location). | 172 // Emits an event with an handle value -> (name, location). |
| 166 static void HandleEvent(const char* name, Object** location); | 173 void HandleEvent(const char* name, Object** location); |
| 167 | 174 |
| 168 // Emits memory management events for C allocated structures. | 175 // Emits memory management events for C allocated structures. |
| 169 static void NewEvent(const char* name, void* object, size_t size); | 176 void NewEvent(const char* name, void* object, size_t size); |
| 170 static void DeleteEvent(const char* name, void* object); | 177 void DeleteEvent(const char* name, void* object); |
| 178 |
| 179 // Static versions of the above, operate on current isolate's logger. |
| 180 // Used in TRACK_MEMORY(TypeName) defined in globals.h |
| 181 static void NewEventStatic(const char* name, void* object, size_t size); |
| 182 static void DeleteEventStatic(const char* name, void* object); |
| 171 | 183 |
| 172 // Emits an event with a tag, and some resource usage information. | 184 // Emits an event with a tag, and some resource usage information. |
| 173 // -> (name, tag, <rusage information>). | 185 // -> (name, tag, <rusage information>). |
| 174 // Currently, the resource usage information is a process time stamp | 186 // Currently, the resource usage information is a process time stamp |
| 175 // and a real time timestamp. | 187 // and a real time timestamp. |
| 176 static void ResourceEvent(const char* name, const char* tag); | 188 void ResourceEvent(const char* name, const char* tag); |
| 177 | 189 |
| 178 // Emits an event that an undefined property was read from an | 190 // Emits an event that an undefined property was read from an |
| 179 // object. | 191 // object. |
| 180 static void SuspectReadEvent(String* name, Object* obj); | 192 void SuspectReadEvent(String* name, Object* obj); |
| 181 | 193 |
| 182 // Emits an event when a message is put on or read from a debugging queue. | 194 // Emits an event when a message is put on or read from a debugging queue. |
| 183 // DebugTag lets us put a call-site specific label on the event. | 195 // DebugTag lets us put a call-site specific label on the event. |
| 184 static void DebugTag(const char* call_site_tag); | 196 void DebugTag(const char* call_site_tag); |
| 185 static void DebugEvent(const char* event_type, Vector<uint16_t> parameter); | 197 void DebugEvent(const char* event_type, Vector<uint16_t> parameter); |
| 186 | 198 |
| 187 | 199 |
| 188 // ==== Events logged by --log-api. ==== | 200 // ==== Events logged by --log-api. ==== |
| 189 static void ApiNamedSecurityCheck(Object* key); | 201 void ApiNamedSecurityCheck(Object* key); |
| 190 static void ApiIndexedSecurityCheck(uint32_t index); | 202 void ApiIndexedSecurityCheck(uint32_t index); |
| 191 static void ApiNamedPropertyAccess(const char* tag, | 203 void ApiNamedPropertyAccess(const char* tag, JSObject* holder, Object* name); |
| 192 JSObject* holder, | 204 void ApiIndexedPropertyAccess(const char* tag, |
| 193 Object* name); | 205 JSObject* holder, |
| 194 static void ApiIndexedPropertyAccess(const char* tag, | 206 uint32_t index); |
| 195 JSObject* holder, | 207 void ApiObjectAccess(const char* tag, JSObject* obj); |
| 196 uint32_t index); | 208 void ApiEntryCall(const char* name); |
| 197 static void ApiObjectAccess(const char* tag, JSObject* obj); | |
| 198 static void ApiEntryCall(const char* name); | |
| 199 | 209 |
| 200 | 210 |
| 201 // ==== Events logged by --log-code. ==== | 211 // ==== Events logged by --log-code. ==== |
| 202 // Emits a code event for a callback function. | 212 // Emits a code event for a callback function. |
| 203 static void CallbackEvent(String* name, Address entry_point); | 213 void CallbackEvent(String* name, Address entry_point); |
| 204 static void GetterCallbackEvent(String* name, Address entry_point); | 214 void GetterCallbackEvent(String* name, Address entry_point); |
| 205 static void SetterCallbackEvent(String* name, Address entry_point); | 215 void SetterCallbackEvent(String* name, Address entry_point); |
| 206 // Emits a code create event. | 216 // Emits a code create event. |
| 207 static void CodeCreateEvent(LogEventsAndTags tag, | 217 void CodeCreateEvent(LogEventsAndTags tag, |
| 208 Code* code, const char* source); | 218 Code* code, const char* source); |
| 209 static void CodeCreateEvent(LogEventsAndTags tag, | 219 void CodeCreateEvent(LogEventsAndTags tag, |
| 210 Code* code, String* name); | 220 Code* code, String* name); |
| 211 static void CodeCreateEvent(LogEventsAndTags tag, | 221 void CodeCreateEvent(LogEventsAndTags tag, |
| 212 Code* code, | 222 Code* code, |
| 213 SharedFunctionInfo* shared, | 223 SharedFunctionInfo* shared, |
| 214 String* name); | 224 String* name); |
| 215 static void CodeCreateEvent(LogEventsAndTags tag, | 225 void CodeCreateEvent(LogEventsAndTags tag, |
| 216 Code* code, | 226 Code* code, |
| 217 SharedFunctionInfo* shared, | 227 SharedFunctionInfo* shared, |
| 218 String* source, int line); | 228 String* source, int line); |
| 219 static void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count); | 229 void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count); |
| 220 static void CodeMovingGCEvent(); | 230 void CodeMovingGCEvent(); |
| 221 // Emits a code create event for a RegExp. | 231 // Emits a code create event for a RegExp. |
| 222 static void RegExpCodeCreateEvent(Code* code, String* source); | 232 void RegExpCodeCreateEvent(Code* code, String* source); |
| 223 // Emits a code move event. | 233 // Emits a code move event. |
| 224 static void CodeMoveEvent(Address from, Address to); | 234 void CodeMoveEvent(Address from, Address to); |
| 225 // Emits a code delete event. | 235 // Emits a code delete event. |
| 226 static void CodeDeleteEvent(Address from); | 236 void CodeDeleteEvent(Address from); |
| 227 | 237 |
| 228 static void SharedFunctionInfoMoveEvent(Address from, Address to); | 238 void SharedFunctionInfoMoveEvent(Address from, Address to); |
| 229 | 239 |
| 230 static void SnapshotPositionEvent(Address addr, int pos); | 240 void SnapshotPositionEvent(Address addr, int pos); |
| 231 | 241 |
| 232 // ==== Events logged by --log-gc. ==== | 242 // ==== Events logged by --log-gc. ==== |
| 233 // Heap sampling events: start, end, and individual types. | 243 // Heap sampling events: start, end, and individual types. |
| 234 static void HeapSampleBeginEvent(const char* space, const char* kind); | 244 void HeapSampleBeginEvent(const char* space, const char* kind); |
| 235 static void HeapSampleEndEvent(const char* space, const char* kind); | 245 void HeapSampleEndEvent(const char* space, const char* kind); |
| 236 static void HeapSampleItemEvent(const char* type, int number, int bytes); | 246 void HeapSampleItemEvent(const char* type, int number, int bytes); |
| 237 static void HeapSampleJSConstructorEvent(const char* constructor, | 247 void HeapSampleJSConstructorEvent(const char* constructor, |
| 238 int number, int bytes); | 248 int number, int bytes); |
| 239 static void HeapSampleJSRetainersEvent(const char* constructor, | 249 void HeapSampleJSRetainersEvent(const char* constructor, |
| 240 const char* event); | 250 const char* event); |
| 241 static void HeapSampleJSProducerEvent(const char* constructor, | 251 void HeapSampleJSProducerEvent(const char* constructor, |
| 242 Address* stack); | 252 Address* stack); |
| 243 static void HeapSampleStats(const char* space, const char* kind, | 253 void HeapSampleStats(const char* space, const char* kind, |
| 244 intptr_t capacity, intptr_t used); | 254 intptr_t capacity, intptr_t used); |
| 245 | 255 |
| 246 static void SharedLibraryEvent(const char* library_path, | 256 void SharedLibraryEvent(const char* library_path, |
| 247 uintptr_t start, | 257 uintptr_t start, |
| 248 uintptr_t end); | 258 uintptr_t end); |
| 249 static void SharedLibraryEvent(const wchar_t* library_path, | 259 void SharedLibraryEvent(const wchar_t* library_path, |
| 250 uintptr_t start, | 260 uintptr_t start, |
| 251 uintptr_t end); | 261 uintptr_t end); |
| 252 | 262 |
| 253 // ==== Events logged by --log-regexp ==== | 263 // ==== Events logged by --log-regexp ==== |
| 254 // Regexp compilation and execution events. | 264 // Regexp compilation and execution events. |
| 255 | 265 |
| 256 static void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 266 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
| 257 | 267 |
| 258 // Log an event reported from generated code | 268 // Log an event reported from generated code |
| 259 static void LogRuntime(Vector<const char> format, JSArray* args); | 269 void LogRuntime(Vector<const char> format, JSArray* args); |
| 260 | 270 |
| 261 #ifdef ENABLE_LOGGING_AND_PROFILING | 271 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 262 static bool is_logging() { | 272 bool is_logging() { |
| 263 return logging_nesting_ > 0; | 273 return logging_nesting_ > 0; |
| 264 } | 274 } |
| 265 | 275 |
| 266 // Pause/Resume collection of profiling data. | 276 // Pause/Resume collection of profiling data. |
| 267 // When data collection is paused, CPU Tick events are discarded until | 277 // When data collection is paused, CPU Tick events are discarded until |
| 268 // data collection is Resumed. | 278 // data collection is Resumed. |
| 269 static void PauseProfiler(int flags, int tag); | 279 void PauseProfiler(int flags, int tag); |
| 270 static void ResumeProfiler(int flags, int tag); | 280 void ResumeProfiler(int flags, int tag); |
| 271 static int GetActiveProfilerModules(); | 281 int GetActiveProfilerModules(); |
| 272 | 282 |
| 273 // If logging is performed into a memory buffer, allows to | 283 // If logging is performed into a memory buffer, allows to |
| 274 // retrieve previously written messages. See v8.h. | 284 // retrieve previously written messages. See v8.h. |
| 275 static int GetLogLines(int from_pos, char* dest_buf, int max_size); | 285 int GetLogLines(int from_pos, char* dest_buf, int max_size); |
| 276 | 286 |
| 277 // Logs all compiled functions found in the heap. | 287 // Logs all compiled functions found in the heap. |
| 278 static void LogCompiledFunctions(); | 288 void LogCompiledFunctions(); |
| 279 // Logs all accessor callbacks found in the heap. | 289 // Logs all accessor callbacks found in the heap. |
| 280 static void LogAccessorCallbacks(); | 290 void LogAccessorCallbacks(); |
| 281 // Used for logging stubs found in the snapshot. | 291 // Used for logging stubs found in the snapshot. |
| 282 static void LogCodeObjects(); | 292 void LogCodeObjects(); |
| 283 | 293 |
| 284 // Converts tag to a corresponding NATIVE_... if the script is native. | 294 // Converts tag to a corresponding NATIVE_... if the script is native. |
| 285 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); | 295 INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); |
| 286 | 296 |
| 287 // Profiler's sampling interval (in milliseconds). | 297 // Profiler's sampling interval (in milliseconds). |
| 288 static const int kSamplingIntervalMs = 1; | 298 static const int kSamplingIntervalMs = 1; |
| 289 | 299 |
| 300 // Callback from Log, stops profiling in case of insufficient resources. |
| 301 void LogFailure(); |
| 302 |
| 290 private: | 303 private: |
| 304 Logger(); |
| 305 ~Logger(); |
| 291 | 306 |
| 292 // Emits the profiler's first message. | 307 // Emits the profiler's first message. |
| 293 static void ProfilerBeginEvent(); | 308 void ProfilerBeginEvent(); |
| 294 | 309 |
| 295 // Emits callback event messages. | 310 // Emits callback event messages. |
| 296 static void CallbackEventInternal(const char* prefix, | 311 void CallbackEventInternal(const char* prefix, |
| 297 const char* name, | 312 const char* name, |
| 298 Address entry_point); | 313 Address entry_point); |
| 299 | 314 |
| 300 // Internal configurable move event. | 315 // Internal configurable move event. |
| 301 static void MoveEventInternal(LogEventsAndTags event, | 316 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); |
| 302 Address from, | |
| 303 Address to); | |
| 304 | 317 |
| 305 // Internal configurable move event. | 318 // Internal configurable move event. |
| 306 static void DeleteEventInternal(LogEventsAndTags event, | 319 void DeleteEventInternal(LogEventsAndTags event, Address from); |
| 307 Address from); | |
| 308 | 320 |
| 309 // Emits the source code of a regexp. Used by regexp events. | 321 // Emits the source code of a regexp. Used by regexp events. |
| 310 static void LogRegExpSource(Handle<JSRegExp> regexp); | 322 void LogRegExpSource(Handle<JSRegExp> regexp); |
| 311 | 323 |
| 312 // Used for logging stubs found in the snapshot. | 324 // Used for logging stubs found in the snapshot. |
| 313 static void LogCodeObject(Object* code_object); | 325 void LogCodeObject(Object* code_object); |
| 314 | 326 |
| 315 // Emits general information about generated code. | 327 // Emits general information about generated code. |
| 316 static void LogCodeInfo(); | 328 void LogCodeInfo(); |
| 317 | 329 |
| 318 // Handles code creation when low-level profiling is active. | 330 // Handles code creation when low-level profiling is active. |
| 319 static void LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg); | 331 void LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg); |
| 320 | 332 |
| 321 // Emits a profiler tick event. Used by the profiler thread. | 333 // Emits a profiler tick event. Used by the profiler thread. |
| 322 static void TickEvent(TickSample* sample, bool overflow); | 334 void TickEvent(TickSample* sample, bool overflow); |
| 323 | 335 |
| 324 static void ApiEvent(const char* name, ...); | 336 void ApiEvent(const char* name, ...); |
| 325 | 337 |
| 326 // Logs a StringEvent regardless of whether FLAG_log is true. | 338 // Logs a StringEvent regardless of whether FLAG_log is true. |
| 327 static void UncheckedStringEvent(const char* name, const char* value); | 339 void UncheckedStringEvent(const char* name, const char* value); |
| 328 | 340 |
| 329 // Logs an IntEvent regardless of whether FLAG_log is true. | 341 // Logs an IntEvent regardless of whether FLAG_log is true. |
| 330 static void UncheckedIntEvent(const char* name, int value); | 342 void UncheckedIntEvent(const char* name, int value); |
| 331 static void UncheckedIntPtrTEvent(const char* name, intptr_t value); | 343 void UncheckedIntPtrTEvent(const char* name, intptr_t value); |
| 332 | |
| 333 // Stops logging and profiling in case of insufficient resources. | |
| 334 static void StopLoggingAndProfiling(); | |
| 335 | 344 |
| 336 // Returns whether profiler's sampler is active. | 345 // Returns whether profiler's sampler is active. |
| 337 static bool IsProfilerSamplerActive(); | 346 bool IsProfilerSamplerActive(); |
| 338 | 347 |
| 339 // The sampler used by the profiler and the sliding state window. | 348 // The sampler used by the profiler and the sliding state window. |
| 340 static Ticker* ticker_; | 349 Ticker* ticker_; |
| 341 | 350 |
| 342 // When the statistical profile is active, profiler_ | 351 // When the statistical profile is active, profiler_ |
| 343 // points to a Profiler, that handles collection | 352 // points to a Profiler, that handles collection |
| 344 // of samples. | 353 // of samples. |
| 345 static Profiler* profiler_; | 354 Profiler* profiler_; |
| 346 | 355 |
| 347 // SlidingStateWindow instance keeping a sliding window of the most | 356 // SlidingStateWindow instance keeping a sliding window of the most |
| 348 // recent VM states. | 357 // recent VM states. |
| 349 static SlidingStateWindow* sliding_state_window_; | 358 SlidingStateWindow* sliding_state_window_; |
| 359 |
| 360 // An array of log events names. |
| 361 const char* const* log_events_; |
| 350 | 362 |
| 351 // Internal implementation classes with access to | 363 // Internal implementation classes with access to |
| 352 // private members. | 364 // private members. |
| 353 friend class EventLog; | 365 friend class EventLog; |
| 366 friend class Isolate; |
| 367 friend class LogMessageBuilder; |
| 354 friend class TimeLog; | 368 friend class TimeLog; |
| 355 friend class Profiler; | 369 friend class Profiler; |
| 356 friend class SlidingStateWindow; | 370 friend class SlidingStateWindow; |
| 357 friend class StackTracer; | 371 friend class StackTracer; |
| 358 friend class VMState; | 372 friend class VMState; |
| 359 | 373 |
| 360 friend class LoggerTestHelper; | 374 friend class LoggerTestHelper; |
| 361 | 375 |
| 362 static int logging_nesting_; | 376 |
| 363 static int cpu_profiler_nesting_; | 377 int logging_nesting_; |
| 364 static int heap_profiler_nesting_; | 378 int cpu_profiler_nesting_; |
| 379 int heap_profiler_nesting_; |
| 380 |
| 381 Log* log_; |
| 382 |
| 383 // Guards against multiple calls to TearDown() that can happen in some tests. |
| 384 // 'true' between Setup() and TearDown(). |
| 385 bool is_initialized_; |
| 386 |
| 387 // Support for 'incremental addresses' in compressed logs: |
| 388 // LogMessageBuilder::AppendAddress(Address addr) |
| 389 Address last_address_; |
| 390 // Logger::TickEvent(...) |
| 391 Address prev_sp_; |
| 392 Address prev_function_; |
| 393 // Logger::MoveEventInternal(...) |
| 394 Address prev_to_; |
| 395 // Logger::FunctionCreateEvent(...) |
| 396 Address prev_code_; |
| 365 | 397 |
| 366 friend class CpuProfiler; | 398 friend class CpuProfiler; |
| 367 #else | 399 #else |
| 368 static bool is_logging() { return false; } | 400 bool is_logging() { return false; } |
| 369 #endif | 401 #endif |
| 370 }; | 402 }; |
| 371 | 403 |
| 372 | 404 |
| 405 // Process wide registry of samplers. |
| 406 class SamplerRegistry : public AllStatic { |
| 407 public: |
| 408 enum State { |
| 409 HAS_NO_SAMPLERS, |
| 410 HAS_SAMPLERS, |
| 411 HAS_CPU_PROFILING_SAMPLERS |
| 412 }; |
| 413 |
| 414 typedef void (*VisitSampler)(Sampler*, void*); |
| 415 |
| 416 static State GetState(); |
| 417 |
| 418 // Iterates over all active samplers keeping the internal lock held. |
| 419 // Returns whether there are any active samplers. |
| 420 static bool IterateActiveSamplers(VisitSampler func, void* param); |
| 421 |
| 422 // Adds/Removes an active sampler. |
| 423 static void AddActiveSampler(Sampler* sampler); |
| 424 static void RemoveActiveSampler(Sampler* sampler); |
| 425 |
| 426 private: |
| 427 static bool ActiveSamplersExist() { |
| 428 return active_samplers_ != NULL && !active_samplers_->is_empty(); |
| 429 } |
| 430 |
| 431 static Mutex* mutex_; // Protects the state below. |
| 432 static List<Sampler*>* active_samplers_; |
| 433 |
| 434 DISALLOW_IMPLICIT_CONSTRUCTORS(SamplerRegistry); |
| 435 }; |
| 436 |
| 437 |
| 373 // Class that extracts stack trace, used for profiling. | 438 // Class that extracts stack trace, used for profiling. |
| 374 class StackTracer : public AllStatic { | 439 class StackTracer : public AllStatic { |
| 375 public: | 440 public: |
| 376 static void Trace(TickSample* sample); | 441 static void Trace(Isolate* isolate, TickSample* sample); |
| 377 }; | 442 }; |
| 378 | 443 |
| 379 } } // namespace v8::internal | 444 } } // namespace v8::internal |
| 380 | 445 |
| 381 | 446 |
| 382 #endif // V8_LOG_H_ | 447 #endif // V8_LOG_H_ |
| OLD | NEW |