OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 msg.WriteToLogFile(); | 882 msg.WriteToLogFile(); |
883 #endif | 883 #endif |
884 } | 884 } |
885 | 885 |
886 | 886 |
887 void Logger::HeapSampleJSConstructorEvent(const char* constructor, | 887 void Logger::HeapSampleJSConstructorEvent(const char* constructor, |
888 int number, int bytes) { | 888 int number, int bytes) { |
889 #ifdef ENABLE_LOGGING_AND_PROFILING | 889 #ifdef ENABLE_LOGGING_AND_PROFILING |
890 if (!Log::IsEnabled() || !FLAG_log_gc) return; | 890 if (!Log::IsEnabled() || !FLAG_log_gc) return; |
891 LogMessageBuilder msg; | 891 LogMessageBuilder msg; |
892 msg.Append("heap-js-cons-item,%s,%d,%d\n", | 892 msg.Append("heap-js-cons-item,%s,%d,%d\n", constructor, number, bytes); |
893 constructor[0] != '\0' ? constructor : "(anonymous)", | |
894 number, bytes); | |
895 msg.WriteToLogFile(); | 893 msg.WriteToLogFile(); |
896 #endif | 894 #endif |
897 } | 895 } |
898 | 896 |
899 | 897 |
900 void Logger::HeapSampleJSRetainersEvent(const char* event) { | 898 void Logger::HeapSampleJSRetainersEvent( |
| 899 const char* constructor, const char* event) { |
901 #ifdef ENABLE_LOGGING_AND_PROFILING | 900 #ifdef ENABLE_LOGGING_AND_PROFILING |
902 if (!Log::IsEnabled() || !FLAG_log_gc) return; | 901 if (!Log::IsEnabled() || !FLAG_log_gc) return; |
903 LogMessageBuilder msg; | 902 // Event starts with comma, so we don't have it in the format string. |
904 msg.Append("heap-js-ret-item,%s\n", event); | 903 static const char* event_text = "heap-js-ret-item,%s"; |
905 msg.WriteToLogFile(); | 904 // We take placeholder strings into account, but it's OK to be conservative. |
| 905 static const int event_text_len = strlen(event_text); |
| 906 const int cons_len = strlen(constructor), event_len = strlen(event); |
| 907 int pos = 0; |
| 908 // Retainer lists can be long. We may need to split them into multiple events. |
| 909 do { |
| 910 LogMessageBuilder msg; |
| 911 msg.Append(event_text, constructor); |
| 912 int to_write = event_len - pos; |
| 913 if (to_write > Log::kMessageBufferSize - (cons_len + event_text_len)) { |
| 914 int cut_pos = pos + Log::kMessageBufferSize - (cons_len + event_text_len); |
| 915 ASSERT(cut_pos < event_len); |
| 916 while (cut_pos > pos && event[cut_pos] != ',') --cut_pos; |
| 917 if (event[cut_pos] != ',') { |
| 918 // Crash in debug mode, skip in release mode. |
| 919 ASSERT(false); |
| 920 return; |
| 921 } |
| 922 // Append a piece of event that fits, without trailing comma. |
| 923 msg.AppendStringPart(event + pos, cut_pos - pos); |
| 924 // Start next piece with comma. |
| 925 pos = cut_pos; |
| 926 } else { |
| 927 msg.Append("%s", event + pos); |
| 928 pos += event_len; |
| 929 } |
| 930 msg.Append('\n'); |
| 931 msg.WriteToLogFile(); |
| 932 } while (pos < event_len); |
906 #endif | 933 #endif |
907 } | 934 } |
908 | 935 |
909 | 936 |
910 void Logger::DebugTag(const char* call_site_tag) { | 937 void Logger::DebugTag(const char* call_site_tag) { |
911 #ifdef ENABLE_LOGGING_AND_PROFILING | 938 #ifdef ENABLE_LOGGING_AND_PROFILING |
912 if (!Log::IsEnabled() || !FLAG_log) return; | 939 if (!Log::IsEnabled() || !FLAG_log) return; |
913 LogMessageBuilder msg; | 940 LogMessageBuilder msg; |
914 msg.Append("debug-tag,%s\n", call_site_tag); | 941 msg.Append("debug-tag,%s\n", call_site_tag); |
915 msg.WriteToLogFile(); | 942 msg.WriteToLogFile(); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 // Otherwise, if the sliding state window computation has not been | 1285 // Otherwise, if the sliding state window computation has not been |
1259 // started we do it now. | 1286 // started we do it now. |
1260 if (sliding_state_window_ == NULL) { | 1287 if (sliding_state_window_ == NULL) { |
1261 sliding_state_window_ = new SlidingStateWindow(); | 1288 sliding_state_window_ = new SlidingStateWindow(); |
1262 } | 1289 } |
1263 #endif | 1290 #endif |
1264 } | 1291 } |
1265 | 1292 |
1266 | 1293 |
1267 } } // namespace v8::internal | 1294 } } // namespace v8::internal |
OLD | NEW |