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

Side by Side Diff: src/log.cc

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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/log-utils.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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 856
857 void Logger::DeleteEventStatic(const char* name, void* object) { 857 void Logger::DeleteEventStatic(const char* name, void* object) {
858 Isolate::Current()->logger()->DeleteEvent(name, object); 858 Isolate::Current()->logger()->DeleteEvent(name, object);
859 } 859 }
860 860
861 void Logger::CallbackEventInternal(const char* prefix, Name* name, 861 void Logger::CallbackEventInternal(const char* prefix, Name* name,
862 Address entry_point) { 862 Address entry_point) {
863 if (!log_->IsEnabled() || !FLAG_log_code) return; 863 if (!log_->IsEnabled() || !FLAG_log_code) return;
864 LogMessageBuilder msg(this); 864 LogMessageBuilder msg(this);
865 msg.Append("%s,%s,-3,", 865 msg.Append("%s,%s,-2,",
866 kLogEventsNames[CODE_CREATION_EVENT], 866 kLogEventsNames[CODE_CREATION_EVENT],
867 kLogEventsNames[CALLBACK_TAG]); 867 kLogEventsNames[CALLBACK_TAG]);
868 msg.AppendAddress(entry_point); 868 msg.AppendAddress(entry_point);
869 if (name->IsString()) { 869 if (name->IsString()) {
870 SmartArrayPointer<char> str = 870 SmartArrayPointer<char> str =
871 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 871 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
872 msg.Append(",1,\"%s%s\"", prefix, *str); 872 msg.Append(",1,\"%s%s\"", prefix, *str);
873 } else { 873 } else {
874 Symbol* symbol = Symbol::cast(name); 874 Symbol* symbol = Symbol::cast(name);
875 if (symbol->name()->IsUndefined()) { 875 if (symbol->name()->IsUndefined()) {
(...skipping 20 matching lines...) Expand all
896 CallbackEventInternal("get ", name, entry_point); 896 CallbackEventInternal("get ", name, entry_point);
897 } 897 }
898 898
899 899
900 void Logger::SetterCallbackEvent(Name* name, Address entry_point) { 900 void Logger::SetterCallbackEvent(Name* name, Address entry_point) {
901 if (!log_->IsEnabled() || !FLAG_log_code) return; 901 if (!log_->IsEnabled() || !FLAG_log_code) return;
902 CallbackEventInternal("set ", name, entry_point); 902 CallbackEventInternal("set ", name, entry_point);
903 } 903 }
904 904
905 905
906 void Logger::CodeCreateEvent(LogEventsAndTags tag, 906 void Logger::AppendName(Name* name) {
907 Code* code, 907 if (name->IsString()) {
908 const char* comment) { 908 name_buffer_->AppendString(String::cast(name));
909 if (!is_logging_code_events()) return; 909 } else {
910 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 910 Symbol* symbol = Symbol::cast(name);
911 name_buffer_->AppendBytes("symbol(");
912 if (!symbol->name()->IsUndefined()) {
913 name_buffer_->AppendBytes("\"");
914 name_buffer_->AppendString(String::cast(symbol->name()));
915 name_buffer_->AppendBytes("\" ");
916 }
917 name_buffer_->AppendBytes("hash ");
918 name_buffer_->AppendHex(symbol->Hash());
919 name_buffer_->AppendByte(')');
920 }
921 }
922
923
924 void Logger::InitNameBuffer(LogEventsAndTags tag) {
911 name_buffer_->Reset(); 925 name_buffer_->Reset();
912 name_buffer_->AppendBytes(kLogEventsNames[tag]); 926 name_buffer_->AppendBytes(kLogEventsNames[tag]);
913 name_buffer_->AppendByte(':'); 927 name_buffer_->AppendByte(':');
914 name_buffer_->AppendBytes(comment); 928 }
915 } 929
930
931 void Logger::LogRecordedBuffer(Code* code, SharedFunctionInfo* shared) {
916 if (code_event_handler_ != NULL) { 932 if (code_event_handler_ != NULL) {
917 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size()); 933 Script* script = shared && shared->script()->IsScript() ?
934 Script::cast(shared->script()) : NULL;
935 IssueCodeAddedEvent(code,
936 script,
937 name_buffer_->get(),
938 name_buffer_->size());
918 } 939 }
919 if (!log_->IsEnabled()) return; 940 if (!log_->IsEnabled()) return;
920 if (FLAG_ll_prof) { 941 if (FLAG_ll_prof) {
921 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 942 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
922 } 943 }
923 if (Serializer::enabled()) { 944 if (Serializer::enabled()) {
924 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 945 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
925 } 946 }
926 if (!FLAG_log_code) return; 947 }
948
949
950 void Logger::AppendCodeCreateHeader(LogMessageBuilder* msg,
951 LogEventsAndTags tag,
952 Code* code) {
953 ASSERT(msg);
954 msg->Append("%s,%s,%d,",
955 kLogEventsNames[CODE_CREATION_EVENT],
956 kLogEventsNames[tag],
957 code->kind());
958 msg->AppendAddress(code->address());
959 msg->Append(",%d,", code->ExecutableSize());
960 }
961
962
963 void Logger::AppendSymbolName(LogMessageBuilder* msg,
964 Symbol* symbol) {
965 ASSERT(symbol);
966 msg->Append("symbol(");
967 if (!symbol->name()->IsUndefined()) {
968 msg->Append("\"");
969 msg->AppendDetailed(String::cast(symbol->name()), false);
970 msg->Append("\" ");
971 }
972 msg->Append("hash %x)", symbol->Hash());
973 }
974
975
976 void Logger::CodeCreateEvent(LogEventsAndTags tag,
977 Code* code,
978 const char* comment) {
979 if (!is_logging_code_events()) return;
980 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
981 InitNameBuffer(tag);
982 name_buffer_->AppendBytes(comment);
983 LogRecordedBuffer(code, NULL);
984 }
985
986 if (!FLAG_log_code || !log_->IsEnabled()) return;
927 LogMessageBuilder msg(this); 987 LogMessageBuilder msg(this);
928 msg.Append("%s,%s,%d,", 988 AppendCodeCreateHeader(&msg, tag, code);
929 kLogEventsNames[CODE_CREATION_EVENT], 989 msg.AppendDoubleQuotedString(comment);
930 kLogEventsNames[tag],
931 code->kind());
932 msg.AppendAddress(code->address());
933 msg.Append(",%d,\"", code->ExecutableSize());
934 for (const char* p = comment; *p != '\0'; p++) {
935 if (*p == '"') {
936 msg.Append('\\');
937 }
938 msg.Append(*p);
939 }
940 msg.Append('"');
941 msg.Append('\n'); 990 msg.Append('\n');
942 msg.WriteToLogFile(); 991 msg.WriteToLogFile();
943 } 992 }
944 993
945 994
946 void Logger::CodeCreateEvent(LogEventsAndTags tag, 995 void Logger::CodeCreateEvent(LogEventsAndTags tag,
947 Code* code, 996 Code* code,
948 Name* name) { 997 Name* name) {
949 if (!is_logging_code_events()) return; 998 if (!is_logging_code_events()) return;
950 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 999 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
951 name_buffer_->Reset(); 1000 InitNameBuffer(tag);
952 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1001 AppendName(name);
953 name_buffer_->AppendByte(':'); 1002 LogRecordedBuffer(code, NULL);
954 if (name->IsString()) {
955 name_buffer_->AppendString(String::cast(name));
956 } else {
957 Symbol* symbol = Symbol::cast(name);
958 name_buffer_->AppendBytes("symbol(");
959 if (!symbol->name()->IsUndefined()) {
960 name_buffer_->AppendBytes("\"");
961 name_buffer_->AppendString(String::cast(symbol->name()));
962 name_buffer_->AppendBytes("\" ");
963 }
964 name_buffer_->AppendBytes("hash ");
965 name_buffer_->AppendHex(symbol->Hash());
966 name_buffer_->AppendByte(')');
967 }
968 } 1003 }
969 if (code_event_handler_ != NULL) { 1004
970 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size()); 1005 if (!FLAG_log_code || !log_->IsEnabled()) return;
971 }
972 if (!log_->IsEnabled()) return;
973 if (FLAG_ll_prof) {
974 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
975 }
976 if (Serializer::enabled()) {
977 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
978 }
979 if (!FLAG_log_code) return;
980 LogMessageBuilder msg(this); 1006 LogMessageBuilder msg(this);
981 msg.Append("%s,%s,%d,", 1007 AppendCodeCreateHeader(&msg, tag, code);
982 kLogEventsNames[CODE_CREATION_EVENT],
983 kLogEventsNames[tag],
984 code->kind());
985 msg.AppendAddress(code->address());
986 msg.Append(",%d,", code->ExecutableSize());
987 if (name->IsString()) { 1008 if (name->IsString()) {
988 msg.Append('"'); 1009 msg.Append('"');
989 msg.AppendDetailed(String::cast(name), false); 1010 msg.AppendDetailed(String::cast(name), false);
990 msg.Append('"'); 1011 msg.Append('"');
991 } else { 1012 } else {
992 Symbol* symbol = Symbol::cast(name); 1013 AppendSymbolName(&msg, Symbol::cast(name));
993 msg.Append("symbol(");
994 if (!symbol->name()->IsUndefined()) {
995 msg.Append("\"");
996 msg.AppendDetailed(String::cast(symbol->name()), false);
997 msg.Append("\" ");
998 }
999 msg.Append("hash %x)", symbol->Hash());
1000 } 1014 }
1001 msg.Append('\n'); 1015 msg.Append('\n');
1002 msg.WriteToLogFile(); 1016 msg.WriteToLogFile();
1003 } 1017 }
1004 1018
1005 1019
1006 // ComputeMarker must only be used when SharedFunctionInfo is known. 1020 // ComputeMarker must only be used when SharedFunctionInfo is known.
1007 static const char* ComputeMarker(Code* code) { 1021 static const char* ComputeMarker(Code* code) {
1008 switch (code->kind()) { 1022 switch (code->kind()) {
1009 case Code::FUNCTION: return code->optimizable() ? "~" : ""; 1023 case Code::FUNCTION: return code->optimizable() ? "~" : "";
1010 case Code::OPTIMIZED_FUNCTION: return "*"; 1024 case Code::OPTIMIZED_FUNCTION: return "*";
1011 default: return ""; 1025 default: return "";
1012 } 1026 }
1013 } 1027 }
1014 1028
1015 1029
1016 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1030 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1017 Code* code, 1031 Code* code,
1018 SharedFunctionInfo* shared, 1032 SharedFunctionInfo* shared,
1019 CompilationInfo* info, 1033 CompilationInfo* info,
1020 Name* name) { 1034 Name* name) {
1021 if (!is_logging_code_events()) return; 1035 if (!is_logging_code_events()) return;
1022 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1036 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1023 name_buffer_->Reset(); 1037 InitNameBuffer(tag);
1024 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1025 name_buffer_->AppendByte(':');
1026 name_buffer_->AppendBytes(ComputeMarker(code)); 1038 name_buffer_->AppendBytes(ComputeMarker(code));
1027 if (name->IsString()) { 1039 AppendName(name);
1028 name_buffer_->AppendString(String::cast(name)); 1040 LogRecordedBuffer(code, shared);
1029 } else {
1030 Symbol* symbol = Symbol::cast(name);
1031 name_buffer_->AppendBytes("symbol(");
1032 if (!symbol->name()->IsUndefined()) {
1033 name_buffer_->AppendBytes("\"");
1034 name_buffer_->AppendString(String::cast(symbol->name()));
1035 name_buffer_->AppendBytes("\" ");
1036 }
1037 name_buffer_->AppendBytes("hash ");
1038 name_buffer_->AppendHex(symbol->Hash());
1039 name_buffer_->AppendByte(')');
1040 }
1041 } 1041 }
1042 if (code_event_handler_ != NULL) { 1042
1043 Script* script = 1043 if (!FLAG_log_code || !log_->IsEnabled()) return;
1044 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL;
1045 IssueCodeAddedEvent(code,
1046 script,
1047 name_buffer_->get(),
1048 name_buffer_->size());
1049 }
1050 if (!log_->IsEnabled()) return;
1051 if (FLAG_ll_prof) {
1052 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1053 }
1054 if (Serializer::enabled()) {
1055 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1056 }
1057 if (!FLAG_log_code) return;
1058 if (code == Isolate::Current()->builtins()->builtin( 1044 if (code == Isolate::Current()->builtins()->builtin(
1059 Builtins::kLazyCompile)) 1045 Builtins::kLazyCompile))
1060 return; 1046 return;
1061 1047
1062 LogMessageBuilder msg(this); 1048 LogMessageBuilder msg(this);
1063 msg.Append("%s,%s,%d,", 1049 AppendCodeCreateHeader(&msg, tag, code);
1064 kLogEventsNames[CODE_CREATION_EVENT],
1065 kLogEventsNames[tag],
1066 code->kind());
1067 msg.AppendAddress(code->address());
1068 msg.Append(",%d,", code->ExecutableSize());
1069 if (name->IsString()) { 1050 if (name->IsString()) {
1070 SmartArrayPointer<char> str = 1051 SmartArrayPointer<char> str =
1071 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1052 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1072 msg.Append("\"%s\"", *str); 1053 msg.Append("\"%s\"", *str);
1073 } else { 1054 } else {
1074 Symbol* symbol = Symbol::cast(name); 1055 AppendSymbolName(&msg, Symbol::cast(name));
1075 msg.Append("symbol(");
1076 if (!symbol->name()->IsUndefined()) {
1077 msg.Append("\"");
1078 msg.AppendDetailed(String::cast(symbol->name()), false);
1079 msg.Append("\" ");
1080 }
1081 msg.Append("hash %x)", symbol->Hash());
1082 } 1056 }
1083 msg.Append(','); 1057 msg.Append(',');
1084 msg.AppendAddress(shared->address()); 1058 msg.AppendAddress(shared->address());
1085 msg.Append(",%s", ComputeMarker(code)); 1059 msg.Append(",%s", ComputeMarker(code));
1086 msg.Append('\n'); 1060 msg.Append('\n');
1087 msg.WriteToLogFile(); 1061 msg.WriteToLogFile();
1088 } 1062 }
1089 1063
1090 1064
1091 // Although, it is possible to extract source and line from 1065 // Although, it is possible to extract source and line from
1092 // the SharedFunctionInfo object, we left it to caller 1066 // the SharedFunctionInfo object, we left it to caller
1093 // to leave logging functions free from heap allocations. 1067 // to leave logging functions free from heap allocations.
1094 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1068 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1095 Code* code, 1069 Code* code,
1096 SharedFunctionInfo* shared, 1070 SharedFunctionInfo* shared,
1097 CompilationInfo* info, 1071 CompilationInfo* info,
1098 Name* source, int line) { 1072 Name* source, int line) {
1099 if (!is_logging_code_events()) return; 1073 if (!is_logging_code_events()) return;
1100 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1074 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1101 name_buffer_->Reset(); 1075 InitNameBuffer(tag);
1102 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1103 name_buffer_->AppendByte(':');
1104 name_buffer_->AppendBytes(ComputeMarker(code)); 1076 name_buffer_->AppendBytes(ComputeMarker(code));
1105 name_buffer_->AppendString(shared->DebugName()); 1077 name_buffer_->AppendString(shared->DebugName());
1106 name_buffer_->AppendByte(' '); 1078 name_buffer_->AppendByte(' ');
1107 if (source->IsString()) { 1079 if (source->IsString()) {
1108 name_buffer_->AppendString(String::cast(source)); 1080 name_buffer_->AppendString(String::cast(source));
1109 } else { 1081 } else {
1110 name_buffer_->AppendBytes("symbol(hash "); 1082 name_buffer_->AppendBytes("symbol(hash ");
1111 name_buffer_->AppendHex(Name::cast(source)->Hash()); 1083 name_buffer_->AppendHex(Name::cast(source)->Hash());
1112 name_buffer_->AppendByte(')'); 1084 name_buffer_->AppendByte(')');
1113 } 1085 }
1114 name_buffer_->AppendByte(':'); 1086 name_buffer_->AppendByte(':');
1115 name_buffer_->AppendInt(line); 1087 name_buffer_->AppendInt(line);
1088 LogRecordedBuffer(code, shared);
1116 } 1089 }
1117 if (code_event_handler_ != NULL) { 1090
1118 Script* script = 1091 if (!FLAG_log_code || !log_->IsEnabled()) return;
1119 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL;
1120 IssueCodeAddedEvent(code,
1121 script,
1122 name_buffer_->get(),
1123 name_buffer_->size());
1124 }
1125 if (!log_->IsEnabled()) return;
1126 if (FLAG_ll_prof) {
1127 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1128 }
1129 if (Serializer::enabled()) {
1130 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1131 }
1132 if (!FLAG_log_code) return;
1133 LogMessageBuilder msg(this); 1092 LogMessageBuilder msg(this);
1093 AppendCodeCreateHeader(&msg, tag, code);
1134 SmartArrayPointer<char> name = 1094 SmartArrayPointer<char> name =
1135 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1095 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1136 msg.Append("%s,%s,%d,", 1096 msg.Append("\"%s ", *name);
1137 kLogEventsNames[CODE_CREATION_EVENT],
1138 kLogEventsNames[tag],
1139 code->kind());
1140 msg.AppendAddress(code->address());
1141 msg.Append(",%d,\"%s ", code->ExecutableSize(), *name);
1142 if (source->IsString()) { 1097 if (source->IsString()) {
1143 SmartArrayPointer<char> sourcestr = 1098 SmartArrayPointer<char> sourcestr =
1144 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1099 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1145 msg.Append("%s", *sourcestr); 1100 msg.Append("%s", *sourcestr);
1146 } else { 1101 } else {
1147 Symbol* symbol = Symbol::cast(source); 1102 AppendSymbolName(&msg, Symbol::cast(source));
1148 msg.Append("symbol(");
1149 if (!symbol->name()->IsUndefined()) {
1150 msg.Append("\"");
1151 msg.AppendDetailed(String::cast(symbol->name()), false);
1152 msg.Append("\" ");
1153 }
1154 msg.Append("hash %x)", symbol->Hash());
1155 } 1103 }
1156 msg.Append(":%d\",", line); 1104 msg.Append(":%d\",", line);
1157 msg.AppendAddress(shared->address()); 1105 msg.AppendAddress(shared->address());
1158 msg.Append(",%s", ComputeMarker(code)); 1106 msg.Append(",%s", ComputeMarker(code));
1159 msg.Append('\n'); 1107 msg.Append('\n');
1160 msg.WriteToLogFile(); 1108 msg.WriteToLogFile();
1161 } 1109 }
1162 1110
1163 1111
1164 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { 1112 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
1165 if (!is_logging_code_events()) return; 1113 if (!is_logging_code_events()) return;
1166 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1114 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1167 name_buffer_->Reset(); 1115 InitNameBuffer(tag);
1168 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1169 name_buffer_->AppendByte(':');
1170 name_buffer_->AppendInt(args_count); 1116 name_buffer_->AppendInt(args_count);
1117 LogRecordedBuffer(code, NULL);
1171 } 1118 }
1172 if (code_event_handler_ != NULL) { 1119
1173 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size()); 1120 if (!FLAG_log_code || !log_->IsEnabled()) return;
1174 }
1175 if (!log_->IsEnabled()) return;
1176 if (FLAG_ll_prof) {
1177 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1178 }
1179 if (Serializer::enabled()) {
1180 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1181 }
1182 if (!FLAG_log_code) return;
1183 LogMessageBuilder msg(this); 1121 LogMessageBuilder msg(this);
1184 msg.Append("%s,%s,%d,", 1122 AppendCodeCreateHeader(&msg, tag, code);
1185 kLogEventsNames[CODE_CREATION_EVENT], 1123 msg.Append("\"args_count: %d\"", args_count);
1186 kLogEventsNames[tag],
1187 code->kind());
1188 msg.AppendAddress(code->address());
1189 msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count);
1190 msg.Append('\n'); 1124 msg.Append('\n');
1191 msg.WriteToLogFile(); 1125 msg.WriteToLogFile();
1192 } 1126 }
1193 1127
1194 1128
1195 void Logger::CodeMovingGCEvent() { 1129 void Logger::CodeMovingGCEvent() {
1196 if (!log_->IsEnabled() || !FLAG_ll_prof) return; 1130 if (!log_->IsEnabled() || !FLAG_ll_prof) return;
1197 LowLevelLogWriteBytes(&kCodeMovingGCTag, sizeof(kCodeMovingGCTag)); 1131 LowLevelLogWriteBytes(&kCodeMovingGCTag, sizeof(kCodeMovingGCTag));
1198 OS::SignalCodeMovingGC(); 1132 OS::SignalCodeMovingGC();
1199 } 1133 }
1200 1134
1201 1135
1202 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { 1136 void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
1203 if (!is_logging_code_events()) return; 1137 if (!is_logging_code_events()) return;
1204 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1138 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1205 name_buffer_->Reset(); 1139 InitNameBuffer(REG_EXP_TAG);
1206 name_buffer_->AppendBytes(kLogEventsNames[REG_EXP_TAG]);
1207 name_buffer_->AppendByte(':');
1208 name_buffer_->AppendString(source); 1140 name_buffer_->AppendString(source);
1141 LogRecordedBuffer(code, NULL);
1209 } 1142 }
1210 if (code_event_handler_ != NULL) { 1143
1211 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size()); 1144 if (!FLAG_log_code || !log_->IsEnabled()) return;
1212 }
1213 if (!log_->IsEnabled()) return;
1214 if (FLAG_ll_prof) {
1215 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1216 }
1217 if (Serializer::enabled()) {
1218 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1219 }
1220 if (!FLAG_log_code) return;
1221 LogMessageBuilder msg(this); 1145 LogMessageBuilder msg(this);
1222 msg.Append("%s,%s,-2,", 1146 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code);
1223 kLogEventsNames[CODE_CREATION_EVENT], 1147 msg.Append('"');
1224 kLogEventsNames[REG_EXP_TAG]);
1225 msg.AppendAddress(code->address());
1226 msg.Append(",%d,\"", code->ExecutableSize());
1227 msg.AppendDetailed(source, false); 1148 msg.AppendDetailed(source, false);
1228 msg.Append('\"'); 1149 msg.Append('"');
1229 msg.Append('\n'); 1150 msg.Append('\n');
1230 msg.WriteToLogFile(); 1151 msg.WriteToLogFile();
1231 } 1152 }
1232 1153
1233 1154
1234 void Logger::CodeMoveEvent(Address from, Address to) { 1155 void Logger::CodeMoveEvent(Address from, Address to) {
1235 if (code_event_handler_ != NULL) IssueCodeMovedEvent(from, to); 1156 if (code_event_handler_ != NULL) IssueCodeMovedEvent(from, to);
1236 if (!log_->IsEnabled()) return; 1157 if (!log_->IsEnabled()) return;
1237 if (FLAG_ll_prof) LowLevelCodeMoveEvent(from, to); 1158 if (FLAG_ll_prof) LowLevelCodeMoveEvent(from, to);
1238 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1159 if (Serializer::enabled() && address_to_name_map_ != NULL) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 } 1208 }
1288 } 1209 }
1289 1210
1290 void Logger::SnapshotPositionEvent(Address addr, int pos) { 1211 void Logger::SnapshotPositionEvent(Address addr, int pos) {
1291 if (!log_->IsEnabled()) return; 1212 if (!log_->IsEnabled()) return;
1292 if (FLAG_ll_prof) LowLevelSnapshotPositionEvent(addr, pos); 1213 if (FLAG_ll_prof) LowLevelSnapshotPositionEvent(addr, pos);
1293 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1214 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1294 const char* code_name = address_to_name_map_->Lookup(addr); 1215 const char* code_name = address_to_name_map_->Lookup(addr);
1295 if (code_name == NULL) return; // Not a code object. 1216 if (code_name == NULL) return; // Not a code object.
1296 LogMessageBuilder msg(this); 1217 LogMessageBuilder msg(this);
1297 msg.Append("%s,%d,\"", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); 1218 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos);
1298 for (const char* p = code_name; *p != '\0'; ++p) { 1219 msg.AppendDoubleQuotedString(code_name);
1299 if (*p == '"') msg.Append('\\'); 1220 msg.Append("\n");
1300 msg.Append(*p);
1301 }
1302 msg.Append("\"\n");
1303 msg.WriteToLogFile(); 1221 msg.WriteToLogFile();
1304 } 1222 }
1305 if (!FLAG_log_snapshot_positions) return; 1223 if (!FLAG_log_snapshot_positions) return;
1306 LogMessageBuilder msg(this); 1224 LogMessageBuilder msg(this);
1307 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); 1225 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]);
1308 msg.AppendAddress(addr); 1226 msg.AppendAddress(addr);
1309 msg.Append(",%d", pos); 1227 msg.Append(",%d", pos);
1310 msg.Append('\n'); 1228 msg.Append('\n');
1311 msg.WriteToLogFile(); 1229 msg.WriteToLogFile();
1312 } 1230 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 ? JSObject::cast(obj)->class_name() 1282 ? JSObject::cast(obj)->class_name()
1365 : isolate_->heap()->empty_string(); 1283 : isolate_->heap()->empty_string();
1366 msg.Append("suspect-read,"); 1284 msg.Append("suspect-read,");
1367 msg.Append(class_name); 1285 msg.Append(class_name);
1368 msg.Append(','); 1286 msg.Append(',');
1369 if (name->IsString()) { 1287 if (name->IsString()) {
1370 msg.Append('"'); 1288 msg.Append('"');
1371 msg.Append(String::cast(name)); 1289 msg.Append(String::cast(name));
1372 msg.Append('"'); 1290 msg.Append('"');
1373 } else { 1291 } else {
1374 Symbol* symbol = Symbol::cast(name); 1292 AppendSymbolName(&msg, Symbol::cast(name));
1375 msg.Append("symbol(");
1376 if (!symbol->name()->IsUndefined()) {
1377 msg.Append("\"");
1378 msg.AppendDetailed(String::cast(symbol->name()), false);
1379 msg.Append("\" ");
1380 }
1381 msg.Append("hash %x)", symbol->Hash());
1382 } 1293 }
1383 msg.Append('\n'); 1294 msg.Append('\n');
1384 msg.WriteToLogFile(); 1295 msg.WriteToLogFile();
1385 } 1296 }
1386 1297
1387 1298
1388 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { 1299 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) {
1389 if (!log_->IsEnabled() || !FLAG_log_gc) return; 1300 if (!log_->IsEnabled() || !FLAG_log_gc) return;
1390 LogMessageBuilder msg(this); 1301 LogMessageBuilder msg(this);
1391 // Using non-relative system time in order to be able to synchronize with 1302 // Using non-relative system time in order to be able to synchronize with
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 case Code::COMPARE_IC: // fall through 1504 case Code::COMPARE_IC: // fall through
1594 case Code::COMPARE_NIL_IC: // fall through 1505 case Code::COMPARE_NIL_IC: // fall through
1595 case Code::TO_BOOLEAN_IC: // fall through 1506 case Code::TO_BOOLEAN_IC: // fall through
1596 case Code::STUB: 1507 case Code::STUB:
1597 description = 1508 description =
1598 CodeStub::MajorName(CodeStub::GetMajorKey(code_object), true); 1509 CodeStub::MajorName(CodeStub::GetMajorKey(code_object), true);
1599 if (description == NULL) 1510 if (description == NULL)
1600 description = "A stub from the snapshot"; 1511 description = "A stub from the snapshot";
1601 tag = Logger::STUB_TAG; 1512 tag = Logger::STUB_TAG;
1602 break; 1513 break;
1514 case Code::REGEXP:
1515 description = "Regular expression code";
1516 tag = Logger::REG_EXP_TAG;
1517 break;
1603 case Code::BUILTIN: 1518 case Code::BUILTIN:
1604 description = "A builtin from the snapshot"; 1519 description = "A builtin from the snapshot";
1605 tag = Logger::BUILTIN_TAG; 1520 tag = Logger::BUILTIN_TAG;
1606 break; 1521 break;
1607 case Code::KEYED_LOAD_IC: 1522 case Code::KEYED_LOAD_IC:
1608 description = "A keyed load IC from the snapshot"; 1523 description = "A keyed load IC from the snapshot";
1609 tag = Logger::KEYED_LOAD_IC_TAG; 1524 tag = Logger::KEYED_LOAD_IC_TAG;
1610 break; 1525 break;
1611 case Code::LOAD_IC: 1526 case Code::LOAD_IC:
1612 description = "A load IC from the snapshot"; 1527 description = "A load IC from the snapshot";
1613 tag = Logger::LOAD_IC_TAG; 1528 tag = Logger::LOAD_IC_TAG;
1614 break; 1529 break;
1615 case Code::STORE_IC: 1530 case Code::STORE_IC:
1616 description = "A store IC from the snapshot"; 1531 description = "A store IC from the snapshot";
1617 tag = Logger::STORE_IC_TAG; 1532 tag = Logger::STORE_IC_TAG;
1618 break; 1533 break;
1619 case Code::KEYED_STORE_IC: 1534 case Code::KEYED_STORE_IC:
1620 description = "A keyed store IC from the snapshot"; 1535 description = "A keyed store IC from the snapshot";
1621 tag = Logger::KEYED_STORE_IC_TAG; 1536 tag = Logger::KEYED_STORE_IC_TAG;
1622 break; 1537 break;
1623 case Code::CALL_IC: 1538 case Code::CALL_IC:
1624 description = "A call IC from the snapshot"; 1539 description = "A call IC from the snapshot";
1625 tag = Logger::CALL_IC_TAG; 1540 tag = Logger::CALL_IC_TAG;
1626 break; 1541 break;
1627 case Code::KEYED_CALL_IC: 1542 case Code::KEYED_CALL_IC:
1628 description = "A keyed call IC from the snapshot"; 1543 description = "A keyed call IC from the snapshot";
1629 tag = Logger::KEYED_CALL_IC_TAG; 1544 tag = Logger::KEYED_CALL_IC_TAG;
1630 break; 1545 break;
1546 case Code::NUMBER_OF_KINDS:
1547 break;
1631 } 1548 }
1632 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description)); 1549 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description));
1633 } 1550 }
1634 1551
1635 1552
1636 void Logger::LogCodeInfo() { 1553 void Logger::LogCodeInfo() {
1637 if (!log_->IsEnabled() || !FLAG_ll_prof) return; 1554 if (!log_->IsEnabled() || !FLAG_ll_prof) return;
1638 #if V8_TARGET_ARCH_IA32 1555 #if V8_TARGET_ARCH_IA32
1639 const char arch[] = "ia32"; 1556 const char arch[] = "ia32";
1640 #elif V8_TARGET_ARCH_X64 1557 #elif V8_TARGET_ARCH_X64
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 profiler_ = NULL; 1801 profiler_ = NULL;
1885 } 1802 }
1886 1803
1887 delete ticker_; 1804 delete ticker_;
1888 ticker_ = NULL; 1805 ticker_ = NULL;
1889 1806
1890 return log_->Close(); 1807 return log_->Close();
1891 } 1808 }
1892 1809
1893 } } // namespace v8::internal 1810 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/log-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698