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 "src/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 | 946 |
947 | 947 |
948 // Instantiate template methods. | 948 // Instantiate template methods. |
949 #define V(TimerName, expose) \ | 949 #define V(TimerName, expose) \ |
950 template void TimerEventScope<TimerEvent##TimerName>::LogTimerEvent( \ | 950 template void TimerEventScope<TimerEvent##TimerName>::LogTimerEvent( \ |
951 Logger::StartEnd se); | 951 Logger::StartEnd se); |
952 TIMER_EVENTS_LIST(V) | 952 TIMER_EVENTS_LIST(V) |
953 #undef V | 953 #undef V |
954 | 954 |
955 | 955 |
956 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { | 956 namespace { |
| 957 // Emits the source code of a regexp. Used by regexp events. |
| 958 void LogRegExpSource(Handle<JSRegExp> regexp, Isolate* isolate, |
| 959 Log::MessageBuilder* msg) { |
957 // Prints "/" + re.source + "/" + | 960 // Prints "/" + re.source + "/" + |
958 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") | 961 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") |
959 Log::MessageBuilder msg(log_); | |
960 | 962 |
961 Handle<Object> source = Object::GetProperty( | 963 Handle<Object> source = |
962 isolate_, regexp, "source").ToHandleChecked(); | 964 Object::GetProperty(isolate, regexp, "source").ToHandleChecked(); |
963 if (!source->IsString()) { | 965 if (!source->IsString()) { |
964 msg.Append("no source"); | 966 msg->Append("no source"); |
965 return; | 967 return; |
966 } | 968 } |
967 | 969 |
968 switch (regexp->TypeTag()) { | 970 switch (regexp->TypeTag()) { |
969 case JSRegExp::ATOM: | 971 case JSRegExp::ATOM: |
970 msg.Append('a'); | 972 msg->Append('a'); |
971 break; | 973 break; |
972 default: | 974 default: |
973 break; | 975 break; |
974 } | 976 } |
975 msg.Append('/'); | 977 msg->Append('/'); |
976 msg.AppendDetailed(*Handle<String>::cast(source), false); | 978 msg->AppendDetailed(*Handle<String>::cast(source), false); |
977 msg.Append('/'); | 979 msg->Append('/'); |
978 | 980 |
979 // global flag | 981 // global flag |
980 Handle<Object> global = Object::GetProperty( | 982 Handle<Object> global = |
981 isolate_, regexp, "global").ToHandleChecked(); | 983 Object::GetProperty(isolate, regexp, "global").ToHandleChecked(); |
982 if (global->IsTrue()) { | 984 if (global->IsTrue()) { |
983 msg.Append('g'); | 985 msg->Append('g'); |
984 } | 986 } |
985 // ignorecase flag | 987 // ignorecase flag |
986 Handle<Object> ignorecase = Object::GetProperty( | 988 Handle<Object> ignorecase = |
987 isolate_, regexp, "ignoreCase").ToHandleChecked(); | 989 Object::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked(); |
988 if (ignorecase->IsTrue()) { | 990 if (ignorecase->IsTrue()) { |
989 msg.Append('i'); | 991 msg->Append('i'); |
990 } | 992 } |
991 // multiline flag | 993 // multiline flag |
992 Handle<Object> multiline = Object::GetProperty( | 994 Handle<Object> multiline = |
993 isolate_, regexp, "multiline").ToHandleChecked(); | 995 Object::GetProperty(isolate, regexp, "multiline").ToHandleChecked(); |
994 if (multiline->IsTrue()) { | 996 if (multiline->IsTrue()) { |
995 msg.Append('m'); | 997 msg->Append('m'); |
996 } | 998 } |
997 | |
998 msg.WriteToLogFile(); | |
999 } | 999 } |
| 1000 } // namespace |
1000 | 1001 |
1001 | 1002 |
1002 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { | 1003 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { |
1003 if (!log_->IsEnabled() || !FLAG_log_regexp) return; | 1004 if (!log_->IsEnabled() || !FLAG_log_regexp) return; |
1004 Log::MessageBuilder msg(log_); | 1005 Log::MessageBuilder msg(log_); |
1005 msg.Append("regexp-compile,"); | 1006 msg.Append("regexp-compile,"); |
1006 LogRegExpSource(regexp); | 1007 LogRegExpSource(regexp, isolate_, &msg); |
1007 msg.Append(in_cache ? ",hit" : ",miss"); | 1008 msg.Append(in_cache ? ",hit" : ",miss"); |
1008 msg.WriteToLogFile(); | 1009 msg.WriteToLogFile(); |
1009 } | 1010 } |
1010 | 1011 |
1011 | 1012 |
1012 void Logger::ApiNamedPropertyAccess(const char* tag, | 1013 void Logger::ApiNamedPropertyAccess(const char* tag, |
1013 JSObject* holder, | 1014 JSObject* holder, |
1014 Object* name) { | 1015 Object* name) { |
1015 DCHECK(name->IsName()); | 1016 DCHECK(name->IsName()); |
1016 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1017 if (!log_->IsEnabled() || !FLAG_log_api) return; |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 removeCodeEventListener(jit_logger_); | 1896 removeCodeEventListener(jit_logger_); |
1896 delete jit_logger_; | 1897 delete jit_logger_; |
1897 jit_logger_ = NULL; | 1898 jit_logger_ = NULL; |
1898 } | 1899 } |
1899 | 1900 |
1900 return log_->Close(); | 1901 return log_->Close(); |
1901 } | 1902 } |
1902 | 1903 |
1903 } // namespace internal | 1904 } // namespace internal |
1904 } // namespace v8 | 1905 } // namespace v8 |
OLD | NEW |