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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 420 } |
421 | 421 |
422 void AppendInt(int n) { | 422 void AppendInt(int n) { |
423 Vector<char> buffer(utf8_buffer_ + utf8_pos_, kUtf8BufferSize - utf8_pos_); | 423 Vector<char> buffer(utf8_buffer_ + utf8_pos_, kUtf8BufferSize - utf8_pos_); |
424 int size = OS::SNPrintF(buffer, "%d", n); | 424 int size = OS::SNPrintF(buffer, "%d", n); |
425 if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { | 425 if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { |
426 utf8_pos_ += size; | 426 utf8_pos_ += size; |
427 } | 427 } |
428 } | 428 } |
429 | 429 |
| 430 void AppendHex(uint32_t n) { |
| 431 Vector<char> buffer(utf8_buffer_ + utf8_pos_, kUtf8BufferSize - utf8_pos_); |
| 432 int size = OS::SNPrintF(buffer, "%x", n); |
| 433 if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { |
| 434 utf8_pos_ += size; |
| 435 } |
| 436 } |
| 437 |
430 const char* get() { return utf8_buffer_; } | 438 const char* get() { return utf8_buffer_; } |
431 int size() const { return utf8_pos_; } | 439 int size() const { return utf8_pos_; } |
432 | 440 |
433 private: | 441 private: |
434 static const int kUtf8BufferSize = 512; | 442 static const int kUtf8BufferSize = 512; |
435 static const int kUtf16BufferSize = 128; | 443 static const int kUtf16BufferSize = 128; |
436 | 444 |
437 int utf8_pos_; | 445 int utf8_pos_; |
438 char utf8_buffer_[kUtf8BufferSize]; | 446 char utf8_buffer_[kUtf8BufferSize]; |
439 uc16 utf16_buffer[kUtf16BufferSize]; | 447 uc16 utf16_buffer[kUtf16BufferSize]; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 msg.WriteToLogFile(); | 596 msg.WriteToLogFile(); |
589 } | 597 } |
590 | 598 |
591 | 599 |
592 void Logger::ApiNamedSecurityCheck(Object* key) { | 600 void Logger::ApiNamedSecurityCheck(Object* key) { |
593 if (!log_->IsEnabled() || !FLAG_log_api) return; | 601 if (!log_->IsEnabled() || !FLAG_log_api) return; |
594 if (key->IsString()) { | 602 if (key->IsString()) { |
595 SmartArrayPointer<char> str = | 603 SmartArrayPointer<char> str = |
596 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 604 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
597 ApiEvent("api,check-security,\"%s\"\n", *str); | 605 ApiEvent("api,check-security,\"%s\"\n", *str); |
| 606 } else if (key->IsSymbol()) { |
| 607 ApiEvent("api,check-security,symbol(hash %x)\n", Symbol::cast(key)->Hash()); |
598 } else if (key->IsUndefined()) { | 608 } else if (key->IsUndefined()) { |
599 ApiEvent("api,check-security,undefined\n"); | 609 ApiEvent("api,check-security,undefined\n"); |
600 } else { | 610 } else { |
601 ApiEvent("api,check-security,['no-name']\n"); | 611 ApiEvent("api,check-security,['no-name']\n"); |
602 } | 612 } |
603 } | 613 } |
604 | 614 |
605 | 615 |
606 void Logger::SharedLibraryEvent(const char* library_path, | 616 void Logger::SharedLibraryEvent(const char* library_path, |
607 uintptr_t start, | 617 uintptr_t start, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 774 |
765 void Logger::ApiIndexedSecurityCheck(uint32_t index) { | 775 void Logger::ApiIndexedSecurityCheck(uint32_t index) { |
766 if (!log_->IsEnabled() || !FLAG_log_api) return; | 776 if (!log_->IsEnabled() || !FLAG_log_api) return; |
767 ApiEvent("api,check-security,%u\n", index); | 777 ApiEvent("api,check-security,%u\n", index); |
768 } | 778 } |
769 | 779 |
770 | 780 |
771 void Logger::ApiNamedPropertyAccess(const char* tag, | 781 void Logger::ApiNamedPropertyAccess(const char* tag, |
772 JSObject* holder, | 782 JSObject* holder, |
773 Object* name) { | 783 Object* name) { |
774 ASSERT(name->IsString()); | 784 ASSERT(name->IsName()); |
775 if (!log_->IsEnabled() || !FLAG_log_api) return; | 785 if (!log_->IsEnabled() || !FLAG_log_api) return; |
776 String* class_name_obj = holder->class_name(); | 786 String* class_name_obj = holder->class_name(); |
777 SmartArrayPointer<char> class_name = | 787 SmartArrayPointer<char> class_name = |
778 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 788 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
779 SmartArrayPointer<char> property_name = | 789 if (name->IsString()) { |
780 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 790 SmartArrayPointer<char> property_name = |
781 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); | 791 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 792 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); |
| 793 } else { |
| 794 uint32_t hash = Symbol::cast(name)->Hash(); |
| 795 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, *class_name, hash); |
| 796 } |
782 } | 797 } |
783 | 798 |
784 void Logger::ApiIndexedPropertyAccess(const char* tag, | 799 void Logger::ApiIndexedPropertyAccess(const char* tag, |
785 JSObject* holder, | 800 JSObject* holder, |
786 uint32_t index) { | 801 uint32_t index) { |
787 if (!log_->IsEnabled() || !FLAG_log_api) return; | 802 if (!log_->IsEnabled() || !FLAG_log_api) return; |
788 String* class_name_obj = holder->class_name(); | 803 String* class_name_obj = holder->class_name(); |
789 SmartArrayPointer<char> class_name = | 804 SmartArrayPointer<char> class_name = |
790 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 805 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
791 ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index); | 806 ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 840 |
826 void Logger::NewEventStatic(const char* name, void* object, size_t size) { | 841 void Logger::NewEventStatic(const char* name, void* object, size_t size) { |
827 LOGGER->NewEvent(name, object, size); | 842 LOGGER->NewEvent(name, object, size); |
828 } | 843 } |
829 | 844 |
830 | 845 |
831 void Logger::DeleteEventStatic(const char* name, void* object) { | 846 void Logger::DeleteEventStatic(const char* name, void* object) { |
832 LOGGER->DeleteEvent(name, object); | 847 LOGGER->DeleteEvent(name, object); |
833 } | 848 } |
834 | 849 |
835 void Logger::CallbackEventInternal(const char* prefix, const char* name, | 850 void Logger::CallbackEventInternal(const char* prefix, Name* name, |
836 Address entry_point) { | 851 Address entry_point) { |
837 if (!log_->IsEnabled() || !FLAG_log_code) return; | 852 if (!log_->IsEnabled() || !FLAG_log_code) return; |
838 LogMessageBuilder msg(this); | 853 LogMessageBuilder msg(this); |
839 msg.Append("%s,%s,-3,", | 854 msg.Append("%s,%s,-3,", |
840 kLogEventsNames[CODE_CREATION_EVENT], | 855 kLogEventsNames[CODE_CREATION_EVENT], |
841 kLogEventsNames[CALLBACK_TAG]); | 856 kLogEventsNames[CALLBACK_TAG]); |
842 msg.AppendAddress(entry_point); | 857 msg.AppendAddress(entry_point); |
843 msg.Append(",1,\"%s%s\"", prefix, name); | 858 if (name->IsString()) { |
| 859 SmartArrayPointer<char> str = |
| 860 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 861 msg.Append(",1,\"%s%s\"", prefix, *str); |
| 862 } else { |
| 863 msg.Append(",1,symbol(hash %x)", prefix, Name::cast(name)->Hash()); |
| 864 } |
844 msg.Append('\n'); | 865 msg.Append('\n'); |
845 msg.WriteToLogFile(); | 866 msg.WriteToLogFile(); |
846 } | 867 } |
847 | 868 |
848 | 869 |
849 void Logger::CallbackEvent(String* name, Address entry_point) { | 870 void Logger::CallbackEvent(Name* name, Address entry_point) { |
850 if (!log_->IsEnabled() || !FLAG_log_code) return; | 871 if (!log_->IsEnabled() || !FLAG_log_code) return; |
851 SmartArrayPointer<char> str = | 872 CallbackEventInternal("", name, entry_point); |
852 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
853 CallbackEventInternal("", *str, entry_point); | |
854 } | 873 } |
855 | 874 |
856 | 875 |
857 void Logger::GetterCallbackEvent(String* name, Address entry_point) { | 876 void Logger::GetterCallbackEvent(Name* name, Address entry_point) { |
858 if (!log_->IsEnabled() || !FLAG_log_code) return; | 877 if (!log_->IsEnabled() || !FLAG_log_code) return; |
859 SmartArrayPointer<char> str = | 878 CallbackEventInternal("get ", name, entry_point); |
860 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
861 CallbackEventInternal("get ", *str, entry_point); | |
862 } | 879 } |
863 | 880 |
864 | 881 |
865 void Logger::SetterCallbackEvent(String* name, Address entry_point) { | 882 void Logger::SetterCallbackEvent(Name* name, Address entry_point) { |
866 if (!log_->IsEnabled() || !FLAG_log_code) return; | 883 if (!log_->IsEnabled() || !FLAG_log_code) return; |
867 SmartArrayPointer<char> str = | 884 CallbackEventInternal("set ", name, entry_point); |
868 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
869 CallbackEventInternal("set ", *str, entry_point); | |
870 } | 885 } |
871 | 886 |
872 | 887 |
873 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 888 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
874 Code* code, | 889 Code* code, |
875 const char* comment) { | 890 const char* comment) { |
876 if (!is_logging_code_events()) return; | 891 if (!is_logging_code_events()) return; |
877 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 892 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
878 name_buffer_->Reset(); | 893 name_buffer_->Reset(); |
879 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 894 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
(...skipping 25 matching lines...) Expand all Loading... |
905 msg.Append(*p); | 920 msg.Append(*p); |
906 } | 921 } |
907 msg.Append('"'); | 922 msg.Append('"'); |
908 msg.Append('\n'); | 923 msg.Append('\n'); |
909 msg.WriteToLogFile(); | 924 msg.WriteToLogFile(); |
910 } | 925 } |
911 | 926 |
912 | 927 |
913 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 928 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
914 Code* code, | 929 Code* code, |
915 String* name) { | 930 Name* name) { |
916 if (!is_logging_code_events()) return; | 931 if (!is_logging_code_events()) return; |
917 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 932 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
918 name_buffer_->Reset(); | 933 name_buffer_->Reset(); |
919 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 934 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
920 name_buffer_->AppendByte(':'); | 935 name_buffer_->AppendByte(':'); |
921 name_buffer_->AppendString(name); | 936 if (name->IsString()) { |
| 937 name_buffer_->AppendString(String::cast(name)); |
| 938 } else { |
| 939 name_buffer_->AppendBytes("symbol(hash "); |
| 940 name_buffer_->AppendHex(Name::cast(name)->Hash()); |
| 941 name_buffer_->AppendByte(')'); |
| 942 } |
922 } | 943 } |
923 if (code_event_handler_ != NULL) { | 944 if (code_event_handler_ != NULL) { |
924 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); | 945 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
925 } | 946 } |
926 if (!log_->IsEnabled()) return; | 947 if (!log_->IsEnabled()) return; |
927 if (FLAG_ll_prof) { | 948 if (FLAG_ll_prof) { |
928 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 949 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
929 } | 950 } |
930 if (Serializer::enabled()) { | 951 if (Serializer::enabled()) { |
931 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 952 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
932 } | 953 } |
933 if (!FLAG_log_code) return; | 954 if (!FLAG_log_code) return; |
934 LogMessageBuilder msg(this); | 955 LogMessageBuilder msg(this); |
935 msg.Append("%s,%s,%d,", | 956 msg.Append("%s,%s,%d,", |
936 kLogEventsNames[CODE_CREATION_EVENT], | 957 kLogEventsNames[CODE_CREATION_EVENT], |
937 kLogEventsNames[tag], | 958 kLogEventsNames[tag], |
938 code->kind()); | 959 code->kind()); |
939 msg.AppendAddress(code->address()); | 960 msg.AppendAddress(code->address()); |
940 msg.Append(",%d,\"", code->ExecutableSize()); | 961 msg.Append(",%d,", code->ExecutableSize()); |
941 msg.AppendDetailed(name, false); | 962 if (name->IsString()) { |
942 msg.Append('"'); | 963 msg.Append('"'); |
| 964 msg.AppendDetailed(String::cast(name), false); |
| 965 msg.Append('"'); |
| 966 } else { |
| 967 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); |
| 968 } |
943 msg.Append('\n'); | 969 msg.Append('\n'); |
944 msg.WriteToLogFile(); | 970 msg.WriteToLogFile(); |
945 } | 971 } |
946 | 972 |
947 | 973 |
948 // ComputeMarker must only be used when SharedFunctionInfo is known. | 974 // ComputeMarker must only be used when SharedFunctionInfo is known. |
949 static const char* ComputeMarker(Code* code) { | 975 static const char* ComputeMarker(Code* code) { |
950 switch (code->kind()) { | 976 switch (code->kind()) { |
951 case Code::FUNCTION: return code->optimizable() ? "~" : ""; | 977 case Code::FUNCTION: return code->optimizable() ? "~" : ""; |
952 case Code::OPTIMIZED_FUNCTION: return "*"; | 978 case Code::OPTIMIZED_FUNCTION: return "*"; |
953 default: return ""; | 979 default: return ""; |
954 } | 980 } |
955 } | 981 } |
956 | 982 |
957 | 983 |
958 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 984 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
959 Code* code, | 985 Code* code, |
960 SharedFunctionInfo* shared, | 986 SharedFunctionInfo* shared, |
961 String* name) { | 987 Name* name) { |
962 if (!is_logging_code_events()) return; | 988 if (!is_logging_code_events()) return; |
963 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 989 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
964 name_buffer_->Reset(); | 990 name_buffer_->Reset(); |
965 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 991 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
966 name_buffer_->AppendByte(':'); | 992 name_buffer_->AppendByte(':'); |
967 name_buffer_->AppendBytes(ComputeMarker(code)); | 993 name_buffer_->AppendBytes(ComputeMarker(code)); |
968 name_buffer_->AppendString(name); | 994 if (name->IsString()) { |
| 995 name_buffer_->AppendString(String::cast(name)); |
| 996 } else { |
| 997 name_buffer_->AppendBytes("symbol(hash "); |
| 998 name_buffer_->AppendHex(Name::cast(name)->Hash()); |
| 999 name_buffer_->AppendByte(')'); |
| 1000 } |
969 } | 1001 } |
970 if (code_event_handler_ != NULL) { | 1002 if (code_event_handler_ != NULL) { |
971 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); | 1003 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
972 } | 1004 } |
973 if (!log_->IsEnabled()) return; | 1005 if (!log_->IsEnabled()) return; |
974 if (FLAG_ll_prof) { | 1006 if (FLAG_ll_prof) { |
975 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1007 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
976 } | 1008 } |
977 if (Serializer::enabled()) { | 1009 if (Serializer::enabled()) { |
978 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1010 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
979 } | 1011 } |
980 if (!FLAG_log_code) return; | 1012 if (!FLAG_log_code) return; |
981 if (code == Isolate::Current()->builtins()->builtin( | 1013 if (code == Isolate::Current()->builtins()->builtin( |
982 Builtins::kLazyCompile)) | 1014 Builtins::kLazyCompile)) |
983 return; | 1015 return; |
984 | 1016 |
985 LogMessageBuilder msg(this); | 1017 LogMessageBuilder msg(this); |
986 SmartArrayPointer<char> str = | |
987 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
988 msg.Append("%s,%s,%d,", | 1018 msg.Append("%s,%s,%d,", |
989 kLogEventsNames[CODE_CREATION_EVENT], | 1019 kLogEventsNames[CODE_CREATION_EVENT], |
990 kLogEventsNames[tag], | 1020 kLogEventsNames[tag], |
991 code->kind()); | 1021 code->kind()); |
992 msg.AppendAddress(code->address()); | 1022 msg.AppendAddress(code->address()); |
993 msg.Append(",%d,\"%s\",", code->ExecutableSize(), *str); | 1023 msg.Append(",%d,", code->ExecutableSize()); |
| 1024 if (name->IsString()) { |
| 1025 SmartArrayPointer<char> str = |
| 1026 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1027 msg.Append("\"%s\"", *str); |
| 1028 } else { |
| 1029 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); |
| 1030 } |
| 1031 msg.Append(','); |
994 msg.AppendAddress(shared->address()); | 1032 msg.AppendAddress(shared->address()); |
995 msg.Append(",%s", ComputeMarker(code)); | 1033 msg.Append(",%s", ComputeMarker(code)); |
996 msg.Append('\n'); | 1034 msg.Append('\n'); |
997 msg.WriteToLogFile(); | 1035 msg.WriteToLogFile(); |
998 } | 1036 } |
999 | 1037 |
1000 | 1038 |
1001 // Although, it is possible to extract source and line from | 1039 // Although, it is possible to extract source and line from |
1002 // the SharedFunctionInfo object, we left it to caller | 1040 // the SharedFunctionInfo object, we left it to caller |
1003 // to leave logging functions free from heap allocations. | 1041 // to leave logging functions free from heap allocations. |
1004 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1042 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
1005 Code* code, | 1043 Code* code, |
1006 SharedFunctionInfo* shared, | 1044 SharedFunctionInfo* shared, |
1007 String* source, int line) { | 1045 Name* source, int line) { |
1008 if (!is_logging_code_events()) return; | 1046 if (!is_logging_code_events()) return; |
1009 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 1047 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
1010 name_buffer_->Reset(); | 1048 name_buffer_->Reset(); |
1011 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1049 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
1012 name_buffer_->AppendByte(':'); | 1050 name_buffer_->AppendByte(':'); |
1013 name_buffer_->AppendBytes(ComputeMarker(code)); | 1051 name_buffer_->AppendBytes(ComputeMarker(code)); |
1014 name_buffer_->AppendString(shared->DebugName()); | 1052 name_buffer_->AppendString(shared->DebugName()); |
1015 name_buffer_->AppendByte(' '); | 1053 name_buffer_->AppendByte(' '); |
1016 name_buffer_->AppendString(source); | 1054 if (source->IsString()) { |
| 1055 name_buffer_->AppendString(String::cast(source)); |
| 1056 } else { |
| 1057 name_buffer_->AppendBytes("symbol(hash "); |
| 1058 name_buffer_->AppendHex(Name::cast(source)->Hash()); |
| 1059 name_buffer_->AppendByte(')'); |
| 1060 } |
1017 name_buffer_->AppendByte(':'); | 1061 name_buffer_->AppendByte(':'); |
1018 name_buffer_->AppendInt(line); | 1062 name_buffer_->AppendInt(line); |
1019 } | 1063 } |
1020 if (code_event_handler_ != NULL) { | 1064 if (code_event_handler_ != NULL) { |
1021 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); | 1065 IssueCodeAddedEvent(code, name_buffer_->get(), name_buffer_->size()); |
1022 } | 1066 } |
1023 if (!log_->IsEnabled()) return; | 1067 if (!log_->IsEnabled()) return; |
1024 if (FLAG_ll_prof) { | 1068 if (FLAG_ll_prof) { |
1025 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); | 1069 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); |
1026 } | 1070 } |
1027 if (Serializer::enabled()) { | 1071 if (Serializer::enabled()) { |
1028 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1072 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
1029 } | 1073 } |
1030 if (!FLAG_log_code) return; | 1074 if (!FLAG_log_code) return; |
1031 LogMessageBuilder msg(this); | 1075 LogMessageBuilder msg(this); |
1032 SmartArrayPointer<char> name = | 1076 SmartArrayPointer<char> name = |
1033 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1077 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1034 SmartArrayPointer<char> sourcestr = | |
1035 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
1036 msg.Append("%s,%s,%d,", | 1078 msg.Append("%s,%s,%d,", |
1037 kLogEventsNames[CODE_CREATION_EVENT], | 1079 kLogEventsNames[CODE_CREATION_EVENT], |
1038 kLogEventsNames[tag], | 1080 kLogEventsNames[tag], |
1039 code->kind()); | 1081 code->kind()); |
1040 msg.AppendAddress(code->address()); | 1082 msg.AppendAddress(code->address()); |
1041 msg.Append(",%d,\"%s %s:%d\",", | 1083 msg.Append(",%d,\"%s ", code->ExecutableSize(), *name); |
1042 code->ExecutableSize(), | 1084 if (source->IsString()) { |
1043 *name, | 1085 SmartArrayPointer<char> sourcestr = |
1044 *sourcestr, | 1086 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1045 line); | 1087 msg.Append("%s", *sourcestr); |
| 1088 } else { |
| 1089 msg.Append("symbol(hash %x)", Name::cast(source)->Hash()); |
| 1090 } |
| 1091 msg.Append(":%d\",", line); |
1046 msg.AppendAddress(shared->address()); | 1092 msg.AppendAddress(shared->address()); |
1047 msg.Append(",%s", ComputeMarker(code)); | 1093 msg.Append(",%s", ComputeMarker(code)); |
1048 msg.Append('\n'); | 1094 msg.Append('\n'); |
1049 msg.WriteToLogFile(); | 1095 msg.WriteToLogFile(); |
1050 } | 1096 } |
1051 | 1097 |
1052 | 1098 |
1053 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { | 1099 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { |
1054 if (!is_logging_code_events()) return; | 1100 if (!is_logging_code_events()) return; |
1055 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 1101 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 if (OS::GetUserTime(&sec, &usec) != -1) { | 1251 if (OS::GetUserTime(&sec, &usec) != -1) { |
1206 msg.Append("%d,%d,", sec, usec); | 1252 msg.Append("%d,%d,", sec, usec); |
1207 } | 1253 } |
1208 msg.Append("%.0f", OS::TimeCurrentMillis()); | 1254 msg.Append("%.0f", OS::TimeCurrentMillis()); |
1209 | 1255 |
1210 msg.Append('\n'); | 1256 msg.Append('\n'); |
1211 msg.WriteToLogFile(); | 1257 msg.WriteToLogFile(); |
1212 } | 1258 } |
1213 | 1259 |
1214 | 1260 |
1215 void Logger::SuspectReadEvent(String* name, Object* obj) { | 1261 void Logger::SuspectReadEvent(Name* name, Object* obj) { |
1216 if (!log_->IsEnabled() || !FLAG_log_suspect) return; | 1262 if (!log_->IsEnabled() || !FLAG_log_suspect) return; |
1217 LogMessageBuilder msg(this); | 1263 LogMessageBuilder msg(this); |
1218 String* class_name = obj->IsJSObject() | 1264 String* class_name = obj->IsJSObject() |
1219 ? JSObject::cast(obj)->class_name() | 1265 ? JSObject::cast(obj)->class_name() |
1220 : HEAP->empty_string(); | 1266 : HEAP->empty_string(); |
1221 msg.Append("suspect-read,"); | 1267 msg.Append("suspect-read,"); |
1222 msg.Append(class_name); | 1268 msg.Append(class_name); |
1223 msg.Append(','); | 1269 msg.Append(','); |
1224 msg.Append('"'); | 1270 if (name->IsString()) { |
1225 msg.Append(name); | 1271 msg.Append('"'); |
1226 msg.Append('"'); | 1272 msg.Append(String::cast(name)); |
| 1273 msg.Append('"'); |
| 1274 } else { |
| 1275 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); |
| 1276 } |
1227 msg.Append('\n'); | 1277 msg.Append('\n'); |
1228 msg.WriteToLogFile(); | 1278 msg.WriteToLogFile(); |
1229 } | 1279 } |
1230 | 1280 |
1231 | 1281 |
1232 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { | 1282 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { |
1233 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1283 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
1234 LogMessageBuilder msg(this); | 1284 LogMessageBuilder msg(this); |
1235 // Using non-relative system time in order to be able to synchronize with | 1285 // Using non-relative system time in order to be able to synchronize with |
1236 // external memory profiling events (e.g. DOM memory size). | 1286 // external memory profiling events (e.g. DOM memory size). |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1688 |
1639 | 1689 |
1640 void Logger::LogAccessorCallbacks() { | 1690 void Logger::LogAccessorCallbacks() { |
1641 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1691 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1642 "Logger::LogAccessorCallbacks"); | 1692 "Logger::LogAccessorCallbacks"); |
1643 HeapIterator iterator; | 1693 HeapIterator iterator; |
1644 AssertNoAllocation no_alloc; | 1694 AssertNoAllocation no_alloc; |
1645 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1695 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1646 if (!obj->IsAccessorInfo()) continue; | 1696 if (!obj->IsAccessorInfo()) continue; |
1647 AccessorInfo* ai = AccessorInfo::cast(obj); | 1697 AccessorInfo* ai = AccessorInfo::cast(obj); |
1648 if (!ai->name()->IsString()) continue; | 1698 if (!ai->name()->IsName()) continue; |
1649 String* name = String::cast(ai->name()); | 1699 Name* name = Name::cast(ai->name()); |
1650 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1700 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
1651 if (getter_entry != 0) { | 1701 if (getter_entry != 0) { |
1652 PROFILE(ISOLATE, GetterCallbackEvent(name, getter_entry)); | 1702 PROFILE(ISOLATE, GetterCallbackEvent(name, getter_entry)); |
1653 } | 1703 } |
1654 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1704 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
1655 if (setter_entry != 0) { | 1705 if (setter_entry != 0) { |
1656 PROFILE(ISOLATE, SetterCallbackEvent(name, setter_entry)); | 1706 PROFILE(ISOLATE, SetterCallbackEvent(name, setter_entry)); |
1657 } | 1707 } |
1658 } | 1708 } |
1659 } | 1709 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1863 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1814 ASSERT(sampler->IsActive()); | 1864 ASSERT(sampler->IsActive()); |
1815 ScopedLock lock(active_samplers_mutex); | 1865 ScopedLock lock(active_samplers_mutex); |
1816 ASSERT(active_samplers_ != NULL); | 1866 ASSERT(active_samplers_ != NULL); |
1817 bool removed = active_samplers_->RemoveElement(sampler); | 1867 bool removed = active_samplers_->RemoveElement(sampler); |
1818 ASSERT(removed); | 1868 ASSERT(removed); |
1819 USE(removed); | 1869 USE(removed); |
1820 } | 1870 } |
1821 | 1871 |
1822 } } // namespace v8::internal | 1872 } } // namespace v8::internal |
OLD | NEW |