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

Side by Side Diff: src/log.cc

Issue 12223027: This patch is the propagation version of https://codereview.chromium.org/10824032 patch (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 10 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') | test/cctest/test-api.cc » ('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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 463
464 Logger::~Logger() { 464 Logger::~Logger() {
465 delete address_to_name_map_; 465 delete address_to_name_map_;
466 delete name_buffer_; 466 delete name_buffer_;
467 delete log_; 467 delete log_;
468 } 468 }
469 469
470 470
471 void Logger::IssueCodeAddedEvent(Code* code, 471 void Logger::IssueCodeAddedEvent(Code* code,
472 Script* script,
472 const char* name, 473 const char* name,
473 size_t name_len) { 474 size_t name_len) {
474 JitCodeEvent event; 475 JitCodeEvent event;
476 memset(&event, 0, sizeof(event));
475 event.type = JitCodeEvent::CODE_ADDED; 477 event.type = JitCodeEvent::CODE_ADDED;
476 event.code_start = code->instruction_start(); 478 event.code_start = code->instruction_start();
477 event.code_len = code->instruction_size(); 479 event.code_len = code->instruction_size();
480 Handle<Script> script_handle =
481 script != NULL ? Handle<Script>(script) : Handle<Script>();
482 event.script = v8::Handle<v8::Script>(ToApi<v8::Script>(script_handle));
478 event.name.str = name; 483 event.name.str = name;
479 event.name.len = name_len; 484 event.name.len = name_len;
480 485
481 code_event_handler_(&event); 486 code_event_handler_(&event);
482 } 487 }
483 488
484 489
485 void Logger::IssueCodeMovedEvent(Address from, Address to) { 490 void Logger::IssueCodeMovedEvent(Address from, Address to) {
486 Code* from_code = Code::cast(HeapObject::FromAddress(from)); 491 Code* from_code = Code::cast(HeapObject::FromAddress(from));
487 492
(...skipping 18 matching lines...) Expand all
506 Code* from_code = Code::cast(HeapObject::FromAddress(from)); 511 Code* from_code = Code::cast(HeapObject::FromAddress(from));
507 512
508 JitCodeEvent event; 513 JitCodeEvent event;
509 event.type = JitCodeEvent::CODE_REMOVED; 514 event.type = JitCodeEvent::CODE_REMOVED;
510 event.code_start = from_code->instruction_start(); 515 event.code_start = from_code->instruction_start();
511 event.code_len = from_code->instruction_size(); 516 event.code_len = from_code->instruction_size();
512 517
513 code_event_handler_(&event); 518 code_event_handler_(&event);
514 } 519 }
515 520
521 void Logger::IssueAddCodeLinePosInfoEvent(
522 void* jit_handler_data,
523 int pc_offset,
524 int position,
525 JitCodeEvent::PositionType position_type) {
526 JitCodeEvent event;
527 memset(&event, 0, sizeof(event));
528 event.type = JitCodeEvent::CODE_ADD_LINE_POS_INFO;
529 event.user_data = jit_handler_data;
530 event.line_info.offset = pc_offset;
531 event.line_info.pos = position;
532 event.line_info.position_type = position_type;
533
534 code_event_handler_(&event);
535 }
536
537 void* Logger::IssueStartCodePosInfoEvent() {
538 JitCodeEvent event;
539 memset(&event, 0, sizeof(event));
540 event.type = JitCodeEvent::CODE_START_LINE_INFO_RECORDING;
541
542 code_event_handler_(&event);
543 return event.user_data;
544 }
545
546 void Logger::IssueEndCodePosInfoEvent(Code* code, void* jit_handler_data) {
547 JitCodeEvent event;
548 memset(&event, 0, sizeof(event));
549 event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING;
550 event.code_start = code->instruction_start();
551 event.user_data = jit_handler_data;
552
553 code_event_handler_(&event);
554 }
516 555
517 #define DECLARE_EVENT(ignore1, name) name, 556 #define DECLARE_EVENT(ignore1, name) name,
518 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { 557 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
519 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) 558 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT)
520 }; 559 };
521 #undef DECLARE_EVENT 560 #undef DECLARE_EVENT
522 561
523 562
524 void Logger::ProfilerBeginEvent() { 563 void Logger::ProfilerBeginEvent() {
525 if (!log_->IsEnabled()) return; 564 if (!log_->IsEnabled()) return;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 Code* code, 916 Code* code,
878 const char* comment) { 917 const char* comment) {
879 if (!is_logging_code_events()) return; 918 if (!is_logging_code_events()) return;
880 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 919 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
881 name_buffer_->Reset(); 920 name_buffer_->Reset();
882 name_buffer_->AppendBytes(kLogEventsNames[tag]); 921 name_buffer_->AppendBytes(kLogEventsNames[tag]);
883 name_buffer_->AppendByte(':'); 922 name_buffer_->AppendByte(':');
884 name_buffer_->AppendBytes(comment); 923 name_buffer_->AppendBytes(comment);
885 } 924 }
886 if (code_event_handler_ != NULL) { 925 if (code_event_handler_ != NULL) {
887 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 926 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size());
888 } 927 }
889 if (!log_->IsEnabled()) return; 928 if (!log_->IsEnabled()) return;
890 if (FLAG_ll_prof) { 929 if (FLAG_ll_prof) {
891 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 930 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
892 } 931 }
893 if (Serializer::enabled()) { 932 if (Serializer::enabled()) {
894 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 933 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
895 } 934 }
896 if (!FLAG_log_code) return; 935 if (!FLAG_log_code) return;
897 LogMessageBuilder msg(this); 936 LogMessageBuilder msg(this);
(...skipping 19 matching lines...) Expand all
917 Code* code, 956 Code* code,
918 String* name) { 957 String* name) {
919 if (!is_logging_code_events()) return; 958 if (!is_logging_code_events()) return;
920 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 959 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
921 name_buffer_->Reset(); 960 name_buffer_->Reset();
922 name_buffer_->AppendBytes(kLogEventsNames[tag]); 961 name_buffer_->AppendBytes(kLogEventsNames[tag]);
923 name_buffer_->AppendByte(':'); 962 name_buffer_->AppendByte(':');
924 name_buffer_->AppendString(name); 963 name_buffer_->AppendString(name);
925 } 964 }
926 if (code_event_handler_ != NULL) { 965 if (code_event_handler_ != NULL) {
927 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 966 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size());
928 } 967 }
929 if (!log_->IsEnabled()) return; 968 if (!log_->IsEnabled()) return;
930 if (FLAG_ll_prof) { 969 if (FLAG_ll_prof) {
931 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 970 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
932 } 971 }
933 if (Serializer::enabled()) { 972 if (Serializer::enabled()) {
934 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 973 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
935 } 974 }
936 if (!FLAG_log_code) return; 975 if (!FLAG_log_code) return;
937 LogMessageBuilder msg(this); 976 LogMessageBuilder msg(this);
(...skipping 26 matching lines...) Expand all
964 String* name) { 1003 String* name) {
965 if (!is_logging_code_events()) return; 1004 if (!is_logging_code_events()) return;
966 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1005 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
967 name_buffer_->Reset(); 1006 name_buffer_->Reset();
968 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1007 name_buffer_->AppendBytes(kLogEventsNames[tag]);
969 name_buffer_->AppendByte(':'); 1008 name_buffer_->AppendByte(':');
970 name_buffer_->AppendBytes(ComputeMarker(code)); 1009 name_buffer_->AppendBytes(ComputeMarker(code));
971 name_buffer_->AppendString(name); 1010 name_buffer_->AppendString(name);
972 } 1011 }
973 if (code_event_handler_ != NULL) { 1012 if (code_event_handler_ != NULL) {
974 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 1013 Script* script =
1014 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL;
1015 IssueCodeAddedEvent(code,
1016 script,
1017 name_buffer_->get(),
1018 name_buffer_->size());
975 } 1019 }
976 if (!log_->IsEnabled()) return; 1020 if (!log_->IsEnabled()) return;
977 if (FLAG_ll_prof) { 1021 if (FLAG_ll_prof) {
978 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 1022 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
979 } 1023 }
980 if (Serializer::enabled()) { 1024 if (Serializer::enabled()) {
981 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1025 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
982 } 1026 }
983 if (!FLAG_log_code) return; 1027 if (!FLAG_log_code) return;
984 if (code == Isolate::Current()->builtins()->builtin( 1028 if (code == Isolate::Current()->builtins()->builtin(
(...skipping 29 matching lines...) Expand all
1014 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1058 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1015 name_buffer_->AppendByte(':'); 1059 name_buffer_->AppendByte(':');
1016 name_buffer_->AppendBytes(ComputeMarker(code)); 1060 name_buffer_->AppendBytes(ComputeMarker(code));
1017 name_buffer_->AppendString(shared->DebugName()); 1061 name_buffer_->AppendString(shared->DebugName());
1018 name_buffer_->AppendByte(' '); 1062 name_buffer_->AppendByte(' ');
1019 name_buffer_->AppendString(source); 1063 name_buffer_->AppendString(source);
1020 name_buffer_->AppendByte(':'); 1064 name_buffer_->AppendByte(':');
1021 name_buffer_->AppendInt(line); 1065 name_buffer_->AppendInt(line);
1022 } 1066 }
1023 if (code_event_handler_ != NULL) { 1067 if (code_event_handler_ != NULL) {
1024 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 1068 Script* script =
1069 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL;
1070 IssueCodeAddedEvent(code,
1071 script,
1072 name_buffer_->get(),
1073 name_buffer_->size());
1025 } 1074 }
1026 if (!log_->IsEnabled()) return; 1075 if (!log_->IsEnabled()) return;
1027 if (FLAG_ll_prof) { 1076 if (FLAG_ll_prof) {
1028 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 1077 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1029 } 1078 }
1030 if (Serializer::enabled()) { 1079 if (Serializer::enabled()) {
1031 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1080 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1032 } 1081 }
1033 if (!FLAG_log_code) return; 1082 if (!FLAG_log_code) return;
1034 LogMessageBuilder msg(this); 1083 LogMessageBuilder msg(this);
(...skipping 20 matching lines...) Expand all
1055 1104
1056 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { 1105 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
1057 if (!is_logging_code_events()) return; 1106 if (!is_logging_code_events()) return;
1058 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1107 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1059 name_buffer_->Reset(); 1108 name_buffer_->Reset();
1060 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1109 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1061 name_buffer_->AppendByte(':'); 1110 name_buffer_->AppendByte(':');
1062 name_buffer_->AppendInt(args_count); 1111 name_buffer_->AppendInt(args_count);
1063 } 1112 }
1064 if (code_event_handler_ != NULL) { 1113 if (code_event_handler_ != NULL) {
1065 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 1114 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size());
1066 } 1115 }
1067 if (!log_->IsEnabled()) return; 1116 if (!log_->IsEnabled()) return;
1068 if (FLAG_ll_prof) { 1117 if (FLAG_ll_prof) {
1069 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 1118 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1070 } 1119 }
1071 if (Serializer::enabled()) { 1120 if (Serializer::enabled()) {
1072 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1121 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1073 } 1122 }
1074 if (!FLAG_log_code) return; 1123 if (!FLAG_log_code) return;
1075 LogMessageBuilder msg(this); 1124 LogMessageBuilder msg(this);
(...skipping 17 matching lines...) Expand all
1093 1142
1094 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { 1143 void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
1095 if (!is_logging_code_events()) return; 1144 if (!is_logging_code_events()) return;
1096 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1145 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1097 name_buffer_->Reset(); 1146 name_buffer_->Reset();
1098 name_buffer_->AppendBytes(kLogEventsNames[REG_EXP_TAG]); 1147 name_buffer_->AppendBytes(kLogEventsNames[REG_EXP_TAG]);
1099 name_buffer_->AppendByte(':'); 1148 name_buffer_->AppendByte(':');
1100 name_buffer_->AppendString(source); 1149 name_buffer_->AppendString(source);
1101 } 1150 }
1102 if (code_event_handler_ != NULL) { 1151 if (code_event_handler_ != NULL) {
1103 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); 1152 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size());
1104 } 1153 }
1105 if (!log_->IsEnabled()) return; 1154 if (!log_->IsEnabled()) return;
1106 if (FLAG_ll_prof) { 1155 if (FLAG_ll_prof) {
1107 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 1156 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
1108 } 1157 }
1109 if (Serializer::enabled()) { 1158 if (Serializer::enabled()) {
1110 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1159 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
1111 } 1160 }
1112 if (!FLAG_log_code) return; 1161 if (!FLAG_log_code) return;
1113 LogMessageBuilder msg(this); 1162 LogMessageBuilder msg(this);
(...skipping 23 matching lines...) Expand all
1137 void Logger::CodeDeleteEvent(Address from) { 1186 void Logger::CodeDeleteEvent(Address from) {
1138 if (code_event_handler_ != NULL) IssueCodeRemovedEvent(from); 1187 if (code_event_handler_ != NULL) IssueCodeRemovedEvent(from);
1139 if (!log_->IsEnabled()) return; 1188 if (!log_->IsEnabled()) return;
1140 if (FLAG_ll_prof) LowLevelCodeDeleteEvent(from); 1189 if (FLAG_ll_prof) LowLevelCodeDeleteEvent(from);
1141 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1190 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1142 address_to_name_map_->Remove(from); 1191 address_to_name_map_->Remove(from);
1143 } 1192 }
1144 DeleteEventInternal(CODE_DELETE_EVENT, from); 1193 DeleteEventInternal(CODE_DELETE_EVENT, from);
1145 } 1194 }
1146 1195
1196 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
1197 int pc_offset,
1198 int position) {
1199 if (code_event_handler_ != NULL) {
1200 IssueAddCodeLinePosInfoEvent(jit_handler_data,
1201 pc_offset,
1202 position,
1203 JitCodeEvent::POSITION);
1204 }
1205 }
1206
1207 void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
1208 int pc_offset,
1209 int position) {
1210 if (code_event_handler_ != NULL) {
1211 IssueAddCodeLinePosInfoEvent(jit_handler_data,
1212 pc_offset,
1213 position,
1214 JitCodeEvent::STATEMENT_POSITION);
1215 }
1216 }
1217
1218 void Logger::CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder) {
1219 if (code_event_handler_ != NULL) {
1220 pos_recorder->AttachJITHandlerData(IssueStartCodePosInfoEvent());
1221 }
1222 }
1223
1224 void Logger::CodeEndLinePosInfoRecordEvent(Code* code,
1225 void* jit_handler_data) {
1226 if (code_event_handler_ != NULL) {
1227 IssueEndCodePosInfoEvent(code, jit_handler_data);
1228 }
1229 }
1147 1230
1148 void Logger::SnapshotPositionEvent(Address addr, int pos) { 1231 void Logger::SnapshotPositionEvent(Address addr, int pos) {
1149 if (!log_->IsEnabled()) return; 1232 if (!log_->IsEnabled()) return;
1150 if (FLAG_ll_prof) LowLevelSnapshotPositionEvent(addr, pos); 1233 if (FLAG_ll_prof) LowLevelSnapshotPositionEvent(addr, pos);
1151 if (Serializer::enabled() && address_to_name_map_ != NULL) { 1234 if (Serializer::enabled() && address_to_name_map_ != NULL) {
1152 const char* code_name = address_to_name_map_->Lookup(addr); 1235 const char* code_name = address_to_name_map_->Lookup(addr);
1153 if (code_name == NULL) return; // Not a code object. 1236 if (code_name == NULL) return; // Not a code object.
1154 LogMessageBuilder msg(this); 1237 LogMessageBuilder msg(this);
1155 msg.Append("%s,%d,\"", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); 1238 msg.Append("%s,%d,\"", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos);
1156 for (const char* p = code_name; *p != '\0'; ++p) { 1239 for (const char* p = code_name; *p != '\0'; ++p) {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { 1903 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) {
1821 ASSERT(sampler->IsActive()); 1904 ASSERT(sampler->IsActive());
1822 ScopedLock lock(active_samplers_mutex); 1905 ScopedLock lock(active_samplers_mutex);
1823 ASSERT(active_samplers_ != NULL); 1906 ASSERT(active_samplers_ != NULL);
1824 bool removed = active_samplers_->RemoveElement(sampler); 1907 bool removed = active_samplers_->RemoveElement(sampler);
1825 ASSERT(removed); 1908 ASSERT(removed);
1826 USE(removed); 1909 USE(removed);
1827 } 1910 }
1828 1911
1829 } } // namespace v8::internal 1912 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698