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