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

Side by Side Diff: src/log.cc

Issue 19540012: Logger: extract FLAG_log_code related logging into CodeEventLogger class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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') | no next file » | 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 Logger::Logger(Isolate* isolate) 440 Logger::Logger(Isolate* isolate)
441 : isolate_(isolate), 441 : isolate_(isolate),
442 ticker_(NULL), 442 ticker_(NULL),
443 profiler_(NULL), 443 profiler_(NULL),
444 log_events_(NULL), 444 log_events_(NULL),
445 logging_nesting_(0), 445 logging_nesting_(0),
446 cpu_profiler_nesting_(0), 446 cpu_profiler_nesting_(0),
447 log_(new Log(this)), 447 log_(new Log(this)),
448 ll_logger_(NULL), 448 ll_logger_(NULL),
449 jit_logger_(NULL), 449 jit_logger_(NULL),
450 code_logger_(NULL),
450 name_buffer_(new NameBuffer), 451 name_buffer_(new NameBuffer),
451 address_to_name_map_(NULL), 452 address_to_name_map_(NULL),
452 is_initialized_(false), 453 is_initialized_(false),
453 last_address_(NULL), 454 last_address_(NULL),
454 prev_sp_(NULL), 455 prev_sp_(NULL),
455 prev_function_(NULL), 456 prev_function_(NULL),
456 prev_to_(NULL), 457 prev_to_(NULL),
457 prev_code_(NULL), 458 prev_code_(NULL),
458 epoch_(0) { 459 epoch_(0) {
459 } 460 }
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 void Logger::NewEventStatic(const char* name, void* object, size_t size) { 936 void Logger::NewEventStatic(const char* name, void* object, size_t size) {
936 Isolate::Current()->logger()->NewEvent(name, object, size); 937 Isolate::Current()->logger()->NewEvent(name, object, size);
937 } 938 }
938 939
939 940
940 void Logger::DeleteEventStatic(const char* name, void* object) { 941 void Logger::DeleteEventStatic(const char* name, void* object) {
941 Isolate::Current()->logger()->DeleteEvent(name, object); 942 Isolate::Current()->logger()->DeleteEvent(name, object);
942 } 943 }
943 944
944 945
945 void Logger::CallbackEventInternal(const char* prefix, Name* name, 946 class CodeEventLogger {
yurys 2013/07/18 18:05:05 I'd rather extract EventDispatcher into a separate
946 Address entry_point) { 947 public:
947 if (!log_->IsEnabled() || !FLAG_log_code) return; 948 explicit CodeEventLogger(Log* log) : log_(log) { }
949 void CallbackEvent(const char* prefix, Name* name, Address entry_point);
950 void CodeCreateEvent(Logger::LogEventsAndTags tag,
951 Code* code,
952 const char* comment);
953 void CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, Name* name);
954 void CodeCreateEvent(Logger::LogEventsAndTags tag,
955 Code* code,
956 SharedFunctionInfo* shared,
957 CompilationInfo* info,
958 Name* name);
959 void CodeCreateEvent(Logger::LogEventsAndTags tag,
960 Code* code,
961 SharedFunctionInfo* shared,
962 CompilationInfo* info,
963 Name* source, int line);
964 void CodeCreateEvent(Logger::LogEventsAndTags tag,
965 Code* code,
966 int args_count);
967 void RegExpCodeCreateEvent(Code* code, String* source);
968 void CodeMoveEvent(Logger::LogEventsAndTags event, Address from, Address to);
969 void CodeDeleteEvent(Logger::LogEventsAndTags event, Address from);
970
971 private:
972 class CodeCreateMessageBuilder : public Log::MessageBuilder {
973 public:
974 CodeCreateMessageBuilder(Log* log,
975 Logger::LogEventsAndTags tag,
976 Code* code)
977 : Log::MessageBuilder(log) {
978 Append("%s,%s,%d,",
979 kLogEventsNames[Logger::CODE_CREATION_EVENT],
980 kLogEventsNames[tag],
981 code->kind());
982 AppendAddress(code->address());
983 Append(",%d,", code->ExecutableSize());
984 }
985 };
986
987 Log* log_;
988 };
989
990
991 #define CODE_LOG(Call)\
992 if (log_->IsEnabled() && code_logger_)\
993 code_logger_->Call;
994
995
996 void CodeEventLogger::CallbackEvent(const char* prefix,
997 Name* name,
998 Address entry_point) {
948 Log::MessageBuilder msg(log_); 999 Log::MessageBuilder msg(log_);
949 msg.Append("%s,%s,-2,", 1000 msg.Append("%s,%s,-2,",
950 kLogEventsNames[CODE_CREATION_EVENT], 1001 kLogEventsNames[Logger::CODE_CREATION_EVENT],
951 kLogEventsNames[CALLBACK_TAG]); 1002 kLogEventsNames[Logger::CALLBACK_TAG]);
952 msg.AppendAddress(entry_point); 1003 msg.AppendAddress(entry_point);
953 if (name->IsString()) { 1004 if (name->IsString()) {
954 SmartArrayPointer<char> str = 1005 SmartArrayPointer<char> str =
955 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1006 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
956 msg.Append(",1,\"%s%s\"", prefix, *str); 1007 msg.Append(",1,\"%s%s\"", prefix, *str);
957 } else { 1008 } else {
958 Symbol* symbol = Symbol::cast(name); 1009 Symbol* symbol = Symbol::cast(name);
959 if (symbol->name()->IsUndefined()) { 1010 if (symbol->name()->IsUndefined()) {
960 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash()); 1011 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash());
961 } else { 1012 } else {
962 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( 1013 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
963 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1014 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
964 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, *str, symbol->Hash()); 1015 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, *str, symbol->Hash());
965 } 1016 }
966 } 1017 }
967 msg.Append('\n'); 1018 msg.Append('\n');
968 msg.WriteToLogFile(); 1019 msg.WriteToLogFile();
969 } 1020 }
970 1021
971 1022
972 void Logger::CallbackEvent(Name* name, Address entry_point) { 1023 void Logger::CallbackEvent(Name* name, Address entry_point) {
973 if (!log_->IsEnabled() || !FLAG_log_code) return; 1024 CODE_LOG(CallbackEvent("", name, entry_point));
974 CallbackEventInternal("", name, entry_point);
975 } 1025 }
976 1026
977 1027
978 void Logger::GetterCallbackEvent(Name* name, Address entry_point) { 1028 void Logger::GetterCallbackEvent(Name* name, Address entry_point) {
979 if (!log_->IsEnabled() || !FLAG_log_code) return; 1029 CODE_LOG(CallbackEvent("get ", name, entry_point));
980 CallbackEventInternal("get ", name, entry_point);
981 } 1030 }
982 1031
983 1032
984 void Logger::SetterCallbackEvent(Name* name, Address entry_point) { 1033 void Logger::SetterCallbackEvent(Name* name, Address entry_point) {
985 if (!log_->IsEnabled() || !FLAG_log_code) return; 1034 CODE_LOG(CallbackEvent("set ", name, entry_point));
986 CallbackEventInternal("set ", name, entry_point);
987 } 1035 }
988 1036
989 1037
990 void Logger::AppendName(Name* name) { 1038 void Logger::AppendName(Name* name) {
991 if (name->IsString()) { 1039 if (name->IsString()) {
992 name_buffer_->AppendString(String::cast(name)); 1040 name_buffer_->AppendString(String::cast(name));
993 } else { 1041 } else {
994 Symbol* symbol = Symbol::cast(name); 1042 Symbol* symbol = Symbol::cast(name);
995 name_buffer_->AppendBytes("symbol("); 1043 name_buffer_->AppendBytes("symbol(");
996 if (!symbol->name()->IsUndefined()) { 1044 if (!symbol->name()->IsUndefined()) {
997 name_buffer_->AppendBytes("\""); 1045 name_buffer_->AppendBytes("\"");
998 name_buffer_->AppendString(String::cast(symbol->name())); 1046 name_buffer_->AppendString(String::cast(symbol->name()));
999 name_buffer_->AppendBytes("\" "); 1047 name_buffer_->AppendBytes("\" ");
1000 } 1048 }
1001 name_buffer_->AppendBytes("hash "); 1049 name_buffer_->AppendBytes("hash ");
1002 name_buffer_->AppendHex(symbol->Hash()); 1050 name_buffer_->AppendHex(symbol->Hash());
1003 name_buffer_->AppendByte(')'); 1051 name_buffer_->AppendByte(')');
1004 } 1052 }
1005 } 1053 }
1006 1054
1007 1055
1008 void Logger::InitNameBuffer(LogEventsAndTags tag) { 1056 void Logger::InitNameBuffer(LogEventsAndTags tag) {
1009 name_buffer_->Reset(); 1057 name_buffer_->Reset();
1010 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1058 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1011 name_buffer_->AppendByte(':'); 1059 name_buffer_->AppendByte(':');
1012 } 1060 }
1013 1061
1014 1062
1015 void Logger::LogRecordedBuffer(Code* code, SharedFunctionInfo* shared) { 1063 void Logger::LogRecordedBuffer(Code* code, SharedFunctionInfo* shared) {
1016 Script* script = shared && shared->script()->IsScript() ? 1064 Script* script = shared && shared->script()->IsScript() ?
1017 Script::cast(shared->script()) : NULL; 1065 Script::cast(shared->script()) : NULL;
1018 JIT_LOG(CodeCreateEvent(code, script, name_buffer_->get(), 1066 JIT_LOG(CodeCreateEvent(code, script, name_buffer_->get(),
1019 name_buffer_->size())); 1067 name_buffer_->size()));
1020 if (!log_->IsEnabled()) return; 1068 if (!log_->IsEnabled()) return;
1021 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size())); 1069 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()));
1022 if (Serializer::enabled()) { 1070 if (Serializer::enabled()) {
1023 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1071 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1024 } 1072 }
1025 } 1073 }
1026 1074
1027 1075
1028 static void AppendCodeCreateHeader(Log::MessageBuilder* msg,
1029 Logger::LogEventsAndTags tag,
1030 Code* code) {
1031 ASSERT(msg);
1032 msg->Append("%s,%s,%d,",
1033 kLogEventsNames[Logger::CODE_CREATION_EVENT],
1034 kLogEventsNames[tag],
1035 code->kind());
1036 msg->AppendAddress(code->address());
1037 msg->Append(",%d,", code->ExecutableSize());
1038 }
1039
1040
1041 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1076 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1042 Code* code, 1077 Code* code,
1043 const char* comment) { 1078 const char* comment) {
1044 if (!is_logging_code_events()) return; 1079 if (!is_logging_code_events()) return;
1045 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { 1080 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1046 InitNameBuffer(tag); 1081 InitNameBuffer(tag);
1047 name_buffer_->AppendBytes(comment); 1082 name_buffer_->AppendBytes(comment);
1048 LogRecordedBuffer(code, NULL); 1083 LogRecordedBuffer(code, NULL);
1049 } 1084 }
1085 CODE_LOG(CodeCreateEvent(tag, code, comment));
1086 }
1050 1087
1051 if (!FLAG_log_code || !log_->IsEnabled()) return; 1088
1052 Log::MessageBuilder msg(log_); 1089 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
1053 AppendCodeCreateHeader(&msg, tag, code); 1090 Code* code,
1091 const char* comment) {
1092 CodeCreateMessageBuilder msg(log_, tag, code);
1054 msg.AppendDoubleQuotedString(comment); 1093 msg.AppendDoubleQuotedString(comment);
1055 msg.Append('\n'); 1094 msg.Append('\n');
1056 msg.WriteToLogFile(); 1095 msg.WriteToLogFile();
1057 } 1096 }
1058 1097
1059 1098
1060 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1099 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1061 Code* code, 1100 Code* code,
1062 Name* name) { 1101 Name* name) {
1063 if (!is_logging_code_events()) return; 1102 if (!is_logging_code_events()) return;
1064 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { 1103 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1065 InitNameBuffer(tag); 1104 InitNameBuffer(tag);
1066 AppendName(name); 1105 AppendName(name);
1067 LogRecordedBuffer(code, NULL); 1106 LogRecordedBuffer(code, NULL);
1068 } 1107 }
1108 CODE_LOG(CodeCreateEvent(tag, code, name));
1109 }
1069 1110
1070 if (!FLAG_log_code || !log_->IsEnabled()) return; 1111
1071 Log::MessageBuilder msg(log_); 1112 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
1072 AppendCodeCreateHeader(&msg, tag, code); 1113 Code* code,
1114 Name* name) {
1115 CodeCreateMessageBuilder msg(log_, tag, code);
1073 if (name->IsString()) { 1116 if (name->IsString()) {
1074 msg.Append('"'); 1117 msg.Append('"');
1075 msg.AppendDetailed(String::cast(name), false); 1118 msg.AppendDetailed(String::cast(name), false);
1076 msg.Append('"'); 1119 msg.Append('"');
1077 } else { 1120 } else {
1078 msg.AppendSymbolName(Symbol::cast(name)); 1121 msg.AppendSymbolName(Symbol::cast(name));
1079 } 1122 }
1080 msg.Append('\n'); 1123 msg.Append('\n');
1081 msg.WriteToLogFile(); 1124 msg.WriteToLogFile();
1082 } 1125 }
(...skipping 15 matching lines...) Expand all
1098 CompilationInfo* info, 1141 CompilationInfo* info,
1099 Name* name) { 1142 Name* name) {
1100 if (!is_logging_code_events()) return; 1143 if (!is_logging_code_events()) return;
1101 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { 1144 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1102 InitNameBuffer(tag); 1145 InitNameBuffer(tag);
1103 name_buffer_->AppendBytes(ComputeMarker(code)); 1146 name_buffer_->AppendBytes(ComputeMarker(code));
1104 AppendName(name); 1147 AppendName(name);
1105 LogRecordedBuffer(code, shared); 1148 LogRecordedBuffer(code, shared);
1106 } 1149 }
1107 1150
1108 if (!FLAG_log_code || !log_->IsEnabled()) return; 1151 if (code == isolate_->builtins()->builtin(Builtins::kLazyCompile)) return;
1109 if (code == isolate_->builtins()->builtin( 1152 CODE_LOG(CodeCreateEvent(tag, code, shared, info, name));
1110 Builtins::kLazyCompile)) 1153 }
1111 return;
1112 1154
1113 Log::MessageBuilder msg(log_); 1155
1114 AppendCodeCreateHeader(&msg, tag, code); 1156 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
1157 Code* code,
1158 SharedFunctionInfo* shared,
1159 CompilationInfo* info,
1160 Name* name) {
1161 CodeCreateMessageBuilder msg(log_, tag, code);
1115 if (name->IsString()) { 1162 if (name->IsString()) {
1116 SmartArrayPointer<char> str = 1163 SmartArrayPointer<char> str =
1117 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1164 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1118 msg.Append("\"%s\"", *str); 1165 msg.Append("\"%s\"", *str);
1119 } else { 1166 } else {
1120 msg.AppendSymbolName(Symbol::cast(name)); 1167 msg.AppendSymbolName(Symbol::cast(name));
1121 } 1168 }
1122 msg.Append(','); 1169 msg.Append(',');
1123 msg.AppendAddress(shared->address()); 1170 msg.AppendAddress(shared->address());
1124 msg.Append(",%s", ComputeMarker(code)); 1171 msg.Append(",%s", ComputeMarker(code));
(...skipping 21 matching lines...) Expand all
1146 } else { 1193 } else {
1147 name_buffer_->AppendBytes("symbol(hash "); 1194 name_buffer_->AppendBytes("symbol(hash ");
1148 name_buffer_->AppendHex(Name::cast(source)->Hash()); 1195 name_buffer_->AppendHex(Name::cast(source)->Hash());
1149 name_buffer_->AppendByte(')'); 1196 name_buffer_->AppendByte(')');
1150 } 1197 }
1151 name_buffer_->AppendByte(':'); 1198 name_buffer_->AppendByte(':');
1152 name_buffer_->AppendInt(line); 1199 name_buffer_->AppendInt(line);
1153 LogRecordedBuffer(code, shared); 1200 LogRecordedBuffer(code, shared);
1154 } 1201 }
1155 1202
1156 if (!FLAG_log_code || !log_->IsEnabled()) return; 1203 CODE_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
1157 Log::MessageBuilder msg(log_); 1204 }
1158 AppendCodeCreateHeader(&msg, tag, code); 1205
1206
1207 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
1208 Code* code,
1209 SharedFunctionInfo* shared,
1210 CompilationInfo* info,
1211 Name* source,
1212 int line) {
1213 CodeCreateMessageBuilder msg(log_, tag, code);
1159 SmartArrayPointer<char> name = 1214 SmartArrayPointer<char> name =
1160 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1215 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1161 msg.Append("\"%s ", *name); 1216 msg.Append("\"%s ", *name);
1162 if (source->IsString()) { 1217 if (source->IsString()) {
1163 SmartArrayPointer<char> sourcestr = 1218 SmartArrayPointer<char> sourcestr =
1164 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1219 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1165 msg.Append("%s", *sourcestr); 1220 msg.Append("%s", *sourcestr);
1166 } else { 1221 } else {
1167 msg.AppendSymbolName(Symbol::cast(source)); 1222 msg.AppendSymbolName(Symbol::cast(source));
1168 } 1223 }
1169 msg.Append(":%d\",", line); 1224 msg.Append(":%d\",", line);
1170 msg.AppendAddress(shared->address()); 1225 msg.AppendAddress(shared->address());
1171 msg.Append(",%s", ComputeMarker(code)); 1226 msg.Append(",%s", ComputeMarker(code));
1172 msg.Append('\n'); 1227 msg.Append('\n');
1173 msg.WriteToLogFile(); 1228 msg.WriteToLogFile();
1174 } 1229 }
1175 1230
1176 1231
1177 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { 1232 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
1178 if (!is_logging_code_events()) return; 1233 if (!is_logging_code_events()) return;
1179 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { 1234 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1180 InitNameBuffer(tag); 1235 InitNameBuffer(tag);
1181 name_buffer_->AppendInt(args_count); 1236 name_buffer_->AppendInt(args_count);
1182 LogRecordedBuffer(code, NULL); 1237 LogRecordedBuffer(code, NULL);
1183 } 1238 }
1239 CODE_LOG(CodeCreateEvent(tag, code, args_count));
1240 }
1184 1241
1185 if (!FLAG_log_code || !log_->IsEnabled()) return; 1242
1186 Log::MessageBuilder msg(log_); 1243 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
1187 AppendCodeCreateHeader(&msg, tag, code); 1244 Code* code,
1245 int args_count) {
1246 CodeCreateMessageBuilder msg(log_, tag, code);
1188 msg.Append("\"args_count: %d\"", args_count); 1247 msg.Append("\"args_count: %d\"", args_count);
1189 msg.Append('\n'); 1248 msg.Append('\n');
1190 msg.WriteToLogFile(); 1249 msg.WriteToLogFile();
1191 } 1250 }
1192 1251
1193 1252
1194 void Logger::CodeMovingGCEvent() { 1253 void Logger::CodeMovingGCEvent() {
1195 if (!log_->IsEnabled() || !FLAG_ll_prof) return; 1254 if (!log_->IsEnabled() || !FLAG_ll_prof) return;
1196 LL_LOG(CodeMovingGCEvent()); 1255 LL_LOG(CodeMovingGCEvent());
1197 OS::SignalCodeMovingGC(); 1256 OS::SignalCodeMovingGC();
1198 } 1257 }
1199 1258
1200 1259
1201 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { 1260 void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
1202 if (!is_logging_code_events()) return; 1261 if (!is_logging_code_events()) return;
1203 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { 1262 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1204 InitNameBuffer(REG_EXP_TAG); 1263 InitNameBuffer(REG_EXP_TAG);
1205 name_buffer_->AppendString(source); 1264 name_buffer_->AppendString(source);
1206 LogRecordedBuffer(code, NULL); 1265 LogRecordedBuffer(code, NULL);
1207 } 1266 }
1267 CODE_LOG(RegExpCodeCreateEvent(code, source));
1268 }
1208 1269
1209 if (!FLAG_log_code || !log_->IsEnabled()) return; 1270
1210 Log::MessageBuilder msg(log_); 1271 void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) {
1211 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); 1272 CodeCreateMessageBuilder msg(log_, Logger::REG_EXP_TAG, code);
1212 msg.Append('"'); 1273 msg.Append('"');
1213 msg.AppendDetailed(source, false); 1274 msg.AppendDetailed(source, false);
1214 msg.Append('"'); 1275 msg.Append('"');
1215 msg.Append('\n'); 1276 msg.Append('\n');
1216 msg.WriteToLogFile(); 1277 msg.WriteToLogFile();
1217 } 1278 }
1218 1279
1219 1280
1220 void Logger::CodeMoveEvent(Address from, Address to) { 1281 void Logger::CodeMoveEvent(Address from, Address to) {
1221 JIT_LOG(CodeMovedEvent(from, to)); 1282 JIT_LOG(CodeMovedEvent(from, to));
1222 if (!log_->IsEnabled()) return; 1283 if (!log_->IsEnabled()) return;
1223 LL_LOG(CodeMoveEvent(from, to)); 1284 LL_LOG(CodeMoveEvent(from, to));
1224 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1285 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1225 address_to_name_map_->Move(from, to); 1286 address_to_name_map_->Move(from, to);
1226 } 1287 }
1227 MoveEventInternal(CODE_MOVE_EVENT, from, to); 1288 CODE_LOG(CodeMoveEvent(CODE_MOVE_EVENT, from, to));
1228 } 1289 }
1229 1290
1230 1291
1231 void Logger::CodeDeleteEvent(Address from) { 1292 void Logger::CodeDeleteEvent(Address from) {
1232 JIT_LOG(CodeRemovedEvent(from)); 1293 JIT_LOG(CodeRemovedEvent(from));
1233 if (!log_->IsEnabled()) return; 1294 if (!log_->IsEnabled()) return;
1234 LL_LOG(CodeDeleteEvent(from)); 1295 LL_LOG(CodeDeleteEvent(from));
1235 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1296 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1236 address_to_name_map_->Remove(from); 1297 address_to_name_map_->Remove(from);
1237 } 1298 }
1238 DeleteEventInternal(CODE_DELETE_EVENT, from); 1299 CODE_LOG(CodeDeleteEvent(CODE_DELETE_EVENT, from));
1239 } 1300 }
1240 1301
1241 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, 1302 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
1242 int pc_offset, 1303 int pc_offset,
1243 int position) { 1304 int position) {
1244 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, 1305 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data,
1245 pc_offset, 1306 pc_offset,
1246 position, 1307 position,
1247 JitCodeEvent::POSITION)); 1308 JitCodeEvent::POSITION));
1248 } 1309 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 Log::MessageBuilder msg(log_); 1346 Log::MessageBuilder msg(log_);
1286 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); 1347 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]);
1287 msg.AppendAddress(addr); 1348 msg.AppendAddress(addr);
1288 msg.Append(",%d", pos); 1349 msg.Append(",%d", pos);
1289 msg.Append('\n'); 1350 msg.Append('\n');
1290 msg.WriteToLogFile(); 1351 msg.WriteToLogFile();
1291 } 1352 }
1292 1353
1293 1354
1294 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { 1355 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
1295 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); 1356 CODE_LOG(CodeMoveEvent(SHARED_FUNC_MOVE_EVENT, from, to));
1296 } 1357 }
1297 1358
1298 1359
1299 void Logger::MoveEventInternal(LogEventsAndTags event, 1360 void CodeEventLogger::CodeMoveEvent(Logger::LogEventsAndTags event,
1300 Address from, 1361 Address from,
1301 Address to) { 1362 Address to) {
1302 if (!log_->IsEnabled() || !FLAG_log_code) return;
1303 Log::MessageBuilder msg(log_); 1363 Log::MessageBuilder msg(log_);
1304 msg.Append("%s,", kLogEventsNames[event]); 1364 msg.Append("%s,", kLogEventsNames[event]);
1305 msg.AppendAddress(from); 1365 msg.AppendAddress(from);
1306 msg.Append(','); 1366 msg.Append(',');
1307 msg.AppendAddress(to); 1367 msg.AppendAddress(to);
1308 msg.Append('\n'); 1368 msg.Append('\n');
1309 msg.WriteToLogFile(); 1369 msg.WriteToLogFile();
1310 } 1370 }
1311 1371
1312 1372
1313 void Logger::DeleteEventInternal(LogEventsAndTags event, Address from) { 1373 void CodeEventLogger::CodeDeleteEvent(Logger::LogEventsAndTags event,
1314 if (!log_->IsEnabled() || !FLAG_log_code) return; 1374 Address from) {
1315 Log::MessageBuilder msg(log_); 1375 Log::MessageBuilder msg(log_);
1316 msg.Append("%s,", kLogEventsNames[event]); 1376 msg.Append("%s,", kLogEventsNames[event]);
1317 msg.AppendAddress(from); 1377 msg.AppendAddress(from);
1318 msg.Append('\n'); 1378 msg.Append('\n');
1319 msg.WriteToLogFile(); 1379 msg.WriteToLogFile();
1320 } 1380 }
1321 1381
1322 1382
1323 void Logger::ResourceEvent(const char* name, const char* tag) { 1383 void Logger::ResourceEvent(const char* name, const char* tag) {
1324 if (!log_->IsEnabled() || !FLAG_log) return; 1384 if (!log_->IsEnabled() || !FLAG_log) return;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 } else { 1964 } else {
1905 logging_nesting_ = 1; 1965 logging_nesting_ = 1;
1906 } 1966 }
1907 if (!FLAG_prof_lazy) { 1967 if (!FLAG_prof_lazy) {
1908 profiler_->Engage(); 1968 profiler_->Engage();
1909 } 1969 }
1910 } 1970 }
1911 1971
1912 if (FLAG_log_internal_timer_events || FLAG_prof) epoch_ = OS::Ticks(); 1972 if (FLAG_log_internal_timer_events || FLAG_prof) epoch_ = OS::Ticks();
1913 1973
1974 if (FLAG_log_code) {
1975 code_logger_ = new CodeEventLogger(log_);
1976 }
1977
1914 return true; 1978 return true;
1915 } 1979 }
1916 1980
1917 1981
1918 void Logger::SetCodeEventHandler(uint32_t options, 1982 void Logger::SetCodeEventHandler(uint32_t options,
1919 JitCodeEventHandler event_handler) { 1983 JitCodeEventHandler event_handler) {
1920 if (jit_logger_) { 1984 if (jit_logger_) {
1921 delete jit_logger_; 1985 delete jit_logger_;
1922 jit_logger_ = NULL; 1986 jit_logger_ = NULL;
1923 } 1987 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 if (ll_logger_) { 2020 if (ll_logger_) {
1957 delete ll_logger_; 2021 delete ll_logger_;
1958 ll_logger_ = NULL; 2022 ll_logger_ = NULL;
1959 } 2023 }
1960 2024
1961 if (jit_logger_) { 2025 if (jit_logger_) {
1962 delete jit_logger_; 2026 delete jit_logger_;
1963 jit_logger_ = NULL; 2027 jit_logger_ = NULL;
1964 } 2028 }
1965 2029
2030 if (code_logger_) {
2031 delete code_logger_;
2032 code_logger_ = NULL;
2033 }
2034
1966 return log_->Close(); 2035 return log_->Close();
1967 } 2036 }
1968 2037
1969 } } // namespace v8::internal 2038 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698