OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // --prof | 69 // --prof |
70 // Collect statistical profiling information (ticks), default is off. The | 70 // Collect statistical profiling information (ticks), default is off. The |
71 // tick profiler requires code events, so --prof implies --log-code. | 71 // tick profiler requires code events, so --prof implies --log-code. |
72 | 72 |
73 // Forward declarations. | 73 // Forward declarations. |
74 class LogMessageBuilder; | 74 class LogMessageBuilder; |
75 class Profiler; | 75 class Profiler; |
76 class Semaphore; | 76 class Semaphore; |
77 class Ticker; | 77 class Ticker; |
78 class Isolate; | 78 class Isolate; |
79 class JITCodeLineInfo; | |
79 | 80 |
80 #undef LOG | 81 #undef LOG |
81 #define LOG(isolate, Call) \ | 82 #define LOG(isolate, Call) \ |
82 do { \ | 83 do { \ |
83 v8::internal::Logger* logger = \ | 84 v8::internal::Logger* logger = \ |
84 (isolate)->logger(); \ | 85 (isolate)->logger(); \ |
85 if (logger->is_logging()) \ | 86 if (logger->is_logging()) \ |
86 logger->Call; \ | 87 logger->Call; \ |
87 } while (false) | 88 } while (false) |
88 | 89 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 SharedFunctionInfo* shared, | 240 SharedFunctionInfo* shared, |
240 String* source, int line); | 241 String* source, int line); |
241 void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count); | 242 void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count); |
242 void CodeMovingGCEvent(); | 243 void CodeMovingGCEvent(); |
243 // Emits a code create event for a RegExp. | 244 // Emits a code create event for a RegExp. |
244 void RegExpCodeCreateEvent(Code* code, String* source); | 245 void RegExpCodeCreateEvent(Code* code, String* source); |
245 // Emits a code move event. | 246 // Emits a code move event. |
246 void CodeMoveEvent(Address from, Address to); | 247 void CodeMoveEvent(Address from, Address to); |
247 // Emits a code delete event. | 248 // Emits a code delete event. |
248 void CodeDeleteEvent(Address from); | 249 void CodeDeleteEvent(Address from); |
250 // Emits a code line info add event. | |
251 void CodeLinePosInfoAddEvent(JITCodeLineInfo* line_info, | |
252 int pc_offset, | |
253 int position, | |
254 bool is_statement); | |
255 // Emits a code line info start to record event | |
256 void CodeStartLinePosInfoRecordEvent(JITCodeLineInfo* line_info); | |
257 // Emits a code line info finish record event. | |
258 // It's the callee's responsibility to dispose the parameter line_info data. | |
259 void CodeEndLinePosInfoRecordEvent(Code* code, JITCodeLineInfo* line_info); | |
249 | 260 |
250 void SharedFunctionInfoMoveEvent(Address from, Address to); | 261 void SharedFunctionInfoMoveEvent(Address from, Address to); |
251 | 262 |
252 void SnapshotPositionEvent(Address addr, int pos); | 263 void SnapshotPositionEvent(Address addr, int pos); |
253 | 264 |
254 // ==== Events logged by --log-gc. ==== | 265 // ==== Events logged by --log-gc. ==== |
255 // Heap sampling events: start, end, and individual types. | 266 // Heap sampling events: start, end, and individual types. |
256 void HeapSampleBeginEvent(const char* space, const char* kind); | 267 void HeapSampleBeginEvent(const char* space, const char* kind); |
257 void HeapSampleEndEvent(const char* space, const char* kind); | 268 void HeapSampleEndEvent(const char* space, const char* kind); |
258 void HeapSampleItemEvent(const char* type, int number, int bytes); | 269 void HeapSampleItemEvent(const char* type, int number, int bytes); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 | 319 |
309 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); | 320 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); |
310 | 321 |
311 // Log an event reported from generated code | 322 // Log an event reported from generated code |
312 void LogRuntime(Vector<const char> format, JSArray* args); | 323 void LogRuntime(Vector<const char> format, JSArray* args); |
313 | 324 |
314 bool is_logging() { | 325 bool is_logging() { |
315 return logging_nesting_ > 0; | 326 return logging_nesting_ > 0; |
316 } | 327 } |
317 | 328 |
329 bool is_code_event_handler_enabled() { | |
330 return code_event_handler_ != NULL; | |
331 } | |
332 | |
318 bool is_logging_code_events() { | 333 bool is_logging_code_events() { |
319 return is_logging() || code_event_handler_ != NULL; | 334 return is_logging() || code_event_handler_ != NULL; |
320 } | 335 } |
321 | 336 |
322 // Pause/Resume collection of profiling data. | 337 // Pause/Resume collection of profiling data. |
323 // When data collection is paused, CPU Tick events are discarded until | 338 // When data collection is paused, CPU Tick events are discarded until |
324 // data collection is Resumed. | 339 // data collection is Resumed. |
325 void PauseProfiler(); | 340 void PauseProfiler(); |
326 void ResumeProfiler(); | 341 void ResumeProfiler(); |
327 bool IsProfilerPaused(); | 342 bool IsProfilerPaused(); |
(...skipping 23 matching lines...) Expand all Loading... | |
351 void LogFailure(); | 366 void LogFailure(); |
352 | 367 |
353 private: | 368 private: |
354 class NameBuffer; | 369 class NameBuffer; |
355 class NameMap; | 370 class NameMap; |
356 | 371 |
357 Logger(); | 372 Logger(); |
358 ~Logger(); | 373 ~Logger(); |
359 | 374 |
360 // Issue code notifications. | 375 // Issue code notifications. |
361 void IssueCodeAddedEvent(Code* code, const char* name, size_t name_len); | 376 void IssueCodeAddedEvent(Code* code, |
377 Script* script, | |
378 const char* name, | |
379 size_t name_len); | |
362 void IssueCodeMovedEvent(Address from, Address to); | 380 void IssueCodeMovedEvent(Address from, Address to); |
363 void IssueCodeRemovedEvent(Address from); | 381 void IssueCodeRemovedEvent(Address from); |
364 | 382 void IssueAddCodeLinePosInfoEvent(JITCodeLineInfo* line_info, |
383 int pc_offset, | |
384 int position, | |
385 bool is_statement); | |
386 void IssueStartCodePosInfoEvent(JITCodeLineInfo* line_info); | |
387 void IssueEndCodePosInfoEvent(Code* code, JITCodeLineInfo* line_info); | |
365 // Emits the profiler's first message. | 388 // Emits the profiler's first message. |
366 void ProfilerBeginEvent(); | 389 void ProfilerBeginEvent(); |
367 | 390 |
368 // Emits callback event messages. | 391 // Emits callback event messages. |
369 void CallbackEventInternal(const char* prefix, | 392 void CallbackEventInternal(const char* prefix, |
370 const char* name, | 393 const char* name, |
371 Address entry_point); | 394 Address entry_point); |
372 | 395 |
373 // Internal configurable move event. | 396 // Internal configurable move event. |
374 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); | 397 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 | 527 |
505 private: | 528 private: |
506 static bool ActiveSamplersExist() { | 529 static bool ActiveSamplersExist() { |
507 return active_samplers_ != NULL && !active_samplers_->is_empty(); | 530 return active_samplers_ != NULL && !active_samplers_->is_empty(); |
508 } | 531 } |
509 | 532 |
510 static List<Sampler*>* active_samplers_; | 533 static List<Sampler*>* active_samplers_; |
511 | 534 |
512 DISALLOW_IMPLICIT_CONSTRUCTORS(SamplerRegistry); | 535 DISALLOW_IMPLICIT_CONSTRUCTORS(SamplerRegistry); |
513 }; | 536 }; |
514 | 537 |
danno
2013/01/10 16:47:33
nit: Google style guide, 2 lines of whitespace bet
| |
538 // This class is used to record the JITted code position info for JIT | |
539 // code profiling. | |
540 class JITCodeLineInfo : public Malloced { | |
danno
2013/01/10 16:47:33
As mentioned in the comments for assembler.h, this
chunyang.dai
2013/01/18 10:22:44
I defined this class here in previous patch set be
| |
541 public: | |
542 JITCodeLineInfo() : line_num_info_(10) { } | |
515 | 543 |
544 void SetPosition(intptr_t pc, int pos, bool is_statement) { | |
545 AddCodeLineInfo(LineNumInfo(pc, pos, is_statement)); | |
546 } | |
547 | |
548 struct LineNumInfo { | |
549 LineNumInfo(intptr_t pc, int pos, bool is_statement) | |
550 : pc_(pc), pos_(pos), is_statement_(is_statement) { } | |
551 | |
552 intptr_t pc_; | |
553 int pos_; | |
554 bool is_statement_; | |
555 }; | |
556 | |
557 List<LineNumInfo>* line_numinfo() { | |
558 return &line_num_info_; | |
559 } | |
560 | |
561 private: | |
562 void AddCodeLineInfo(const LineNumInfo& line_info) { | |
563 line_num_info_.Add(line_info); | |
564 } | |
565 List<LineNumInfo> line_num_info_; | |
566 }; | |
danno
2013/01/10 16:47:33
nit: Google style guide, 2 lines of whitespace bet
| |
516 // Class that extracts stack trace, used for profiling. | 567 // Class that extracts stack trace, used for profiling. |
517 class StackTracer : public AllStatic { | 568 class StackTracer : public AllStatic { |
518 public: | 569 public: |
519 static void Trace(Isolate* isolate, TickSample* sample); | 570 static void Trace(Isolate* isolate, TickSample* sample); |
520 }; | 571 }; |
521 | 572 |
522 } } // namespace v8::internal | 573 } } // namespace v8::internal |
523 | 574 |
524 | 575 |
525 #endif // V8_LOG_H_ | 576 #endif // V8_LOG_H_ |
OLD | NEW |