OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 void Logger::CurrentTimeEvent() { | 921 void Logger::CurrentTimeEvent() { |
922 if (!log_->IsEnabled()) return; | 922 if (!log_->IsEnabled()) return; |
923 ASSERT(FLAG_log_internal_timer_events); | 923 ASSERT(FLAG_log_internal_timer_events); |
924 Log::MessageBuilder msg(log_); | 924 Log::MessageBuilder msg(log_); |
925 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); | 925 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); |
926 msg.Append("current-time,%ld\n", since_epoch); | 926 msg.Append("current-time,%ld\n", since_epoch); |
927 msg.WriteToLogFile(); | 927 msg.WriteToLogFile(); |
928 } | 928 } |
929 | 929 |
930 | 930 |
931 void Logger::TimerEvent(StartEnd se, const char* name) { | 931 void Logger::TimerEvent(Logger::StartEnd se, const char* name) { |
932 if (!log_->IsEnabled()) return; | 932 if (!log_->IsEnabled()) return; |
933 ASSERT(FLAG_log_internal_timer_events); | 933 ASSERT(FLAG_log_internal_timer_events); |
934 Log::MessageBuilder msg(log_); | 934 Log::MessageBuilder msg(log_); |
935 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); | 935 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); |
936 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n" | 936 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n" |
937 : "timer-event-end,\"%s\",%ld\n"; | 937 : "timer-event-end,\"%s\",%ld\n"; |
938 msg.Append(format, name, since_epoch); | 938 msg.Append(format, name, since_epoch); |
939 msg.WriteToLogFile(); | 939 msg.WriteToLogFile(); |
940 } | 940 } |
941 | 941 |
942 | 942 |
943 void Logger::EnterExternal(Isolate* isolate) { | 943 void Logger::EnterExternal(Isolate* isolate) { |
944 LOG(isolate, TimerEvent(START, TimerEventScope::v8_external)); | 944 LOG(isolate, TimerEvent(START, TimerEventExternal::name())); |
945 ASSERT(isolate->current_vm_state() == JS); | 945 ASSERT(isolate->current_vm_state() == JS); |
946 isolate->set_current_vm_state(EXTERNAL); | 946 isolate->set_current_vm_state(EXTERNAL); |
947 } | 947 } |
948 | 948 |
949 | 949 |
950 void Logger::LeaveExternal(Isolate* isolate) { | 950 void Logger::LeaveExternal(Isolate* isolate) { |
951 LOG(isolate, TimerEvent(END, TimerEventScope::v8_external)); | 951 LOG(isolate, TimerEvent(END, TimerEventExternal::name())); |
952 ASSERT(isolate->current_vm_state() == EXTERNAL); | 952 ASSERT(isolate->current_vm_state() == EXTERNAL); |
953 isolate->set_current_vm_state(JS); | 953 isolate->set_current_vm_state(JS); |
954 } | 954 } |
955 | 955 |
956 | 956 |
957 void Logger::LogInternalEvents(const char* name, int se) { | 957 void Logger::DefaultTimerEventsLogger(const char* name, int se) { |
958 Isolate* isolate = Isolate::Current(); | 958 Isolate* isolate = Isolate::Current(); |
959 LOG(isolate, TimerEvent(static_cast<StartEnd>(se), name)); | 959 LOG(isolate, TimerEvent(static_cast<StartEnd>(se), name)); |
960 } | 960 } |
961 | 961 |
962 | 962 |
963 void Logger::TimerEventScope::LogTimerEvent(StartEnd se) { | 963 template <class TimerEvent> |
964 isolate_->event_logger()(name_, se); | 964 void TimerEventScope<TimerEvent>::LogTimerEvent(Logger::StartEnd se) { |
| 965 if (TimerEvent::expose_to_api() || |
| 966 isolate_->event_logger() == Logger::DefaultTimerEventsLogger) { |
| 967 isolate_->event_logger()(TimerEvent::name(), se); |
| 968 } |
965 } | 969 } |
966 | 970 |
967 | 971 |
968 const char* Logger::TimerEventScope::v8_recompile_synchronous = | 972 // Instantiate template methods. |
969 "V8.RecompileSynchronous"; | 973 #define V(TimerName, expose) \ |
970 const char* Logger::TimerEventScope::v8_recompile_concurrent = | 974 template void TimerEventScope<TimerEvent##TimerName>::LogTimerEvent( \ |
971 "V8.RecompileConcurrent"; | 975 Logger::StartEnd se); |
972 const char* Logger::TimerEventScope::v8_compile_full_code = | 976 TIMER_EVENTS_LIST(V) |
973 "V8.CompileFullCode"; | 977 #undef V |
974 const char* Logger::TimerEventScope::v8_execute = "V8.Execute"; | |
975 const char* Logger::TimerEventScope::v8_external = "V8.External"; | |
976 const char* Logger::TimerEventScope::v8_ic_miss = "V8.IcMiss"; | |
977 | 978 |
978 | 979 |
979 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { | 980 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
980 // Prints "/" + re.source + "/" + | 981 // Prints "/" + re.source + "/" + |
981 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") | 982 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") |
982 Log::MessageBuilder msg(log_); | 983 Log::MessageBuilder msg(log_); |
983 | 984 |
984 Handle<Object> source = Object::GetProperty( | 985 Handle<Object> source = Object::GetProperty( |
985 isolate_, regexp, "source").ToHandleChecked(); | 986 isolate_, regexp, "source").ToHandleChecked(); |
986 if (!source->IsString()) { | 987 if (!source->IsString()) { |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 if (jit_logger_) { | 1957 if (jit_logger_) { |
1957 removeCodeEventListener(jit_logger_); | 1958 removeCodeEventListener(jit_logger_); |
1958 delete jit_logger_; | 1959 delete jit_logger_; |
1959 jit_logger_ = NULL; | 1960 jit_logger_ = NULL; |
1960 } | 1961 } |
1961 | 1962 |
1962 return log_->Close(); | 1963 return log_->Close(); |
1963 } | 1964 } |
1964 | 1965 |
1965 } } // namespace v8::internal | 1966 } } // namespace v8::internal |
OLD | NEW |