Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: src/log.h

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_LOG_H_ 28 #ifndef V8_LOG_H_
29 #define V8_LOG_H_ 29 #define V8_LOG_H_
30 30
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "objects.h" 32 #include "objects.h"
33 #include "platform.h" 33 #include "platform.h"
34 #include "log-utils.h"
35 34
36 namespace v8 { 35 namespace v8 {
37 namespace internal { 36 namespace internal {
38 37
39 // Logger is used for collecting logging information from V8 during 38 // Logger is used for collecting logging information from V8 during
40 // execution. The result is dumped to a file. 39 // execution. The result is dumped to a file.
41 // 40 //
42 // Available command line flags: 41 // Available command line flags:
43 // 42 //
44 // --log 43 // --log
(...skipping 19 matching lines...) Expand all
64 // --log-regexp implies --log. 63 // --log-regexp implies --log.
65 // 64 //
66 // --logfile <filename> 65 // --logfile <filename>
67 // Specify the name of the logfile, default is "v8.log". 66 // Specify the name of the logfile, default is "v8.log".
68 // 67 //
69 // --prof 68 // --prof
70 // Collect statistical profiling information (ticks), default is off. The 69 // Collect statistical profiling information (ticks), default is off. The
71 // tick profiler requires code events, so --prof implies --log-code. 70 // tick profiler requires code events, so --prof implies --log-code.
72 71
73 // Forward declarations. 72 // Forward declarations.
74 class LogMessageBuilder; 73 class CodeAddressMap;
74 class CompilationInfo;
75 class CpuProfiler;
76 class Isolate;
77 class Log;
78 class PositionsRecorder;
75 class Profiler; 79 class Profiler;
76 class Semaphore; 80 class Semaphore;
81 class Ticker;
77 struct TickSample; 82 struct TickSample;
78 class Ticker;
79 class Isolate;
80 class PositionsRecorder;
81 class CpuProfiler;
82 class CompilationInfo;
83 83
84 #undef LOG 84 #undef LOG
85 #define LOG(isolate, Call) \ 85 #define LOG(isolate, Call) \
86 do { \ 86 do { \
87 v8::internal::Logger* logger = \ 87 v8::internal::Logger* logger = \
88 (isolate)->logger(); \ 88 (isolate)->logger(); \
89 if (logger->is_logging()) \ 89 if (logger->is_logging()) \
90 logger->Call; \ 90 logger->Call; \
91 } while (false) 91 } while (false)
92 92
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 V(STORE_IC_TAG, "StoreIC") \ 144 V(STORE_IC_TAG, "StoreIC") \
145 V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \ 145 V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \
146 V(STUB_TAG, "Stub") \ 146 V(STUB_TAG, "Stub") \
147 V(NATIVE_FUNCTION_TAG, "Function") \ 147 V(NATIVE_FUNCTION_TAG, "Function") \
148 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \ 148 V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \
149 V(NATIVE_SCRIPT_TAG, "Script") 149 V(NATIVE_SCRIPT_TAG, "Script")
150 // Note that 'NATIVE_' cases for functions and scripts are mapped onto 150 // Note that 'NATIVE_' cases for functions and scripts are mapped onto
151 // original tags when writing to the log. 151 // original tags when writing to the log.
152 152
153 153
154 class JitLogger;
154 class LowLevelLogger; 155 class LowLevelLogger;
155 class Sampler; 156 class Sampler;
156 157
157 158
158 class Logger { 159 class Logger {
159 public: 160 public:
160 #define DECLARE_ENUM(enum_item, ignore) enum_item, 161 #define DECLARE_ENUM(enum_item, ignore) enum_item,
161 enum LogEventsAndTags { 162 enum LogEventsAndTags {
162 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) 163 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM)
163 NUMBER_OF_LOG_EVENTS 164 NUMBER_OF_LOG_EVENTS
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 331
331 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); 332 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache);
332 333
333 // Log an event reported from generated code 334 // Log an event reported from generated code
334 void LogRuntime(Vector<const char> format, JSArray* args); 335 void LogRuntime(Vector<const char> format, JSArray* args);
335 336
336 bool is_logging() { 337 bool is_logging() {
337 return logging_nesting_ > 0; 338 return logging_nesting_ > 0;
338 } 339 }
339 340
340 bool is_code_event_handler_enabled() {
341 return code_event_handler_ != NULL;
342 }
343
344 bool is_logging_code_events() { 341 bool is_logging_code_events() {
345 return is_logging() || code_event_handler_ != NULL; 342 return is_logging() || jit_logger_ != NULL;
346 } 343 }
347 344
348 // Pause/Resume collection of profiling data. 345 // Pause/Resume collection of profiling data.
349 // When data collection is paused, CPU Tick events are discarded until 346 // When data collection is paused, CPU Tick events are discarded until
350 // data collection is Resumed. 347 // data collection is Resumed.
351 void PauseProfiler(); 348 void PauseProfiler();
352 void ResumeProfiler(); 349 void ResumeProfiler();
353 bool IsProfilerPaused(); 350 bool IsProfilerPaused();
354 351
355 void LogExistingFunction(Handle<SharedFunctionInfo> shared, 352 void LogExistingFunction(Handle<SharedFunctionInfo> shared,
(...skipping 14 matching lines...) Expand all
370 // and laptop computers for which current heuristics are tuned. 367 // and laptop computers for which current heuristics are tuned.
371 static const int kSamplingIntervalMs = 5; 368 static const int kSamplingIntervalMs = 5;
372 #else 369 #else
373 static const int kSamplingIntervalMs = 1; 370 static const int kSamplingIntervalMs = 1;
374 #endif 371 #endif
375 372
376 // Callback from Log, stops profiling in case of insufficient resources. 373 // Callback from Log, stops profiling in case of insufficient resources.
377 void LogFailure(); 374 void LogFailure();
378 375
379 private: 376 private:
380 class NameBuffer;
381 class NameMap;
382
383 explicit Logger(Isolate* isolate); 377 explicit Logger(Isolate* isolate);
384 ~Logger(); 378 ~Logger();
385 379
386 // Issue code notifications.
387 void IssueCodeAddedEvent(Code* code,
388 Script* script,
389 const char* name,
390 size_t name_len);
391 void IssueCodeMovedEvent(Address from, Address to);
392 void IssueCodeRemovedEvent(Address from);
393 void IssueAddCodeLinePosInfoEvent(void* jit_handler_data,
394 int pc_offset,
395 int position,
396 JitCodeEvent::PositionType position_Type);
397 void* IssueStartCodePosInfoEvent();
398 void IssueEndCodePosInfoEvent(Code* code, void* jit_handler_data);
399 // Emits the profiler's first message. 380 // Emits the profiler's first message.
400 void ProfilerBeginEvent(); 381 void ProfilerBeginEvent();
401 382
402 // Emits callback event messages. 383 // Emits callback event messages.
403 void CallbackEventInternal(const char* prefix, 384 void CallbackEventInternal(const char* prefix,
404 Name* name, 385 Name* name,
405 Address entry_point); 386 Address entry_point);
406 387
407 // Internal configurable move event. 388 // Internal configurable move event.
408 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); 389 void MoveEventInternal(LogEventsAndTags event, Address from, Address to);
409 390
410 // Internal configurable move event.
411 void DeleteEventInternal(LogEventsAndTags event, Address from);
412
413 // Emits the source code of a regexp. Used by regexp events. 391 // Emits the source code of a regexp. Used by regexp events.
414 void LogRegExpSource(Handle<JSRegExp> regexp); 392 void LogRegExpSource(Handle<JSRegExp> regexp);
415 393
416 // Used for logging stubs found in the snapshot. 394 // Used for logging stubs found in the snapshot.
417 void LogCodeObject(Object* code_object); 395 void LogCodeObject(Object* code_object);
418 396
419 // Helper method. It resets name_buffer_ and add tag name into it. 397 // Helper method. It resets name_buffer_ and add tag name into it.
420 void InitNameBuffer(LogEventsAndTags tag); 398 void InitNameBuffer(LogEventsAndTags tag);
421 399
422 // Helper method. It push recorded buffer into different handlers.
423 void LogRecordedBuffer(Code*, SharedFunctionInfo*);
424
425 // Helper method. It dumps name into name_buffer_.
426 void AppendName(Name* name);
427
428 // Appends standard code header.
429 void AppendCodeCreateHeader(LogMessageBuilder*, LogEventsAndTags, Code*);
430
431 // Appends symbol for the name.
432 void AppendSymbolName(LogMessageBuilder*, Symbol*);
433
434 void RegisterSnapshotCodeName(Code* code, const char* name, int name_size);
435
436 // Emits a profiler tick event. Used by the profiler thread. 400 // Emits a profiler tick event. Used by the profiler thread.
437 void TickEvent(TickSample* sample, bool overflow); 401 void TickEvent(TickSample* sample, bool overflow);
438 402
439 void ApiEvent(const char* name, ...); 403 void ApiEvent(const char* name, ...);
440 404
441 // Logs a StringEvent regardless of whether FLAG_log is true. 405 // Logs a StringEvent regardless of whether FLAG_log is true.
442 void UncheckedStringEvent(const char* name, const char* value); 406 void UncheckedStringEvent(const char* name, const char* value);
443 407
444 // Logs an IntEvent regardless of whether FLAG_log is true. 408 // Logs an IntEvent regardless of whether FLAG_log is true.
445 void UncheckedIntEvent(const char* name, int value); 409 void UncheckedIntEvent(const char* name, int value);
446 void UncheckedIntPtrTEvent(const char* name, intptr_t value); 410 void UncheckedIntPtrTEvent(const char* name, intptr_t value);
447 411
448 Isolate* isolate_; 412 Isolate* isolate_;
449 413
450 // The sampler used by the profiler and the sliding state window. 414 // The sampler used by the profiler and the sliding state window.
451 Ticker* ticker_; 415 Ticker* ticker_;
452 416
453 // When the statistical profile is active, profiler_ 417 // When the statistical profile is active, profiler_
454 // points to a Profiler, that handles collection 418 // points to a Profiler, that handles collection
455 // of samples. 419 // of samples.
456 Profiler* profiler_; 420 Profiler* profiler_;
457 421
458 // An array of log events names. 422 // An array of log events names.
459 const char* const* log_events_; 423 const char* const* log_events_;
460 424
461 // Internal implementation classes with access to 425 // Internal implementation classes with access to
462 // private members. 426 // private members.
463 friend class EventLog; 427 friend class EventLog;
464 friend class Isolate; 428 friend class Isolate;
465 friend class LogMessageBuilder;
466 friend class TimeLog; 429 friend class TimeLog;
467 friend class Profiler; 430 friend class Profiler;
468 template <StateTag Tag> friend class VMState; 431 template <StateTag Tag> friend class VMState;
469 432
470 friend class LoggerTestHelper; 433 friend class LoggerTestHelper;
471 434
472 435
473 int logging_nesting_; 436 int logging_nesting_;
474 int cpu_profiler_nesting_; 437 int cpu_profiler_nesting_;
475 438
476 Log* log_; 439 Log* log_;
477 LowLevelLogger* ll_logger_; 440 LowLevelLogger* ll_logger_;
478 441 JitLogger* jit_logger_;
479 NameBuffer* name_buffer_; 442 CodeAddressMap* code_address_map_;
480
481 NameMap* address_to_name_map_;
482 443
483 // Guards against multiple calls to TearDown() that can happen in some tests. 444 // Guards against multiple calls to TearDown() that can happen in some tests.
484 // 'true' between SetUp() and TearDown(). 445 // 'true' between SetUp() and TearDown().
485 bool is_initialized_; 446 bool is_initialized_;
486 447
487 // The code event handler - if any.
488 JitCodeEventHandler code_event_handler_;
489
490 // Support for 'incremental addresses' in compressed logs: 448 // Support for 'incremental addresses' in compressed logs:
491 // LogMessageBuilder::AppendAddress(Address addr) 449 // LogMessageBuilder::AppendAddress(Address addr)
492 Address last_address_; 450 Address last_address_;
493 // Logger::TickEvent(...) 451 // Logger::TickEvent(...)
494 Address prev_sp_; 452 Address prev_sp_;
495 Address prev_function_; 453 Address prev_function_;
496 // Logger::MoveEventInternal(...) 454 // Logger::MoveEventInternal(...)
497 Address prev_to_; 455 Address prev_to_;
498 // Logger::FunctionCreateEvent(...) 456 // Logger::FunctionCreateEvent(...)
499 Address prev_code_; 457 Address prev_code_;
500 458
501 int64_t epoch_; 459 int64_t epoch_;
502 460
503 friend class CpuProfiler; 461 friend class CpuProfiler;
504 }; 462 };
505 463
506 464
507 } } // namespace v8::internal 465 } } // namespace v8::internal
508 466
509 467
510 #endif // V8_LOG_H_ 468 #endif // V8_LOG_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698