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 <memory> | 8 #include <memory> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 isolate->set_current_vm_state(JS); | 886 isolate->set_current_vm_state(JS); |
887 } | 887 } |
888 | 888 |
889 // Instantiate template methods. | 889 // Instantiate template methods. |
890 #define V(TimerName, expose) \ | 890 #define V(TimerName, expose) \ |
891 template void TimerEventScope<TimerEvent##TimerName>::LogTimerEvent( \ | 891 template void TimerEventScope<TimerEvent##TimerName>::LogTimerEvent( \ |
892 Logger::StartEnd se); | 892 Logger::StartEnd se); |
893 TIMER_EVENTS_LIST(V) | 893 TIMER_EVENTS_LIST(V) |
894 #undef V | 894 #undef V |
895 | 895 |
896 | |
897 namespace { | |
898 // Emits the source code of a regexp. Used by regexp events. | |
899 void LogRegExpSource(Handle<JSRegExp> regexp, Isolate* isolate, | |
900 Log::MessageBuilder* msg) { | |
901 // Prints "/" + re.source + "/" + | |
902 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") | |
903 | |
904 Handle<Object> source = | |
905 JSReceiver::GetProperty(isolate, regexp, "source").ToHandleChecked(); | |
906 if (!source->IsString()) { | |
907 msg->Append("no source"); | |
908 return; | |
909 } | |
910 | |
911 switch (regexp->TypeTag()) { | |
912 case JSRegExp::ATOM: | |
913 msg->Append('a'); | |
914 break; | |
915 default: | |
916 break; | |
917 } | |
918 msg->Append('/'); | |
919 msg->AppendDetailed(*Handle<String>::cast(source), false); | |
920 msg->Append('/'); | |
921 | |
922 // global flag | |
923 Handle<Object> global = | |
924 JSReceiver::GetProperty(isolate, regexp, "global").ToHandleChecked(); | |
925 if (global->IsTrue(isolate)) { | |
926 msg->Append('g'); | |
927 } | |
928 // ignorecase flag | |
929 Handle<Object> ignorecase = | |
930 JSReceiver::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked(); | |
931 if (ignorecase->IsTrue(isolate)) { | |
932 msg->Append('i'); | |
933 } | |
934 // multiline flag | |
935 Handle<Object> multiline = | |
936 JSReceiver::GetProperty(isolate, regexp, "multiline").ToHandleChecked(); | |
937 if (multiline->IsTrue(isolate)) { | |
938 msg->Append('m'); | |
939 } | |
940 } | |
941 } // namespace | |
942 | |
943 | |
944 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { | |
945 if (!log_->IsEnabled() || !FLAG_log_regexp) return; | |
946 Log::MessageBuilder msg(log_); | |
947 msg.Append("regexp-compile,"); | |
948 LogRegExpSource(regexp, isolate_, &msg); | |
949 msg.Append(in_cache ? ",hit" : ",miss"); | |
950 msg.WriteToLogFile(); | |
951 } | |
952 | |
953 | |
954 void Logger::ApiNamedPropertyAccess(const char* tag, | 896 void Logger::ApiNamedPropertyAccess(const char* tag, |
955 JSObject* holder, | 897 JSObject* holder, |
956 Object* name) { | 898 Object* name) { |
957 DCHECK(name->IsName()); | 899 DCHECK(name->IsName()); |
958 if (!log_->IsEnabled() || !FLAG_log_api) return; | 900 if (!log_->IsEnabled() || !FLAG_log_api) return; |
959 String* class_name_obj = holder->class_name(); | 901 String* class_name_obj = holder->class_name(); |
960 std::unique_ptr<char[]> class_name = | 902 std::unique_ptr<char[]> class_name = |
961 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 903 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
962 if (name->IsString()) { | 904 if (name->IsString()) { |
963 std::unique_ptr<char[]> property_name = | 905 std::unique_ptr<char[]> property_name = |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 | 1779 |
1838 if (profiler_listener_.get() != nullptr) { | 1780 if (profiler_listener_.get() != nullptr) { |
1839 removeCodeEventListener(profiler_listener_.get()); | 1781 removeCodeEventListener(profiler_listener_.get()); |
1840 } | 1782 } |
1841 | 1783 |
1842 return log_->Close(); | 1784 return log_->Close(); |
1843 } | 1785 } |
1844 | 1786 |
1845 } // namespace internal | 1787 } // namespace internal |
1846 } // namespace v8 | 1788 } // namespace v8 |
OLD | NEW |