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

Side by Side Diff: src/log.cc

Issue 12459026: ES6 symbols: implement name property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 9 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/heap-inl.h ('k') | src/objects.h » ('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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 } 637 }
638 638
639 639
640 void Logger::ApiNamedSecurityCheck(Object* key) { 640 void Logger::ApiNamedSecurityCheck(Object* key) {
641 if (!log_->IsEnabled() || !FLAG_log_api) return; 641 if (!log_->IsEnabled() || !FLAG_log_api) return;
642 if (key->IsString()) { 642 if (key->IsString()) {
643 SmartArrayPointer<char> str = 643 SmartArrayPointer<char> str =
644 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 644 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
645 ApiEvent("api,check-security,\"%s\"\n", *str); 645 ApiEvent("api,check-security,\"%s\"\n", *str);
646 } else if (key->IsSymbol()) { 646 } else if (key->IsSymbol()) {
647 ApiEvent("api,check-security,symbol(hash %x)\n", Symbol::cast(key)->Hash()); 647 Symbol* symbol = Symbol::cast(key);
648 if (symbol->name()->IsUndefined()) {
649 ApiEvent("api,check-security,symbol(hash %x)\n",
650 Symbol::cast(key)->Hash());
651 } else {
652 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
653 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
654 ApiEvent("api,check-security,symbol(\"%s\" hash %x)\n",
655 *str,
656 Symbol::cast(key)->Hash());
657 }
648 } else if (key->IsUndefined()) { 658 } else if (key->IsUndefined()) {
649 ApiEvent("api,check-security,undefined\n"); 659 ApiEvent("api,check-security,undefined\n");
650 } else { 660 } else {
651 ApiEvent("api,check-security,['no-name']\n"); 661 ApiEvent("api,check-security,['no-name']\n");
652 } 662 }
653 } 663 }
654 664
655 665
656 void Logger::SharedLibraryEvent(const char* library_path, 666 void Logger::SharedLibraryEvent(const char* library_path,
657 uintptr_t start, 667 uintptr_t start,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 ASSERT(name->IsName()); 836 ASSERT(name->IsName());
827 if (!log_->IsEnabled() || !FLAG_log_api) return; 837 if (!log_->IsEnabled() || !FLAG_log_api) return;
828 String* class_name_obj = holder->class_name(); 838 String* class_name_obj = holder->class_name();
829 SmartArrayPointer<char> class_name = 839 SmartArrayPointer<char> class_name =
830 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 840 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
831 if (name->IsString()) { 841 if (name->IsString()) {
832 SmartArrayPointer<char> property_name = 842 SmartArrayPointer<char> property_name =
833 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 843 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
834 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); 844 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name);
835 } else { 845 } else {
836 uint32_t hash = Symbol::cast(name)->Hash(); 846 Symbol* symbol = Symbol::cast(name);
837 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, *class_name, hash); 847 uint32_t hash = symbol->Hash();
848 if (symbol->name()->IsUndefined()) {
849 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, *class_name, hash);
850 } else {
851 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
852 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
853 ApiEvent("api,%s,\"%s\",symbol(\"%s\" hash %x)\n",
854 tag, *class_name, *str, hash);
855 }
838 } 856 }
839 } 857 }
840 858
841 void Logger::ApiIndexedPropertyAccess(const char* tag, 859 void Logger::ApiIndexedPropertyAccess(const char* tag,
842 JSObject* holder, 860 JSObject* holder,
843 uint32_t index) { 861 uint32_t index) {
844 if (!log_->IsEnabled() || !FLAG_log_api) return; 862 if (!log_->IsEnabled() || !FLAG_log_api) return;
845 String* class_name_obj = holder->class_name(); 863 String* class_name_obj = holder->class_name();
846 SmartArrayPointer<char> class_name = 864 SmartArrayPointer<char> class_name =
847 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 865 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 LogMessageBuilder msg(this); 913 LogMessageBuilder msg(this);
896 msg.Append("%s,%s,-3,", 914 msg.Append("%s,%s,-3,",
897 kLogEventsNames[CODE_CREATION_EVENT], 915 kLogEventsNames[CODE_CREATION_EVENT],
898 kLogEventsNames[CALLBACK_TAG]); 916 kLogEventsNames[CALLBACK_TAG]);
899 msg.AppendAddress(entry_point); 917 msg.AppendAddress(entry_point);
900 if (name->IsString()) { 918 if (name->IsString()) {
901 SmartArrayPointer<char> str = 919 SmartArrayPointer<char> str =
902 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 920 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
903 msg.Append(",1,\"%s%s\"", prefix, *str); 921 msg.Append(",1,\"%s%s\"", prefix, *str);
904 } else { 922 } else {
905 msg.Append(",1,symbol(hash %x)", prefix, Name::cast(name)->Hash()); 923 Symbol* symbol = Symbol::cast(name);
924 if (symbol->name()->IsUndefined()) {
925 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash());
926 } else {
927 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
928 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
929 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, *str, symbol->Hash());
930 }
906 } 931 }
907 msg.Append('\n'); 932 msg.Append('\n');
908 msg.WriteToLogFile(); 933 msg.WriteToLogFile();
909 } 934 }
910 935
911 936
912 void Logger::CallbackEvent(Name* name, Address entry_point) { 937 void Logger::CallbackEvent(Name* name, Address entry_point) {
913 if (!log_->IsEnabled() || !FLAG_log_code) return; 938 if (!log_->IsEnabled() || !FLAG_log_code) return;
914 CallbackEventInternal("", name, entry_point); 939 CallbackEventInternal("", name, entry_point);
915 } 940 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 Code* code, 996 Code* code,
972 Name* name) { 997 Name* name) {
973 if (!is_logging_code_events()) return; 998 if (!is_logging_code_events()) return;
974 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 999 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
975 name_buffer_->Reset(); 1000 name_buffer_->Reset();
976 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1001 name_buffer_->AppendBytes(kLogEventsNames[tag]);
977 name_buffer_->AppendByte(':'); 1002 name_buffer_->AppendByte(':');
978 if (name->IsString()) { 1003 if (name->IsString()) {
979 name_buffer_->AppendString(String::cast(name)); 1004 name_buffer_->AppendString(String::cast(name));
980 } else { 1005 } else {
981 name_buffer_->AppendBytes("symbol(hash "); 1006 Symbol* symbol = Symbol::cast(name);
982 name_buffer_->AppendHex(Name::cast(name)->Hash()); 1007 name_buffer_->AppendBytes("symbol(");
1008 if (!symbol->name()->IsUndefined()) {
1009 name_buffer_->AppendBytes("\"");
1010 name_buffer_->AppendString(String::cast(symbol->name()));
1011 name_buffer_->AppendBytes("\" ");
1012 }
1013 name_buffer_->AppendBytes("hash ");
1014 name_buffer_->AppendHex(symbol->Hash());
983 name_buffer_->AppendByte(')'); 1015 name_buffer_->AppendByte(')');
984 } 1016 }
985 } 1017 }
986 if (code_event_handler_ != NULL) { 1018 if (code_event_handler_ != NULL) {
987 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size()); 1019 IssueCodeAddedEvent(code, NULL, name_buffer_->get(), name_buffer_->size());
988 } 1020 }
989 if (!log_->IsEnabled()) return; 1021 if (!log_->IsEnabled()) return;
990 if (FLAG_ll_prof) { 1022 if (FLAG_ll_prof) {
991 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size()); 1023 LowLevelCodeCreateEvent(code, name_buffer_->get(), name_buffer_->size());
992 } 1024 }
993 if (Serializer::enabled()) { 1025 if (Serializer::enabled()) {
994 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); 1026 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size());
995 } 1027 }
996 if (!FLAG_log_code) return; 1028 if (!FLAG_log_code) return;
997 LogMessageBuilder msg(this); 1029 LogMessageBuilder msg(this);
998 msg.Append("%s,%s,%d,", 1030 msg.Append("%s,%s,%d,",
999 kLogEventsNames[CODE_CREATION_EVENT], 1031 kLogEventsNames[CODE_CREATION_EVENT],
1000 kLogEventsNames[tag], 1032 kLogEventsNames[tag],
1001 code->kind()); 1033 code->kind());
1002 msg.AppendAddress(code->address()); 1034 msg.AppendAddress(code->address());
1003 msg.Append(",%d,", code->ExecutableSize()); 1035 msg.Append(",%d,", code->ExecutableSize());
1004 if (name->IsString()) { 1036 if (name->IsString()) {
1005 msg.Append('"'); 1037 msg.Append('"');
1006 msg.AppendDetailed(String::cast(name), false); 1038 msg.AppendDetailed(String::cast(name), false);
1007 msg.Append('"'); 1039 msg.Append('"');
1008 } else { 1040 } else {
1009 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); 1041 Symbol* symbol = Symbol::cast(name);
1042 msg.Append("symbol(");
1043 if (!symbol->name()->IsUndefined()) {
1044 msg.Append("\"");
1045 msg.AppendDetailed(String::cast(symbol->name()), false);
1046 msg.Append("\" ");
1047 }
1048 msg.Append("hash %x)", symbol->Hash());
1010 } 1049 }
1011 msg.Append('\n'); 1050 msg.Append('\n');
1012 msg.WriteToLogFile(); 1051 msg.WriteToLogFile();
1013 } 1052 }
1014 1053
1015 1054
1016 // ComputeMarker must only be used when SharedFunctionInfo is known. 1055 // ComputeMarker must only be used when SharedFunctionInfo is known.
1017 static const char* ComputeMarker(Code* code) { 1056 static const char* ComputeMarker(Code* code) {
1018 switch (code->kind()) { 1057 switch (code->kind()) {
1019 case Code::FUNCTION: return code->optimizable() ? "~" : ""; 1058 case Code::FUNCTION: return code->optimizable() ? "~" : "";
1020 case Code::OPTIMIZED_FUNCTION: return "*"; 1059 case Code::OPTIMIZED_FUNCTION: return "*";
1021 default: return ""; 1060 default: return "";
1022 } 1061 }
1023 } 1062 }
1024 1063
1025 1064
1026 void Logger::CodeCreateEvent(LogEventsAndTags tag, 1065 void Logger::CodeCreateEvent(LogEventsAndTags tag,
1027 Code* code, 1066 Code* code,
1028 SharedFunctionInfo* shared, 1067 SharedFunctionInfo* shared,
1029 Name* name) { 1068 Name* name) {
1030 if (!is_logging_code_events()) return; 1069 if (!is_logging_code_events()) return;
1031 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { 1070 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) {
1032 name_buffer_->Reset(); 1071 name_buffer_->Reset();
1033 name_buffer_->AppendBytes(kLogEventsNames[tag]); 1072 name_buffer_->AppendBytes(kLogEventsNames[tag]);
1034 name_buffer_->AppendByte(':'); 1073 name_buffer_->AppendByte(':');
1035 name_buffer_->AppendBytes(ComputeMarker(code)); 1074 name_buffer_->AppendBytes(ComputeMarker(code));
1036 if (name->IsString()) { 1075 if (name->IsString()) {
1037 name_buffer_->AppendString(String::cast(name)); 1076 name_buffer_->AppendString(String::cast(name));
1038 } else { 1077 } else {
1039 name_buffer_->AppendBytes("symbol(hash "); 1078 Symbol* symbol = Symbol::cast(name);
1040 name_buffer_->AppendHex(Name::cast(name)->Hash()); 1079 name_buffer_->AppendBytes("symbol(");
1080 if (!symbol->name()->IsUndefined()) {
1081 name_buffer_->AppendBytes("\"");
1082 name_buffer_->AppendString(String::cast(symbol->name()));
1083 name_buffer_->AppendBytes("\" ");
1084 }
1085 name_buffer_->AppendBytes("hash ");
1086 name_buffer_->AppendHex(symbol->Hash());
1041 name_buffer_->AppendByte(')'); 1087 name_buffer_->AppendByte(')');
1042 } 1088 }
1043 } 1089 }
1044 if (code_event_handler_ != NULL) { 1090 if (code_event_handler_ != NULL) {
1045 Script* script = 1091 Script* script =
1046 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL; 1092 shared->script()->IsScript() ? Script::cast(shared->script()) : NULL;
1047 IssueCodeAddedEvent(code, 1093 IssueCodeAddedEvent(code,
1048 script, 1094 script,
1049 name_buffer_->get(), 1095 name_buffer_->get(),
1050 name_buffer_->size()); 1096 name_buffer_->size());
(...skipping 15 matching lines...) Expand all
1066 kLogEventsNames[CODE_CREATION_EVENT], 1112 kLogEventsNames[CODE_CREATION_EVENT],
1067 kLogEventsNames[tag], 1113 kLogEventsNames[tag],
1068 code->kind()); 1114 code->kind());
1069 msg.AppendAddress(code->address()); 1115 msg.AppendAddress(code->address());
1070 msg.Append(",%d,", code->ExecutableSize()); 1116 msg.Append(",%d,", code->ExecutableSize());
1071 if (name->IsString()) { 1117 if (name->IsString()) {
1072 SmartArrayPointer<char> str = 1118 SmartArrayPointer<char> str =
1073 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1119 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1074 msg.Append("\"%s\"", *str); 1120 msg.Append("\"%s\"", *str);
1075 } else { 1121 } else {
1076 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); 1122 Symbol* symbol = Symbol::cast(name);
1123 msg.Append("symbol(");
1124 if (!symbol->name()->IsUndefined()) {
1125 msg.Append("\"");
1126 msg.AppendDetailed(String::cast(symbol->name()), false);
1127 msg.Append("\" ");
1128 }
1129 msg.Append("hash %x)", symbol->Hash());
1077 } 1130 }
1078 msg.Append(','); 1131 msg.Append(',');
1079 msg.AppendAddress(shared->address()); 1132 msg.AppendAddress(shared->address());
1080 msg.Append(",%s", ComputeMarker(code)); 1133 msg.Append(",%s", ComputeMarker(code));
1081 msg.Append('\n'); 1134 msg.Append('\n');
1082 msg.WriteToLogFile(); 1135 msg.WriteToLogFile();
1083 } 1136 }
1084 1137
1085 1138
1086 // Although, it is possible to extract source and line from 1139 // Although, it is possible to extract source and line from
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 kLogEventsNames[CODE_CREATION_EVENT], 1184 kLogEventsNames[CODE_CREATION_EVENT],
1132 kLogEventsNames[tag], 1185 kLogEventsNames[tag],
1133 code->kind()); 1186 code->kind());
1134 msg.AppendAddress(code->address()); 1187 msg.AppendAddress(code->address());
1135 msg.Append(",%d,\"%s ", code->ExecutableSize(), *name); 1188 msg.Append(",%d,\"%s ", code->ExecutableSize(), *name);
1136 if (source->IsString()) { 1189 if (source->IsString()) {
1137 SmartArrayPointer<char> sourcestr = 1190 SmartArrayPointer<char> sourcestr =
1138 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1191 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1139 msg.Append("%s", *sourcestr); 1192 msg.Append("%s", *sourcestr);
1140 } else { 1193 } else {
1141 msg.Append("symbol(hash %x)", Name::cast(source)->Hash()); 1194 Symbol* symbol = Symbol::cast(source);
1195 msg.Append("symbol(");
1196 if (!symbol->name()->IsUndefined()) {
1197 msg.Append("\"");
1198 msg.AppendDetailed(String::cast(symbol->name()), false);
1199 msg.Append("\" ");
1200 }
1201 msg.Append("hash %x)", symbol->Hash());
1142 } 1202 }
1143 msg.Append(":%d\",", line); 1203 msg.Append(":%d\",", line);
1144 msg.AppendAddress(shared->address()); 1204 msg.AppendAddress(shared->address());
1145 msg.Append(",%s", ComputeMarker(code)); 1205 msg.Append(",%s", ComputeMarker(code));
1146 msg.Append('\n'); 1206 msg.Append('\n');
1147 msg.WriteToLogFile(); 1207 msg.WriteToLogFile();
1148 } 1208 }
1149 1209
1150 1210
1151 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { 1211 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 ? JSObject::cast(obj)->class_name() 1411 ? JSObject::cast(obj)->class_name()
1352 : isolate_->heap()->empty_string(); 1412 : isolate_->heap()->empty_string();
1353 msg.Append("suspect-read,"); 1413 msg.Append("suspect-read,");
1354 msg.Append(class_name); 1414 msg.Append(class_name);
1355 msg.Append(','); 1415 msg.Append(',');
1356 if (name->IsString()) { 1416 if (name->IsString()) {
1357 msg.Append('"'); 1417 msg.Append('"');
1358 msg.Append(String::cast(name)); 1418 msg.Append(String::cast(name));
1359 msg.Append('"'); 1419 msg.Append('"');
1360 } else { 1420 } else {
1361 msg.Append("symbol(hash %x)", Name::cast(name)->Hash()); 1421 Symbol* symbol = Symbol::cast(name);
1422 msg.Append("symbol(");
1423 if (!symbol->name()->IsUndefined()) {
1424 msg.Append("\"");
1425 msg.AppendDetailed(String::cast(symbol->name()), false);
1426 msg.Append("\" ");
1427 }
1428 msg.Append("hash %x)", symbol->Hash());
1362 } 1429 }
1363 msg.Append('\n'); 1430 msg.Append('\n');
1364 msg.WriteToLogFile(); 1431 msg.WriteToLogFile();
1365 } 1432 }
1366 1433
1367 1434
1368 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { 1435 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) {
1369 if (!log_->IsEnabled() || !FLAG_log_gc) return; 1436 if (!log_->IsEnabled() || !FLAG_log_gc) return;
1370 LogMessageBuilder msg(this); 1437 LogMessageBuilder msg(this);
1371 // Using non-relative system time in order to be able to synchronize with 1438 // Using non-relative system time in order to be able to synchronize with
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { 2020 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) {
1954 ASSERT(sampler->IsActive()); 2021 ASSERT(sampler->IsActive());
1955 ScopedLock lock(active_samplers_mutex); 2022 ScopedLock lock(active_samplers_mutex);
1956 ASSERT(active_samplers_ != NULL); 2023 ASSERT(active_samplers_ != NULL);
1957 bool removed = active_samplers_->RemoveElement(sampler); 2024 bool removed = active_samplers_->RemoveElement(sampler);
1958 ASSERT(removed); 2025 ASSERT(removed);
1959 USE(removed); 2026 USE(removed);
1960 } 2027 }
1961 2028
1962 } } // namespace v8::internal 2029 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698