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

Side by Side Diff: src/log.cc

Issue 23490015: Reland^2 "Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some windows cleanup Created 7 years, 3 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/log.h ('k') | src/optimizing-compiler-thread.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 : isolate_(isolate), 709 : isolate_(isolate),
710 ticker_(NULL), 710 ticker_(NULL),
711 profiler_(NULL), 711 profiler_(NULL),
712 log_events_(NULL), 712 log_events_(NULL),
713 logging_nesting_(0), 713 logging_nesting_(0),
714 cpu_profiler_nesting_(0), 714 cpu_profiler_nesting_(0),
715 log_(new Log(this)), 715 log_(new Log(this)),
716 ll_logger_(NULL), 716 ll_logger_(NULL),
717 jit_logger_(NULL), 717 jit_logger_(NULL),
718 listeners_(5), 718 listeners_(5),
719 is_initialized_(false), 719 is_initialized_(false) {
720 epoch_(0) {
721 } 720 }
722 721
723 722
724 Logger::~Logger() { 723 Logger::~Logger() {
725 delete log_; 724 delete log_;
726 } 725 }
727 726
728 727
729 void Logger::addCodeEventListener(CodeEventListener* listener) { 728 void Logger::addCodeEventListener(CodeEventListener* listener) {
730 ASSERT(!hasCodeEventListener(listener)); 729 ASSERT(!hasCodeEventListener(listener));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 start, 860 start,
862 end); 861 end);
863 msg.WriteToLogFile(); 862 msg.WriteToLogFile();
864 } 863 }
865 864
866 865
867 void Logger::CodeDeoptEvent(Code* code) { 866 void Logger::CodeDeoptEvent(Code* code) {
868 if (!log_->IsEnabled()) return; 867 if (!log_->IsEnabled()) return;
869 ASSERT(FLAG_log_internal_timer_events); 868 ASSERT(FLAG_log_internal_timer_events);
870 Log::MessageBuilder msg(log_); 869 Log::MessageBuilder msg(log_);
871 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); 870 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds());
872 msg.Append("code-deopt,%ld,%d\n", since_epoch, code->CodeSize()); 871 msg.Append("code-deopt,%ld,%d\n", since_epoch, code->CodeSize());
873 msg.WriteToLogFile(); 872 msg.WriteToLogFile();
874 } 873 }
875 874
876 875
877 void Logger::TimerEvent(StartEnd se, const char* name) { 876 void Logger::TimerEvent(StartEnd se, const char* name) {
878 if (!log_->IsEnabled()) return; 877 if (!log_->IsEnabled()) return;
879 ASSERT(FLAG_log_internal_timer_events); 878 ASSERT(FLAG_log_internal_timer_events);
880 Log::MessageBuilder msg(log_); 879 Log::MessageBuilder msg(log_);
881 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); 880 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds());
882 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n" 881 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n"
883 : "timer-event-end,\"%s\",%ld\n"; 882 : "timer-event-end,\"%s\",%ld\n";
884 msg.Append(format, name, since_epoch); 883 msg.Append(format, name, since_epoch);
885 msg.WriteToLogFile(); 884 msg.WriteToLogFile();
886 } 885 }
887 886
888 887
889 void Logger::EnterExternal(Isolate* isolate) { 888 void Logger::EnterExternal(Isolate* isolate) {
890 LOG(isolate, TimerEvent(START, TimerEventScope::v8_external)); 889 LOG(isolate, TimerEvent(START, TimerEventScope::v8_external));
891 ASSERT(isolate->current_vm_state() == JS); 890 ASSERT(isolate->current_vm_state() == JS);
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 DeleteArray(parameter_string); 1493 DeleteArray(parameter_string);
1495 msg.WriteToLogFile(); 1494 msg.WriteToLogFile();
1496 } 1495 }
1497 1496
1498 1497
1499 void Logger::TickEvent(TickSample* sample, bool overflow) { 1498 void Logger::TickEvent(TickSample* sample, bool overflow) {
1500 if (!log_->IsEnabled() || !FLAG_prof) return; 1499 if (!log_->IsEnabled() || !FLAG_prof) return;
1501 Log::MessageBuilder msg(log_); 1500 Log::MessageBuilder msg(log_);
1502 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); 1501 msg.Append("%s,", kLogEventsNames[TICK_EVENT]);
1503 msg.AppendAddress(sample->pc); 1502 msg.AppendAddress(sample->pc);
1504 msg.Append(",%ld", static_cast<int>(OS::Ticks() - epoch_)); 1503 msg.Append(",%ld", static_cast<int>(timer_.Elapsed().InMicroseconds()));
1505 if (sample->has_external_callback) { 1504 if (sample->has_external_callback) {
1506 msg.Append(",1,"); 1505 msg.Append(",1,");
1507 msg.AppendAddress(sample->external_callback); 1506 msg.AppendAddress(sample->external_callback);
1508 } else { 1507 } else {
1509 msg.Append(",0,"); 1508 msg.Append(",0,");
1510 msg.AppendAddress(sample->tos); 1509 msg.AppendAddress(sample->tos);
1511 } 1510 }
1512 msg.Append(",%d", static_cast<int>(sample->state)); 1511 msg.Append(",%d", static_cast<int>(sample->state));
1513 if (overflow) { 1512 if (overflow) {
1514 msg.Append(",overflow"); 1513 msg.Append(",overflow");
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 if (FLAG_prof) { 1888 if (FLAG_prof) {
1890 profiler_ = new Profiler(isolate); 1889 profiler_ = new Profiler(isolate);
1891 if (FLAG_prof_lazy) { 1890 if (FLAG_prof_lazy) {
1892 profiler_->pause(); 1891 profiler_->pause();
1893 } else { 1892 } else {
1894 logging_nesting_ = 1; 1893 logging_nesting_ = 1;
1895 profiler_->Engage(); 1894 profiler_->Engage();
1896 } 1895 }
1897 } 1896 }
1898 1897
1899 if (FLAG_log_internal_timer_events || FLAG_prof) epoch_ = OS::Ticks(); 1898 if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start();
1900 1899
1901 return true; 1900 return true;
1902 } 1901 }
1903 1902
1904 1903
1905 void Logger::SetCodeEventHandler(uint32_t options, 1904 void Logger::SetCodeEventHandler(uint32_t options,
1906 JitCodeEventHandler event_handler) { 1905 JitCodeEventHandler event_handler) {
1907 if (jit_logger_) { 1906 if (jit_logger_) {
1908 removeCodeEventListener(jit_logger_); 1907 removeCodeEventListener(jit_logger_);
1909 delete jit_logger_; 1908 delete jit_logger_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 if (jit_logger_) { 1949 if (jit_logger_) {
1951 removeCodeEventListener(jit_logger_); 1950 removeCodeEventListener(jit_logger_);
1952 delete jit_logger_; 1951 delete jit_logger_;
1953 jit_logger_ = NULL; 1952 jit_logger_ = NULL;
1954 } 1953 }
1955 1954
1956 return log_->Close(); 1955 return log_->Close();
1957 } 1956 }
1958 1957
1959 } } // namespace v8::internal 1958 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/optimizing-compiler-thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698