OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 #define PROFILER_LOG(Call) \ | 43 #define PROFILER_LOG(Call) \ |
44 do { \ | 44 do { \ |
45 CpuProfiler* cpu_profiler = isolate_->cpu_profiler(); \ | 45 CpuProfiler* cpu_profiler = isolate_->cpu_profiler(); \ |
46 if (cpu_profiler->is_profiling()) { \ | 46 if (cpu_profiler->is_profiling()) { \ |
47 cpu_profiler->Call; \ | 47 cpu_profiler->Call; \ |
48 } \ | 48 } \ |
49 } while (false); | 49 } while (false); |
50 | 50 |
51 // ComputeMarker must only be used when SharedFunctionInfo is known. | 51 static const char* ComputeMarker(SharedFunctionInfo* shared, Code* code) { |
52 static const char* ComputeMarker(Code* code) { | |
53 switch (code->kind()) { | 52 switch (code->kind()) { |
54 case Code::FUNCTION: return code->optimizable() ? "~" : ""; | 53 case Code::FUNCTION: |
55 case Code::OPTIMIZED_FUNCTION: return "*"; | 54 return shared->optimization_disabled() ? "" : "~"; |
56 default: return ""; | 55 case Code::OPTIMIZED_FUNCTION: |
| 56 return "*"; |
| 57 default: |
| 58 return ""; |
57 } | 59 } |
58 } | 60 } |
59 | 61 |
60 | 62 |
61 class CodeEventLogger::NameBuffer { | 63 class CodeEventLogger::NameBuffer { |
62 public: | 64 public: |
63 NameBuffer() { Reset(); } | 65 NameBuffer() { Reset(); } |
64 | 66 |
65 void Reset() { | 67 void Reset() { |
66 utf8_pos_ = 0; | 68 utf8_pos_ = 0; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); | 178 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); |
177 } | 179 } |
178 | 180 |
179 | 181 |
180 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 182 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
181 Code* code, | 183 Code* code, |
182 SharedFunctionInfo* shared, | 184 SharedFunctionInfo* shared, |
183 CompilationInfo* info, | 185 CompilationInfo* info, |
184 Name* name) { | 186 Name* name) { |
185 name_buffer_->Init(tag); | 187 name_buffer_->Init(tag); |
186 name_buffer_->AppendBytes(ComputeMarker(code)); | 188 name_buffer_->AppendBytes(ComputeMarker(shared, code)); |
187 name_buffer_->AppendName(name); | 189 name_buffer_->AppendName(name); |
188 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); | 190 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); |
189 } | 191 } |
190 | 192 |
191 | 193 |
192 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 194 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
193 Code* code, | 195 Code* code, |
194 SharedFunctionInfo* shared, | 196 SharedFunctionInfo* shared, |
195 CompilationInfo* info, | 197 CompilationInfo* info, |
196 Name* source, int line, int column) { | 198 Name* source, int line, int column) { |
197 name_buffer_->Init(tag); | 199 name_buffer_->Init(tag); |
198 name_buffer_->AppendBytes(ComputeMarker(code)); | 200 name_buffer_->AppendBytes(ComputeMarker(shared, code)); |
199 name_buffer_->AppendString(shared->DebugName()); | 201 name_buffer_->AppendString(shared->DebugName()); |
200 name_buffer_->AppendByte(' '); | 202 name_buffer_->AppendByte(' '); |
201 if (source->IsString()) { | 203 if (source->IsString()) { |
202 name_buffer_->AppendString(String::cast(source)); | 204 name_buffer_->AppendString(String::cast(source)); |
203 } else { | 205 } else { |
204 name_buffer_->AppendBytes("symbol(hash "); | 206 name_buffer_->AppendBytes("symbol(hash "); |
205 name_buffer_->AppendHex(Name::cast(source)->Hash()); | 207 name_buffer_->AppendHex(Name::cast(source)->Hash()); |
206 name_buffer_->AppendByte(')'); | 208 name_buffer_->AppendByte(')'); |
207 } | 209 } |
208 name_buffer_->AppendByte(':'); | 210 name_buffer_->AppendByte(':'); |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 AppendCodeCreateHeader(&msg, tag, code); | 1194 AppendCodeCreateHeader(&msg, tag, code); |
1193 if (name->IsString()) { | 1195 if (name->IsString()) { |
1194 SmartArrayPointer<char> str = | 1196 SmartArrayPointer<char> str = |
1195 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1197 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1196 msg.Append("\"%s\"", str.get()); | 1198 msg.Append("\"%s\"", str.get()); |
1197 } else { | 1199 } else { |
1198 msg.AppendSymbolName(Symbol::cast(name)); | 1200 msg.AppendSymbolName(Symbol::cast(name)); |
1199 } | 1201 } |
1200 msg.Append(','); | 1202 msg.Append(','); |
1201 msg.AppendAddress(shared->address()); | 1203 msg.AppendAddress(shared->address()); |
1202 msg.Append(",%s", ComputeMarker(code)); | 1204 msg.Append(",%s", ComputeMarker(shared, code)); |
1203 msg.WriteToLogFile(); | 1205 msg.WriteToLogFile(); |
1204 } | 1206 } |
1205 | 1207 |
1206 | 1208 |
1207 // Although, it is possible to extract source and line from | 1209 // Although, it is possible to extract source and line from |
1208 // the SharedFunctionInfo object, we left it to caller | 1210 // the SharedFunctionInfo object, we left it to caller |
1209 // to leave logging functions free from heap allocations. | 1211 // to leave logging functions free from heap allocations. |
1210 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1212 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
1211 Code* code, | 1213 Code* code, |
1212 SharedFunctionInfo* shared, | 1214 SharedFunctionInfo* shared, |
(...skipping 13 matching lines...) Expand all Loading... |
1226 msg.Append("\"%s ", name.get()); | 1228 msg.Append("\"%s ", name.get()); |
1227 if (source->IsString()) { | 1229 if (source->IsString()) { |
1228 SmartArrayPointer<char> sourcestr = | 1230 SmartArrayPointer<char> sourcestr = |
1229 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1231 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1230 msg.Append("%s", sourcestr.get()); | 1232 msg.Append("%s", sourcestr.get()); |
1231 } else { | 1233 } else { |
1232 msg.AppendSymbolName(Symbol::cast(source)); | 1234 msg.AppendSymbolName(Symbol::cast(source)); |
1233 } | 1235 } |
1234 msg.Append(":%d:%d\",", line, column); | 1236 msg.Append(":%d:%d\",", line, column); |
1235 msg.AppendAddress(shared->address()); | 1237 msg.AppendAddress(shared->address()); |
1236 msg.Append(",%s", ComputeMarker(code)); | 1238 msg.Append(",%s", ComputeMarker(shared, code)); |
1237 msg.WriteToLogFile(); | 1239 msg.WriteToLogFile(); |
1238 } | 1240 } |
1239 | 1241 |
1240 | 1242 |
1241 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1243 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
1242 Code* code, | 1244 Code* code, |
1243 int args_count) { | 1245 int args_count) { |
1244 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); | 1246 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); |
1245 | 1247 |
1246 if (!is_logging_code_events()) return; | 1248 if (!is_logging_code_events()) return; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 if (jit_logger_) { | 1907 if (jit_logger_) { |
1906 removeCodeEventListener(jit_logger_); | 1908 removeCodeEventListener(jit_logger_); |
1907 delete jit_logger_; | 1909 delete jit_logger_; |
1908 jit_logger_ = NULL; | 1910 jit_logger_ = NULL; |
1909 } | 1911 } |
1910 | 1912 |
1911 return log_->Close(); | 1913 return log_->Close(); |
1912 } | 1914 } |
1913 | 1915 |
1914 } } // namespace v8::internal | 1916 } } // namespace v8::internal |
OLD | NEW |