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