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

Side by Side Diff: src/log.cc

Issue 19761003: Extract JitLogger from Logger 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 Logger::Logger(Isolate* isolate) 439 Logger::Logger(Isolate* isolate)
440 : isolate_(isolate), 440 : isolate_(isolate),
441 ticker_(NULL), 441 ticker_(NULL),
442 profiler_(NULL), 442 profiler_(NULL),
443 log_events_(NULL), 443 log_events_(NULL),
444 logging_nesting_(0), 444 logging_nesting_(0),
445 cpu_profiler_nesting_(0), 445 cpu_profiler_nesting_(0),
446 log_(new Log(this)), 446 log_(new Log(this)),
447 ll_logger_(NULL), 447 ll_logger_(NULL),
448 jit_logger_(NULL),
448 name_buffer_(new NameBuffer), 449 name_buffer_(new NameBuffer),
449 address_to_name_map_(NULL), 450 address_to_name_map_(NULL),
450 is_initialized_(false), 451 is_initialized_(false),
451 code_event_handler_(NULL),
452 last_address_(NULL), 452 last_address_(NULL),
453 prev_sp_(NULL), 453 prev_sp_(NULL),
454 prev_function_(NULL), 454 prev_function_(NULL),
455 prev_to_(NULL), 455 prev_to_(NULL),
456 prev_code_(NULL), 456 prev_code_(NULL),
457 epoch_(0) { 457 epoch_(0) {
458 } 458 }
459 459
460 460
461 Logger::~Logger() { 461 Logger::~Logger() {
462 delete address_to_name_map_; 462 delete address_to_name_map_;
463 delete name_buffer_; 463 delete name_buffer_;
464 delete log_; 464 delete log_;
465 } 465 }
466 466
467 467
468 void Logger::IssueCodeAddedEvent(Code* code, 468 class JitLogger {
469 Script* script, 469 public:
470 const char* name, 470 explicit JitLogger(JitCodeEventHandler code_event_handler);
471 size_t name_len) { 471
472 void CodeCreateEvent(Code* code, Script* script,
473 const char* name, size_t name_len);
474 void CodeMovedEvent(Address from, Address to);
475 void CodeRemovedEvent(Address from);
476 void AddCodeLinePosInfoEvent(
477 void* jit_handler_data,
478 int pc_offset,
479 int position,
480 JitCodeEvent::PositionType position_type);
481 void* StartCodePosInfoEvent();
482 void EndCodePosInfoEvent(Code* code, void* jit_handler_data);
483
484 private:
485 JitCodeEventHandler code_event_handler_;
486 };
487
488 #define JIT_LOG(Call) if (jit_logger_) jit_logger_->Call;
489
490
491 JitLogger::JitLogger(JitCodeEventHandler code_event_handler)
492 : code_event_handler_(code_event_handler) {
493 }
494
495
496 void JitLogger::CodeCreateEvent(Code* code,
497 Script* script,
498 const char* name,
499 size_t name_len) {
472 JitCodeEvent event; 500 JitCodeEvent event;
473 memset(&event, 0, sizeof(event)); 501 memset(&event, 0, sizeof(event));
474 event.type = JitCodeEvent::CODE_ADDED; 502 event.type = JitCodeEvent::CODE_ADDED;
475 event.code_start = code->instruction_start(); 503 event.code_start = code->instruction_start();
476 event.code_len = code->instruction_size(); 504 event.code_len = code->instruction_size();
477 Handle<Script> script_handle = 505 Handle<Script> script_handle =
478 script != NULL ? Handle<Script>(script) : Handle<Script>(); 506 script != NULL ? Handle<Script>(script) : Handle<Script>();
479 event.script = ToApiHandle<v8::Script>(script_handle); 507 event.script = ToApiHandle<v8::Script>(script_handle);
480 event.name.str = name; 508 event.name.str = name;
481 event.name.len = name_len; 509 event.name.len = name_len;
482 510
483 code_event_handler_(&event); 511 code_event_handler_(&event);
484 } 512 }
485 513
486 514
487 void Logger::IssueCodeMovedEvent(Address from, Address to) { 515 void JitLogger::CodeMovedEvent(Address from, Address to) {
488 Code* from_code = Code::cast(HeapObject::FromAddress(from)); 516 Code* from_code = Code::cast(HeapObject::FromAddress(from));
489 517
490 JitCodeEvent event; 518 JitCodeEvent event;
491 event.type = JitCodeEvent::CODE_MOVED; 519 event.type = JitCodeEvent::CODE_MOVED;
492 event.code_start = from_code->instruction_start(); 520 event.code_start = from_code->instruction_start();
493 event.code_len = from_code->instruction_size(); 521 event.code_len = from_code->instruction_size();
494 522
495 // Calculate the header size. 523 // Calculate the header size.
496 const size_t header_size = 524 const size_t header_size =
497 from_code->instruction_start() - reinterpret_cast<byte*>(from_code); 525 from_code->instruction_start() - reinterpret_cast<byte*>(from_code);
498 526
499 // Calculate the new start address of the instructions. 527 // Calculate the new start address of the instructions.
500 event.new_code_start = 528 event.new_code_start =
501 reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size; 529 reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size;
502 530
503 code_event_handler_(&event); 531 code_event_handler_(&event);
504 } 532 }
505 533
506 534
507 void Logger::IssueCodeRemovedEvent(Address from) { 535 void JitLogger::CodeRemovedEvent(Address from) {
508 Code* from_code = Code::cast(HeapObject::FromAddress(from)); 536 Code* from_code = Code::cast(HeapObject::FromAddress(from));
509 537
510 JitCodeEvent event; 538 JitCodeEvent event;
511 event.type = JitCodeEvent::CODE_REMOVED; 539 event.type = JitCodeEvent::CODE_REMOVED;
512 event.code_start = from_code->instruction_start(); 540 event.code_start = from_code->instruction_start();
513 event.code_len = from_code->instruction_size(); 541 event.code_len = from_code->instruction_size();
514 542
515 code_event_handler_(&event); 543 code_event_handler_(&event);
516 } 544 }
517 545
518 void Logger::IssueAddCodeLinePosInfoEvent( 546 void JitLogger::AddCodeLinePosInfoEvent(
519 void* jit_handler_data, 547 void* jit_handler_data,
520 int pc_offset, 548 int pc_offset,
521 int position, 549 int position,
522 JitCodeEvent::PositionType position_type) { 550 JitCodeEvent::PositionType position_type) {
523 JitCodeEvent event; 551 JitCodeEvent event;
524 memset(&event, 0, sizeof(event)); 552 memset(&event, 0, sizeof(event));
525 event.type = JitCodeEvent::CODE_ADD_LINE_POS_INFO; 553 event.type = JitCodeEvent::CODE_ADD_LINE_POS_INFO;
526 event.user_data = jit_handler_data; 554 event.user_data = jit_handler_data;
527 event.line_info.offset = pc_offset; 555 event.line_info.offset = pc_offset;
528 event.line_info.pos = position; 556 event.line_info.pos = position;
529 event.line_info.position_type = position_type; 557 event.line_info.position_type = position_type;
530 558
531 code_event_handler_(&event); 559 code_event_handler_(&event);
532 } 560 }
533 561
534 562
535 void* Logger::IssueStartCodePosInfoEvent() { 563 void* JitLogger::StartCodePosInfoEvent() {
536 JitCodeEvent event; 564 JitCodeEvent event;
537 memset(&event, 0, sizeof(event)); 565 memset(&event, 0, sizeof(event));
538 event.type = JitCodeEvent::CODE_START_LINE_INFO_RECORDING; 566 event.type = JitCodeEvent::CODE_START_LINE_INFO_RECORDING;
539 567
540 code_event_handler_(&event); 568 code_event_handler_(&event);
541 return event.user_data; 569 return event.user_data;
542 } 570 }
543 571
544 572
545 void Logger::IssueEndCodePosInfoEvent(Code* code, void* jit_handler_data) { 573 void JitLogger::EndCodePosInfoEvent(Code* code, void* jit_handler_data) {
546 JitCodeEvent event; 574 JitCodeEvent event;
547 memset(&event, 0, sizeof(event)); 575 memset(&event, 0, sizeof(event));
548 event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING; 576 event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING;
549 event.code_start = code->instruction_start(); 577 event.code_start = code->instruction_start();
550 event.user_data = jit_handler_data; 578 event.user_data = jit_handler_data;
551 579
552 code_event_handler_(&event); 580 code_event_handler_(&event);
553 } 581 }
554 582
555 #define DECLARE_EVENT(ignore1, name) name, 583 #define DECLARE_EVENT(ignore1, name) name,
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 1004
977 1005
978 void Logger::InitNameBuffer(LogEventsAndTags tag) { 1006 void Logger::InitNameBuffer(LogEventsAndTags tag) {
979 name_buffer_->Reset(); 1007 name_buffer_->Reset();
980 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1008 name_buffer_->AppendBytes(kLogEventsNames[tag]);
981 name_buffer_->AppendByte(':'); 1009 name_buffer_->AppendByte(':');
982 } 1010 }
983 1011
984 1012
985 void Logger::LogRecordedBuffer(Code* code, SharedFunctionInfo* shared) { 1013 void Logger::LogRecordedBuffer(Code* code, SharedFunctionInfo* shared) {
986 if (code_event_handler_ != NULL) { 1014 Script* script = shared && shared->script()->IsScript() ?
987 Script* script = shared && shared->script()->IsScript() ? 1015 Script::cast(shared->script()) : NULL;
988 Script::cast(shared->script()) : NULL; 1016 JIT_LOG(CodeCreateEvent(code, script, name_buffer_->get(),
989 IssueCodeAddedEvent(code, 1017 name_buffer_->size()));
990 script,
991 name_buffer_->get(),
992 name_buffer_->size());
993 }
994 if (!log_->IsEnabled()) return; 1018 if (!log_->IsEnabled()) return;
995 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size())); 1019 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()));
996 if (Serializer::enabled()) { 1020 if (Serializer::enabled()) {
997 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1021 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
998 } 1022 }
999 } 1023 }
1000 1024
1001 1025
1002 void Logger::AppendCodeCreateHeader(LogMessageBuilder* msg, 1026 void Logger::AppendCodeCreateHeader(LogMessageBuilder* msg,
1003 LogEventsAndTags tag, 1027 LogEventsAndTags tag,
(...skipping 18 matching lines...) Expand all
1022 msg->Append("\" "); 1046 msg->Append("\" ");
1023 } 1047 }
1024 msg->Append("hash %x)", symbol->Hash()); 1048 msg->Append("hash %x)", symbol->Hash());
1025 } 1049 }
1026 1050
1027 1051
1028 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1052 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1029 Code* code, 1053 Code* code,
1030 const char* comment) { 1054 const char* comment) {
1031 if (!is_logging_code_events()) return; 1055 if (!is_logging_code_events()) return;
1032 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1056 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1033 InitNameBuffer(tag); 1057 InitNameBuffer(tag);
1034 name_buffer_->AppendBytes(comment); 1058 name_buffer_->AppendBytes(comment);
1035 LogRecordedBuffer(code, NULL); 1059 LogRecordedBuffer(code, NULL);
1036 } 1060 }
1037 1061
1038 if (!FLAG_log_code || !log_->IsEnabled()) return; 1062 if (!FLAG_log_code || !log_->IsEnabled()) return;
1039 LogMessageBuilder msg(this); 1063 LogMessageBuilder msg(this);
1040 AppendCodeCreateHeader(&msg, tag, code); 1064 AppendCodeCreateHeader(&msg, tag, code);
1041 msg.AppendDoubleQuotedString(comment); 1065 msg.AppendDoubleQuotedString(comment);
1042 msg.Append('\n'); 1066 msg.Append('\n');
1043 msg.WriteToLogFile(); 1067 msg.WriteToLogFile();
1044 } 1068 }
1045 1069
1046 1070
1047 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1071 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1048 Code* code, 1072 Code* code,
1049 Name* name) { 1073 Name* name) {
1050 if (!is_logging_code_events()) return; 1074 if (!is_logging_code_events()) return;
1051 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1075 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1052 InitNameBuffer(tag); 1076 InitNameBuffer(tag);
1053 AppendName(name); 1077 AppendName(name);
1054 LogRecordedBuffer(code, NULL); 1078 LogRecordedBuffer(code, NULL);
1055 } 1079 }
1056 1080
1057 if (!FLAG_log_code || !log_->IsEnabled()) return; 1081 if (!FLAG_log_code || !log_->IsEnabled()) return;
1058 LogMessageBuilder msg(this); 1082 LogMessageBuilder msg(this);
1059 AppendCodeCreateHeader(&msg, tag, code); 1083 AppendCodeCreateHeader(&msg, tag, code);
1060 if (name->IsString()) { 1084 if (name->IsString()) {
1061 msg.Append('"'); 1085 msg.Append('"');
(...skipping 16 matching lines...) Expand all
1078 } 1102 }
1079 } 1103 }
1080 1104
1081 1105
1082 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1106 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1083 Code* code, 1107 Code* code,
1084 SharedFunctionInfo* shared, 1108 SharedFunctionInfo* shared,
1085 CompilationInfo* info, 1109 CompilationInfo* info,
1086 Name* name) { 1110 Name* name) {
1087 if (!is_logging_code_events()) return; 1111 if (!is_logging_code_events()) return;
1088 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1112 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1089 InitNameBuffer(tag); 1113 InitNameBuffer(tag);
1090 name_buffer_->AppendBytes(ComputeMarker(code)); 1114 name_buffer_->AppendBytes(ComputeMarker(code));
1091 AppendName(name); 1115 AppendName(name);
1092 LogRecordedBuffer(code, shared); 1116 LogRecordedBuffer(code, shared);
1093 } 1117 }
1094 1118
1095 if (!FLAG_log_code || !log_->IsEnabled()) return; 1119 if (!FLAG_log_code || !log_->IsEnabled()) return;
1096 if (code == isolate_->builtins()->builtin( 1120 if (code == isolate_->builtins()->builtin(
1097 Builtins::kLazyCompile)) 1121 Builtins::kLazyCompile))
1098 return; 1122 return;
(...skipping 17 matching lines...) Expand all
1116 1140
1117 // Although, it is possible to extract source and line from 1141 // Although, it is possible to extract source and line from
1118 // the SharedFunctionInfo object, we left it to caller 1142 // the SharedFunctionInfo object, we left it to caller
1119 // to leave logging functions free from heap allocations. 1143 // to leave logging functions free from heap allocations.
1120 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1144 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1121 Code* code, 1145 Code* code,
1122 SharedFunctionInfo* shared, 1146 SharedFunctionInfo* shared,
1123 CompilationInfo* info, 1147 CompilationInfo* info,
1124 Name* source, int line) { 1148 Name* source, int line) {
1125 if (!is_logging_code_events()) return; 1149 if (!is_logging_code_events()) return;
1126 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1150 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1127 InitNameBuffer(tag); 1151 InitNameBuffer(tag);
1128 name_buffer_->AppendBytes(ComputeMarker(code)); 1152 name_buffer_->AppendBytes(ComputeMarker(code));
1129 name_buffer_->AppendString(shared->DebugName()); 1153 name_buffer_->AppendString(shared->DebugName());
1130 name_buffer_->AppendByte(' '); 1154 name_buffer_->AppendByte(' ');
1131 if (source->IsString()) { 1155 if (source->IsString()) {
1132 name_buffer_->AppendString(String::cast(source)); 1156 name_buffer_->AppendString(String::cast(source));
1133 } else { 1157 } else {
1134 name_buffer_->AppendBytes("symbol(hash "); 1158 name_buffer_->AppendBytes("symbol(hash ");
1135 name_buffer_->AppendHex(Name::cast(source)->Hash()); 1159 name_buffer_->AppendHex(Name::cast(source)->Hash());
1136 name_buffer_->AppendByte(')'); 1160 name_buffer_->AppendByte(')');
(...skipping 19 matching lines...) Expand all
1156 msg.Append(":%d\",", line); 1180 msg.Append(":%d\",", line);
1157 msg.AppendAddress(shared->address()); 1181 msg.AppendAddress(shared->address());
1158 msg.Append(",%s", ComputeMarker(code)); 1182 msg.Append(",%s", ComputeMarker(code));
1159 msg.Append('\n'); 1183 msg.Append('\n');
1160 msg.WriteToLogFile(); 1184 msg.WriteToLogFile();
1161 } 1185 }
1162 1186
1163 1187
1164 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { 1188 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
1165 if (!is_logging_code_events()) return; 1189 if (!is_logging_code_events()) return;
1166 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1190 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1167 InitNameBuffer(tag); 1191 InitNameBuffer(tag);
1168 name_buffer_->AppendInt(args_count); 1192 name_buffer_->AppendInt(args_count);
1169 LogRecordedBuffer(code, NULL); 1193 LogRecordedBuffer(code, NULL);
1170 } 1194 }
1171 1195
1172 if (!FLAG_log_code || !log_->IsEnabled()) return; 1196 if (!FLAG_log_code || !log_->IsEnabled()) return;
1173 LogMessageBuilder msg(this); 1197 LogMessageBuilder msg(this);
1174 AppendCodeCreateHeader(&msg, tag, code); 1198 AppendCodeCreateHeader(&msg, tag, code);
1175 msg.Append("\"args_count: %d\"", args_count); 1199 msg.Append("\"args_count: %d\"", args_count);
1176 msg.Append('\n'); 1200 msg.Append('\n');
1177 msg.WriteToLogFile(); 1201 msg.WriteToLogFile();
1178 } 1202 }
1179 1203
1180 1204
1181 void Logger::CodeMovingGCEvent() { 1205 void Logger::CodeMovingGCEvent() {
1182 if (!log_->IsEnabled() || !FLAG_ll_prof) return; 1206 if (!log_->IsEnabled() || !FLAG_ll_prof) return;
1183 LL_LOG(CodeMovingGCEvent()); 1207 LL_LOG(CodeMovingGCEvent());
1184 OS::SignalCodeMovingGC(); 1208 OS::SignalCodeMovingGC();
1185 } 1209 }
1186 1210
1187 1211
1188 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { 1212 void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
1189 if (!is_logging_code_events()) return; 1213 if (!is_logging_code_events()) return;
1190 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1214 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) {
1191 InitNameBuffer(REG_EXP_TAG); 1215 InitNameBuffer(REG_EXP_TAG);
1192 name_buffer_->AppendString(source); 1216 name_buffer_->AppendString(source);
1193 LogRecordedBuffer(code, NULL); 1217 LogRecordedBuffer(code, NULL);
1194 } 1218 }
1195 1219
1196 if (!FLAG_log_code || !log_->IsEnabled()) return; 1220 if (!FLAG_log_code || !log_->IsEnabled()) return;
1197 LogMessageBuilder msg(this); 1221 LogMessageBuilder msg(this);
1198 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); 1222 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code);
1199 msg.Append('"'); 1223 msg.Append('"');
1200 msg.AppendDetailed(source, false); 1224 msg.AppendDetailed(source, false);
1201 msg.Append('"'); 1225 msg.Append('"');
1202 msg.Append('\n'); 1226 msg.Append('\n');
1203 msg.WriteToLogFile(); 1227 msg.WriteToLogFile();
1204 } 1228 }
1205 1229
1206 1230
1207 void Logger::CodeMoveEvent(Address from, Address to) { 1231 void Logger::CodeMoveEvent(Address from, Address to) {
1208 if (code_event_handler_ != NULL) IssueCodeMovedEvent(from, to); 1232 JIT_LOG(CodeMovedEvent(from, to));
1209 if (!log_->IsEnabled()) return; 1233 if (!log_->IsEnabled()) return;
1210 LL_LOG(CodeMoveEvent(from, to)); 1234 LL_LOG(CodeMoveEvent(from, to));
1211 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1235 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1212 address_to_name_map_->Move(from, to); 1236 address_to_name_map_->Move(from, to);
1213 } 1237 }
1214 MoveEventInternal(CODE_MOVE_EVENT, from, to); 1238 MoveEventInternal(CODE_MOVE_EVENT, from, to);
1215 } 1239 }
1216 1240
1217 1241
1218 void Logger::CodeDeleteEvent(Address from) { 1242 void Logger::CodeDeleteEvent(Address from) {
1219 if (code_event_handler_ != NULL) IssueCodeRemovedEvent(from); 1243 JIT_LOG(CodeRemovedEvent(from));
1220 if (!log_->IsEnabled()) return; 1244 if (!log_->IsEnabled()) return;
1221 LL_LOG(CodeDeleteEvent(from)); 1245 LL_LOG(CodeDeleteEvent(from));
1222 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1246 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1223 address_to_name_map_->Remove(from); 1247 address_to_name_map_->Remove(from);
1224 } 1248 }
1225 DeleteEventInternal(CODE_DELETE_EVENT, from); 1249 DeleteEventInternal(CODE_DELETE_EVENT, from);
1226 } 1250 }
1227 1251
1228 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, 1252 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
1229 int pc_offset, 1253 int pc_offset,
1230 int position) { 1254 int position) {
1231 if (code_event_handler_ != NULL) { 1255 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data,
1232 IssueAddCodeLinePosInfoEvent(jit_handler_data, 1256 pc_offset,
1233 pc_offset, 1257 position,
1234 position, 1258 JitCodeEvent::POSITION));
1235 JitCodeEvent::POSITION);
1236 }
1237 } 1259 }
1238 1260
1239 void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data, 1261 void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
1240 int pc_offset, 1262 int pc_offset,
1241 int position) { 1263 int position) {
1242 if (code_event_handler_ != NULL) { 1264 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data,
1243 IssueAddCodeLinePosInfoEvent(jit_handler_data, 1265 pc_offset,
1244 pc_offset, 1266 position,
1245 position, 1267 JitCodeEvent::STATEMENT_POSITION));
1246 JitCodeEvent::STATEMENT_POSITION);
1247 }
1248 } 1268 }
1249 1269
1250 1270
1251 void Logger::CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder) { 1271 void Logger::CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder) {
1252 if (code_event_handler_ != NULL) { 1272 if (jit_logger_ != NULL) {
1253 pos_recorder->AttachJITHandlerData(IssueStartCodePosInfoEvent()); 1273 pos_recorder->AttachJITHandlerData(jit_logger_->StartCodePosInfoEvent());
1254 } 1274 }
1255 } 1275 }
1256 1276
1257 void Logger::CodeEndLinePosInfoRecordEvent(Code* code, 1277 void Logger::CodeEndLinePosInfoRecordEvent(Code* code,
1258 void* jit_handler_data) { 1278 void* jit_handler_data) {
1259 if (code_event_handler_ != NULL) { 1279 JIT_LOG(EndCodePosInfoEvent(code, jit_handler_data));
1260 IssueEndCodePosInfoEvent(code, jit_handler_data);
1261 }
1262 } 1280 }
1263 1281
1264 1282
1265 void Logger::SnapshotPositionEvent(Address addr, int pos) { 1283 void Logger::SnapshotPositionEvent(Address addr, int pos) {
1266 if (!log_->IsEnabled()) return; 1284 if (!log_->IsEnabled()) return;
1267 LL_LOG(SnapshotPositionEvent(addr, pos)); 1285 LL_LOG(SnapshotPositionEvent(addr, pos));
1268 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1286 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1269 const char* code_name = address_to_name_map_->Lookup(addr); 1287 const char* code_name = address_to_name_map_->Lookup(addr);
1270 if (code_name == NULL) return; // Not a code object. 1288 if (code_name == NULL) return; // Not a code object.
1271 LogMessageBuilder msg(this); 1289 LogMessageBuilder msg(this);
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 } 1921 }
1904 1922
1905 if (FLAG_log_internal_timer_events || FLAG_prof) epoch_ = OS::Ticks(); 1923 if (FLAG_log_internal_timer_events || FLAG_prof) epoch_ = OS::Ticks();
1906 1924
1907 return true; 1925 return true;
1908 } 1926 }
1909 1927
1910 1928
1911 void Logger::SetCodeEventHandler(uint32_t options, 1929 void Logger::SetCodeEventHandler(uint32_t options,
1912 JitCodeEventHandler event_handler) { 1930 JitCodeEventHandler event_handler) {
1913 code_event_handler_ = event_handler; 1931 if (jit_logger_) {
1932 delete jit_logger_;
1933 jit_logger_ = NULL;
1934 }
1914 1935
1915 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { 1936 if (event_handler) {
1937 jit_logger_ = new JitLogger(event_handler);
1938 }
1939
1940 if (jit_logger_ != NULL && (options & kJitCodeEventEnumExisting)) {
1916 HandleScope scope(isolate_); 1941 HandleScope scope(isolate_);
1917 LogCodeObjects(); 1942 LogCodeObjects();
1918 LogCompiledFunctions(); 1943 LogCompiledFunctions();
1919 } 1944 }
1920 } 1945 }
1921 1946
1922 1947
1923 Sampler* Logger::sampler() { 1948 Sampler* Logger::sampler() {
1924 return ticker_; 1949 return ticker_;
1925 } 1950 }
(...skipping 11 matching lines...) Expand all
1937 } 1962 }
1938 1963
1939 delete ticker_; 1964 delete ticker_;
1940 ticker_ = NULL; 1965 ticker_ = NULL;
1941 1966
1942 if (ll_logger_) { 1967 if (ll_logger_) {
1943 delete ll_logger_; 1968 delete ll_logger_;
1944 ll_logger_ = NULL; 1969 ll_logger_ = NULL;
1945 } 1970 }
1946 1971
1972 if (jit_logger_) {
1973 delete jit_logger_;
1974 jit_logger_ = NULL;
1975 }
1976
1947 return log_->Close(); 1977 return log_->Close();
1948 } 1978 }
1949 1979
1950 } } // namespace v8::internal 1980 } } // 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