OLD | NEW |
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 : ticker_(NULL), | 519 : ticker_(NULL), |
520 profiler_(NULL), | 520 profiler_(NULL), |
521 sliding_state_window_(NULL), | 521 sliding_state_window_(NULL), |
522 log_events_(NULL), | 522 log_events_(NULL), |
523 logging_nesting_(0), | 523 logging_nesting_(0), |
524 cpu_profiler_nesting_(0), | 524 cpu_profiler_nesting_(0), |
525 log_(new Log(this)), | 525 log_(new Log(this)), |
526 name_buffer_(new NameBuffer), | 526 name_buffer_(new NameBuffer), |
527 address_to_name_map_(NULL), | 527 address_to_name_map_(NULL), |
528 is_initialized_(false), | 528 is_initialized_(false), |
| 529 code_event_handler_(NULL), |
529 last_address_(NULL), | 530 last_address_(NULL), |
530 prev_sp_(NULL), | 531 prev_sp_(NULL), |
531 prev_function_(NULL), | 532 prev_function_(NULL), |
532 prev_to_(NULL), | 533 prev_to_(NULL), |
533 prev_code_(NULL) { | 534 prev_code_(NULL) { |
534 } | 535 } |
535 | 536 |
536 | 537 |
537 Logger::~Logger() { | 538 Logger::~Logger() { |
538 delete address_to_name_map_; | 539 delete address_to_name_map_; |
539 delete name_buffer_; | 540 delete name_buffer_; |
540 delete log_; | 541 delete log_; |
541 } | 542 } |
542 | 543 |
543 | 544 |
| 545 void Logger::IssueCodeAddedEvent(Code* code, |
| 546 const char* name, |
| 547 size_t name_len) { |
| 548 JitCodeEvent event; |
| 549 event.type = JitCodeEvent::CODE_ADDED; |
| 550 event.code_start = code->instruction_start(); |
| 551 event.code_len = code->instruction_size(); |
| 552 event.name.str = name; |
| 553 event.name.len = name_len; |
| 554 |
| 555 code_event_handler_(&event); |
| 556 } |
| 557 |
| 558 |
| 559 void Logger::IssueCodeMovedEvent(Address from, Address to) { |
| 560 Code* from_code = Code::cast(HeapObject::FromAddress(from)); |
| 561 |
| 562 JitCodeEvent event; |
| 563 event.type = JitCodeEvent::CODE_MOVED; |
| 564 event.code_start = from_code->instruction_start(); |
| 565 event.code_len = from_code->instruction_size(); |
| 566 |
| 567 // Calculate the header size. |
| 568 const size_t header_size = |
| 569 from_code->instruction_start() - reinterpret_cast<byte*>(from_code); |
| 570 |
| 571 // Calculate the new start address of the instructions. |
| 572 event.new_code_start = |
| 573 reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size; |
| 574 |
| 575 code_event_handler_(&event); |
| 576 } |
| 577 |
| 578 |
| 579 void Logger::IssueCodeRemovedEvent(Address from) { |
| 580 Code* from_code = Code::cast(HeapObject::FromAddress(from)); |
| 581 |
| 582 JitCodeEvent event; |
| 583 event.type = JitCodeEvent::CODE_REMOVED; |
| 584 event.code_start = from_code->instruction_start(); |
| 585 event.code_len = from_code->instruction_size(); |
| 586 |
| 587 code_event_handler_(&event); |
| 588 } |
| 589 |
| 590 |
544 #define DECLARE_EVENT(ignore1, name) name, | 591 #define DECLARE_EVENT(ignore1, name) name, |
545 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { | 592 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
546 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) | 593 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) |
547 }; | 594 }; |
548 #undef DECLARE_EVENT | 595 #undef DECLARE_EVENT |
549 | 596 |
550 | 597 |
551 void Logger::ProfilerBeginEvent() { | 598 void Logger::ProfilerBeginEvent() { |
552 if (!log_->IsEnabled()) return; | 599 if (!log_->IsEnabled()) return; |
553 LogMessageBuilder msg(this); | 600 LogMessageBuilder msg(this); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 if (!log_->IsEnabled() || !FLAG_log_code) return; | 904 if (!log_->IsEnabled() || !FLAG_log_code) return; |
858 SmartArrayPointer<char> str = | 905 SmartArrayPointer<char> str = |
859 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 906 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
860 CallbackEventInternal("set ", *str, entry_point); | 907 CallbackEventInternal("set ", *str, entry_point); |
861 } | 908 } |
862 | 909 |
863 | 910 |
864 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 911 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
865 Code* code, | 912 Code* code, |
866 const char* comment) { | 913 const char* comment) { |
867 if (!log_->IsEnabled()) return; | 914 if (!is_logging_code_events()) return; |
868 if (FLAG_ll_prof || Serializer::enabled()) { | 915 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
869 name_buffer_->Reset(); | 916 name_buffer_->Reset(); |
870 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 917 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
871 name_buffer_->AppendByte(':'); | 918 name_buffer_->AppendByte(':'); |
872 name_buffer_->AppendBytes(comment); | 919 name_buffer_->AppendBytes(comment); |
873 } | 920 } |
| 921 if (code_event_handler_ != NULL) { |
| 922 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 923 } |
| 924 if (!log_->IsEnabled()) return; |
874 if (FLAG_ll_prof) { | 925 if (FLAG_ll_prof) { |
875 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 926 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
876 } | 927 } |
877 if (Serializer::enabled()) { | 928 if (Serializer::enabled()) { |
878 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 929 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
879 } | 930 } |
880 if (!FLAG_log_code) return; | 931 if (!FLAG_log_code) return; |
881 LogMessageBuilder msg(this); | 932 LogMessageBuilder msg(this); |
882 msg.Append("%s,%s,", | 933 msg.Append("%s,%s,", |
883 kLogEventsNames[CODE_CREATION_EVENT], | 934 kLogEventsNames[CODE_CREATION_EVENT], |
884 kLogEventsNames[tag]); | 935 kLogEventsNames[tag]); |
885 msg.AppendAddress(code->address()); | 936 msg.AppendAddress(code->address()); |
886 msg.Append(",%d,\"", code->ExecutableSize()); | 937 msg.Append(",%d,\"", code->ExecutableSize()); |
887 for (const char* p = comment; *p != '\0'; p++) { | 938 for (const char* p = comment; *p != '\0'; p++) { |
888 if (*p == '"') { | 939 if (*p == '"') { |
889 msg.Append('\\'); | 940 msg.Append('\\'); |
890 } | 941 } |
891 msg.Append(*p); | 942 msg.Append(*p); |
892 } | 943 } |
893 msg.Append('"'); | 944 msg.Append('"'); |
894 msg.Append('\n'); | 945 msg.Append('\n'); |
895 msg.WriteToLogFile(); | 946 msg.WriteToLogFile(); |
896 } | 947 } |
897 | 948 |
898 | 949 |
899 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 950 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
900 Code* code, | 951 Code* code, |
901 String* name) { | 952 String* name) { |
902 if (!log_->IsEnabled()) return; | 953 if (!is_logging_code_events()) return; |
903 if (FLAG_ll_prof || Serializer::enabled()) { | 954 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
904 name_buffer_->Reset(); | 955 name_buffer_->Reset(); |
905 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 956 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
906 name_buffer_->AppendByte(':'); | 957 name_buffer_->AppendByte(':'); |
907 name_buffer_->AppendString(name); | 958 name_buffer_->AppendString(name); |
908 } | 959 } |
| 960 if (code_event_handler_ != NULL) { |
| 961 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 962 } |
| 963 if (!log_->IsEnabled()) return; |
909 if (FLAG_ll_prof) { | 964 if (FLAG_ll_prof) { |
910 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 965 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
911 } | 966 } |
912 if (Serializer::enabled()) { | 967 if (Serializer::enabled()) { |
913 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 968 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
914 } | 969 } |
915 if (!FLAG_log_code) return; | 970 if (!FLAG_log_code) return; |
916 LogMessageBuilder msg(this); | 971 LogMessageBuilder msg(this); |
917 msg.Append("%s,%s,", | 972 msg.Append("%s,%s,", |
918 kLogEventsNames[CODE_CREATION_EVENT], | 973 kLogEventsNames[CODE_CREATION_EVENT], |
(...skipping 14 matching lines...) Expand all Loading... |
933 case Code::OPTIMIZED_FUNCTION: return "*"; | 988 case Code::OPTIMIZED_FUNCTION: return "*"; |
934 default: return ""; | 989 default: return ""; |
935 } | 990 } |
936 } | 991 } |
937 | 992 |
938 | 993 |
939 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 994 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
940 Code* code, | 995 Code* code, |
941 SharedFunctionInfo* shared, | 996 SharedFunctionInfo* shared, |
942 String* name) { | 997 String* name) { |
943 if (!log_->IsEnabled()) return; | 998 if (!is_logging_code_events()) return; |
944 if (FLAG_ll_prof || Serializer::enabled()) { | 999 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
945 name_buffer_->Reset(); | 1000 name_buffer_->Reset(); |
946 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1001 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
947 name_buffer_->AppendByte(':'); | 1002 name_buffer_->AppendByte(':'); |
948 name_buffer_->AppendBytes(ComputeMarker(code)); | 1003 name_buffer_->AppendBytes(ComputeMarker(code)); |
949 name_buffer_->AppendString(name); | 1004 name_buffer_->AppendString(name); |
950 } | 1005 } |
| 1006 if (code_event_handler_ != NULL) { |
| 1007 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 1008 } |
| 1009 if (!log_->IsEnabled()) return; |
951 if (FLAG_ll_prof) { | 1010 if (FLAG_ll_prof) { |
952 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1011 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
953 } | 1012 } |
954 if (Serializer::enabled()) { | 1013 if (Serializer::enabled()) { |
955 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1014 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
956 } | 1015 } |
957 if (!FLAG_log_code) return; | 1016 if (!FLAG_log_code) return; |
958 if (code == Isolate::Current()->builtins()->builtin( | 1017 if (code == Isolate::Current()->builtins()->builtin( |
959 Builtins::kLazyCompile)) | 1018 Builtins::kLazyCompile)) |
960 return; | 1019 return; |
(...skipping 13 matching lines...) Expand all Loading... |
974 } | 1033 } |
975 | 1034 |
976 | 1035 |
977 // Although, it is possible to extract source and line from | 1036 // Although, it is possible to extract source and line from |
978 // the SharedFunctionInfo object, we left it to caller | 1037 // the SharedFunctionInfo object, we left it to caller |
979 // to leave logging functions free from heap allocations. | 1038 // to leave logging functions free from heap allocations. |
980 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1039 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
981 Code* code, | 1040 Code* code, |
982 SharedFunctionInfo* shared, | 1041 SharedFunctionInfo* shared, |
983 String* source, int line) { | 1042 String* source, int line) { |
984 if (!log_->IsEnabled()) return; | 1043 if (!is_logging_code_events()) return; |
985 if (FLAG_ll_prof || Serializer::enabled()) { | 1044 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
986 name_buffer_->Reset(); | 1045 name_buffer_->Reset(); |
987 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1046 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
988 name_buffer_->AppendByte(':'); | 1047 name_buffer_->AppendByte(':'); |
989 name_buffer_->AppendBytes(ComputeMarker(code)); | 1048 name_buffer_->AppendBytes(ComputeMarker(code)); |
990 name_buffer_->AppendString(shared->DebugName()); | 1049 name_buffer_->AppendString(shared->DebugName()); |
991 name_buffer_->AppendByte(' '); | 1050 name_buffer_->AppendByte(' '); |
992 name_buffer_->AppendString(source); | 1051 name_buffer_->AppendString(source); |
993 name_buffer_->AppendByte(':'); | 1052 name_buffer_->AppendByte(':'); |
994 name_buffer_->AppendInt(line); | 1053 name_buffer_->AppendInt(line); |
995 } | 1054 } |
| 1055 if (code_event_handler_ != NULL) { |
| 1056 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 1057 } |
| 1058 if (!log_->IsEnabled()) return; |
996 if (FLAG_ll_prof) { | 1059 if (FLAG_ll_prof) { |
997 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1060 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
998 } | 1061 } |
999 if (Serializer::enabled()) { | 1062 if (Serializer::enabled()) { |
1000 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1063 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
1001 } | 1064 } |
1002 if (!FLAG_log_code) return; | 1065 if (!FLAG_log_code) return; |
1003 LogMessageBuilder msg(this); | 1066 LogMessageBuilder msg(this); |
1004 SmartArrayPointer<char> name = | 1067 SmartArrayPointer<char> name = |
1005 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1068 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1006 SmartArrayPointer<char> sourcestr = | 1069 SmartArrayPointer<char> sourcestr = |
1007 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1070 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1008 msg.Append("%s,%s,", | 1071 msg.Append("%s,%s,", |
1009 kLogEventsNames[CODE_CREATION_EVENT], | 1072 kLogEventsNames[CODE_CREATION_EVENT], |
1010 kLogEventsNames[tag]); | 1073 kLogEventsNames[tag]); |
1011 msg.AppendAddress(code->address()); | 1074 msg.AppendAddress(code->address()); |
1012 msg.Append(",%d,\"%s %s:%d\",", | 1075 msg.Append(",%d,\"%s %s:%d\",", |
1013 code->ExecutableSize(), | 1076 code->ExecutableSize(), |
1014 *name, | 1077 *name, |
1015 *sourcestr, | 1078 *sourcestr, |
1016 line); | 1079 line); |
1017 msg.AppendAddress(shared->address()); | 1080 msg.AppendAddress(shared->address()); |
1018 msg.Append(",%s", ComputeMarker(code)); | 1081 msg.Append(",%s", ComputeMarker(code)); |
1019 msg.Append('\n'); | 1082 msg.Append('\n'); |
1020 msg.WriteToLogFile(); | 1083 msg.WriteToLogFile(); |
1021 } | 1084 } |
1022 | 1085 |
1023 | 1086 |
1024 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { | 1087 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { |
1025 if (!log_->IsEnabled()) return; | 1088 if (!is_logging_code_events()) return; |
1026 if (FLAG_ll_prof || Serializer::enabled()) { | 1089 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
1027 name_buffer_->Reset(); | 1090 name_buffer_->Reset(); |
1028 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1091 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
1029 name_buffer_->AppendByte(':'); | 1092 name_buffer_->AppendByte(':'); |
1030 name_buffer_->AppendInt(args_count); | 1093 name_buffer_->AppendInt(args_count); |
1031 } | 1094 } |
| 1095 if (code_event_handler_ != NULL) { |
| 1096 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 1097 } |
| 1098 if (!log_->IsEnabled()) return; |
1032 if (FLAG_ll_prof) { | 1099 if (FLAG_ll_prof) { |
1033 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1100 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
1034 } | 1101 } |
1035 if (Serializer::enabled()) { | 1102 if (Serializer::enabled()) { |
1036 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1103 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
1037 } | 1104 } |
1038 if (!FLAG_log_code) return; | 1105 if (!FLAG_log_code) return; |
1039 LogMessageBuilder msg(this); | 1106 LogMessageBuilder msg(this); |
1040 msg.Append("%s,%s,", | 1107 msg.Append("%s,%s,", |
1041 kLogEventsNames[CODE_CREATION_EVENT], | 1108 kLogEventsNames[CODE_CREATION_EVENT], |
1042 kLogEventsNames[tag]); | 1109 kLogEventsNames[tag]); |
1043 msg.AppendAddress(code->address()); | 1110 msg.AppendAddress(code->address()); |
1044 msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count); | 1111 msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count); |
1045 msg.Append('\n'); | 1112 msg.Append('\n'); |
1046 msg.WriteToLogFile(); | 1113 msg.WriteToLogFile(); |
1047 } | 1114 } |
1048 | 1115 |
1049 | 1116 |
1050 void Logger::CodeMovingGCEvent() { | 1117 void Logger::CodeMovingGCEvent() { |
1051 if (!log_->IsEnabled() || !FLAG_ll_prof) return; | 1118 if (!log_->IsEnabled() || !FLAG_ll_prof) return; |
1052 LowLevelLogWriteBytes(&kCodeMovingGCTag, sizeof(kCodeMovingGCTag)); | 1119 LowLevelLogWriteBytes(&kCodeMovingGCTag, sizeof(kCodeMovingGCTag)); |
1053 OS::SignalCodeMovingGC(); | 1120 OS::SignalCodeMovingGC(); |
1054 } | 1121 } |
1055 | 1122 |
1056 | 1123 |
1057 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1124 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
1058 if (!log_->IsEnabled()) return; | 1125 if (!is_logging_code_events()) return; |
1059 if (FLAG_ll_prof || Serializer::enabled()) { | 1126 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
1060 name_buffer_->Reset(); | 1127 name_buffer_->Reset(); |
1061 name_buffer_->AppendBytes(kLogEventsNames[REG_EXP_TAG]); | 1128 name_buffer_->AppendBytes(kLogEventsNames[REG_EXP_TAG]); |
1062 name_buffer_->AppendByte(':'); | 1129 name_buffer_->AppendByte(':'); |
1063 name_buffer_->AppendString(source); | 1130 name_buffer_->AppendString(source); |
1064 } | 1131 } |
| 1132 if (code_event_handler_ != NULL) { |
| 1133 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
| 1134 } |
| 1135 if (!log_->IsEnabled()) return; |
1065 if (FLAG_ll_prof) { | 1136 if (FLAG_ll_prof) { |
1066 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1137 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
1067 } | 1138 } |
1068 if (Serializer::enabled()) { | 1139 if (Serializer::enabled()) { |
1069 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1140 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
1070 } | 1141 } |
1071 if (!FLAG_log_code) return; | 1142 if (!FLAG_log_code) return; |
1072 LogMessageBuilder msg(this); | 1143 LogMessageBuilder msg(this); |
1073 msg.Append("%s,%s,", | 1144 msg.Append("%s,%s,", |
1074 kLogEventsNames[CODE_CREATION_EVENT], | 1145 kLogEventsNames[CODE_CREATION_EVENT], |
1075 kLogEventsNames[REG_EXP_TAG]); | 1146 kLogEventsNames[REG_EXP_TAG]); |
1076 msg.AppendAddress(code->address()); | 1147 msg.AppendAddress(code->address()); |
1077 msg.Append(",%d,\"", code->ExecutableSize()); | 1148 msg.Append(",%d,\"", code->ExecutableSize()); |
1078 msg.AppendDetailed(source, false); | 1149 msg.AppendDetailed(source, false); |
1079 msg.Append('\"'); | 1150 msg.Append('\"'); |
1080 msg.Append('\n'); | 1151 msg.Append('\n'); |
1081 msg.WriteToLogFile(); | 1152 msg.WriteToLogFile(); |
1082 } | 1153 } |
1083 | 1154 |
1084 | 1155 |
1085 void Logger::CodeMoveEvent(Address from, Address to) { | 1156 void Logger::CodeMoveEvent(Address from, Address to) { |
| 1157 if (code_event_handler_ != NULL) IssueCodeMovedEvent(from, to); |
1086 if (!log_->IsEnabled()) return; | 1158 if (!log_->IsEnabled()) return; |
1087 if (FLAG_ll_prof) LowLevelCodeMoveEvent(from, to); | 1159 if (FLAG_ll_prof) LowLevelCodeMoveEvent(from, to); |
1088 if (Serializer::enabled() && address_to_name_map_ != NULL) { | 1160 if (Serializer::enabled() && address_to_name_map_ != NULL) { |
1089 address_to_name_map_->Move(from, to); | 1161 address_to_name_map_->Move(from, to); |
1090 } | 1162 } |
1091 MoveEventInternal(CODE_MOVE_EVENT, from, to); | 1163 MoveEventInternal(CODE_MOVE_EVENT, from, to); |
1092 } | 1164 } |
1093 | 1165 |
1094 | 1166 |
1095 void Logger::CodeDeleteEvent(Address from) { | 1167 void Logger::CodeDeleteEvent(Address from) { |
| 1168 if (code_event_handler_ != NULL) IssueCodeRemovedEvent(from); |
1096 if (!log_->IsEnabled()) return; | 1169 if (!log_->IsEnabled()) return; |
1097 if (FLAG_ll_prof) LowLevelCodeDeleteEvent(from); | 1170 if (FLAG_ll_prof) LowLevelCodeDeleteEvent(from); |
1098 if (Serializer::enabled() && address_to_name_map_ != NULL) { | 1171 if (Serializer::enabled() && address_to_name_map_ != NULL) { |
1099 address_to_name_map_->Remove(from); | 1172 address_to_name_map_->Remove(from); |
1100 } | 1173 } |
1101 DeleteEventInternal(CODE_DELETE_EVENT, from); | 1174 DeleteEventInternal(CODE_DELETE_EVENT, from); |
1102 } | 1175 } |
1103 | 1176 |
1104 | 1177 |
1105 void Logger::SnapshotPositionEvent(Address addr, int pos) { | 1178 void Logger::SnapshotPositionEvent(Address addr, int pos) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 EnumerateOptimizedFunctionsVisitor visitor(sfis, | 1458 EnumerateOptimizedFunctionsVisitor visitor(sfis, |
1386 code_objects, | 1459 code_objects, |
1387 &compiled_funcs_count); | 1460 &compiled_funcs_count); |
1388 Deoptimizer::VisitAllOptimizedFunctions(&visitor); | 1461 Deoptimizer::VisitAllOptimizedFunctions(&visitor); |
1389 | 1462 |
1390 return compiled_funcs_count; | 1463 return compiled_funcs_count; |
1391 } | 1464 } |
1392 | 1465 |
1393 | 1466 |
1394 void Logger::LogCodeObject(Object* object) { | 1467 void Logger::LogCodeObject(Object* object) { |
1395 if (FLAG_log_code || FLAG_ll_prof) { | 1468 if (FLAG_log_code || FLAG_ll_prof || is_logging_code_events()) { |
1396 Code* code_object = Code::cast(object); | 1469 Code* code_object = Code::cast(object); |
1397 LogEventsAndTags tag = Logger::STUB_TAG; | 1470 LogEventsAndTags tag = Logger::STUB_TAG; |
1398 const char* description = "Unknown code from the snapshot"; | 1471 const char* description = "Unknown code from the snapshot"; |
1399 switch (code_object->kind()) { | 1472 switch (code_object->kind()) { |
1400 case Code::FUNCTION: | 1473 case Code::FUNCTION: |
1401 case Code::OPTIMIZED_FUNCTION: | 1474 case Code::OPTIMIZED_FUNCTION: |
1402 return; // We log this later using LogCompiledFunctions. | 1475 return; // We log this later using LogCompiledFunctions. |
1403 case Code::UNARY_OP_IC: // fall through | 1476 case Code::UNARY_OP_IC: // fall through |
1404 case Code::BINARY_OP_IC: // fall through | 1477 case Code::BINARY_OP_IC: // fall through |
1405 case Code::COMPARE_IC: // fall through | 1478 case Code::COMPARE_IC: // fall through |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 } | 1742 } |
1670 if (!FLAG_prof_lazy) { | 1743 if (!FLAG_prof_lazy) { |
1671 profiler_->Engage(); | 1744 profiler_->Engage(); |
1672 } | 1745 } |
1673 } | 1746 } |
1674 | 1747 |
1675 return true; | 1748 return true; |
1676 } | 1749 } |
1677 | 1750 |
1678 | 1751 |
| 1752 void Logger::SetCodeEventHandler(uint32_t options, |
| 1753 JitCodeEventHandler event_handler) { |
| 1754 code_event_handler_ = event_handler; |
| 1755 |
| 1756 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { |
| 1757 HandleScope scope; |
| 1758 LogCodeObjects(); |
| 1759 LogCompiledFunctions(); |
| 1760 } |
| 1761 } |
| 1762 |
| 1763 |
1679 Sampler* Logger::sampler() { | 1764 Sampler* Logger::sampler() { |
1680 return ticker_; | 1765 return ticker_; |
1681 } | 1766 } |
1682 | 1767 |
1683 | 1768 |
1684 void Logger::EnsureTickerStarted() { | 1769 void Logger::EnsureTickerStarted() { |
1685 ASSERT(ticker_ != NULL); | 1770 ASSERT(ticker_ != NULL); |
1686 if (!ticker_->IsActive()) ticker_->Start(); | 1771 if (!ticker_->IsActive()) ticker_->Start(); |
1687 } | 1772 } |
1688 | 1773 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1783 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1868 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1784 ASSERT(sampler->IsActive()); | 1869 ASSERT(sampler->IsActive()); |
1785 ScopedLock lock(active_samplers_mutex); | 1870 ScopedLock lock(active_samplers_mutex); |
1786 ASSERT(active_samplers_ != NULL); | 1871 ASSERT(active_samplers_ != NULL); |
1787 bool removed = active_samplers_->RemoveElement(sampler); | 1872 bool removed = active_samplers_->RemoveElement(sampler); |
1788 ASSERT(removed); | 1873 ASSERT(removed); |
1789 USE(removed); | 1874 USE(removed); |
1790 } | 1875 } |
1791 | 1876 |
1792 } } // namespace v8::internal | 1877 } } // namespace v8::internal |
OLD | NEW |