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/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 AbstractCode* code, | 182 AbstractCode* code, |
183 SharedFunctionInfo* shared, Name* name) { | 183 SharedFunctionInfo* shared, Name* name) { |
184 name_buffer_->Init(tag); | 184 name_buffer_->Init(tag); |
185 name_buffer_->AppendBytes(ComputeMarker(shared, code)); | 185 name_buffer_->AppendBytes(ComputeMarker(shared, code)); |
186 name_buffer_->AppendName(name); | 186 name_buffer_->AppendName(name); |
187 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); | 187 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); |
188 } | 188 } |
189 | 189 |
190 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 190 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
191 AbstractCode* code, | 191 AbstractCode* code, |
192 SharedFunctionInfo* shared, | 192 SharedFunctionInfo* shared, Name* source, |
193 CompilationInfo* info, Name* source, | |
194 int line, int column) { | 193 int line, int column) { |
195 name_buffer_->Init(tag); | 194 name_buffer_->Init(tag); |
196 name_buffer_->AppendBytes(ComputeMarker(shared, code)); | 195 name_buffer_->AppendBytes(ComputeMarker(shared, code)); |
197 name_buffer_->AppendString(shared->DebugName()); | 196 name_buffer_->AppendString(shared->DebugName()); |
198 name_buffer_->AppendByte(' '); | 197 name_buffer_->AppendByte(' '); |
199 if (source->IsString()) { | 198 if (source->IsString()) { |
200 name_buffer_->AppendString(String::cast(source)); | 199 name_buffer_->AppendString(String::cast(source)); |
201 } else { | 200 } else { |
202 name_buffer_->AppendBytes("symbol(hash "); | 201 name_buffer_->AppendBytes("symbol(hash "); |
203 name_buffer_->AppendHex(Name::cast(source)->Hash()); | 202 name_buffer_->AppendHex(Name::cast(source)->Hash()); |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 msg.AppendAddress(shared->address()); | 1142 msg.AppendAddress(shared->address()); |
1144 msg.Append(",%s", ComputeMarker(shared, code)); | 1143 msg.Append(",%s", ComputeMarker(shared, code)); |
1145 msg.WriteToLogFile(); | 1144 msg.WriteToLogFile(); |
1146 } | 1145 } |
1147 | 1146 |
1148 | 1147 |
1149 // Although, it is possible to extract source and line from | 1148 // Although, it is possible to extract source and line from |
1150 // the SharedFunctionInfo object, we left it to caller | 1149 // the SharedFunctionInfo object, we left it to caller |
1151 // to leave logging functions free from heap allocations. | 1150 // to leave logging functions free from heap allocations. |
1152 void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, | 1151 void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
1153 SharedFunctionInfo* shared, CompilationInfo* info, | 1152 SharedFunctionInfo* shared, Name* source, int line, |
1154 Name* source, int line, int column) { | 1153 int column) { |
1155 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column)); | 1154 PROFILER_LOG(CodeCreateEvent(tag, code, shared, source, line, column)); |
1156 | 1155 |
1157 if (!is_logging_code_events()) return; | 1156 if (!is_logging_code_events()) return; |
1158 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, | 1157 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, source, line, column)); |
1159 column)); | |
1160 | 1158 |
1161 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1159 if (!FLAG_log_code || !log_->IsEnabled()) return; |
1162 Log::MessageBuilder msg(log_); | 1160 Log::MessageBuilder msg(log_); |
1163 AppendCodeCreateHeader(&msg, tag, code); | 1161 AppendCodeCreateHeader(&msg, tag, code); |
1164 base::SmartArrayPointer<char> name = | 1162 base::SmartArrayPointer<char> name = |
1165 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1163 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1166 msg.Append("\"%s ", name.get()); | 1164 msg.Append("\"%s ", name.get()); |
1167 if (source->IsString()) { | 1165 if (source->IsString()) { |
1168 base::SmartArrayPointer<char> sourcestr = String::cast(source)->ToCString( | 1166 base::SmartArrayPointer<char> sourcestr = String::cast(source)->ToCString( |
1169 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1167 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 Handle<Script> script(Script::cast(shared->script())); | 1604 Handle<Script> script(Script::cast(shared->script())); |
1607 int line_num = Script::GetLineNumber(script, shared->start_position()) + 1; | 1605 int line_num = Script::GetLineNumber(script, shared->start_position()) + 1; |
1608 int column_num = | 1606 int column_num = |
1609 Script::GetColumnNumber(script, shared->start_position()) + 1; | 1607 Script::GetColumnNumber(script, shared->start_position()) + 1; |
1610 if (script->name()->IsString()) { | 1608 if (script->name()->IsString()) { |
1611 Handle<String> script_name(String::cast(script->name())); | 1609 Handle<String> script_name(String::cast(script->name())); |
1612 if (line_num > 0) { | 1610 if (line_num > 0) { |
1613 PROFILE(isolate_, | 1611 PROFILE(isolate_, |
1614 CodeCreateEvent( | 1612 CodeCreateEvent( |
1615 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1613 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
1616 *code, *shared, NULL, | 1614 *code, *shared, *script_name, line_num, column_num)); |
1617 *script_name, line_num, column_num)); | |
1618 } else { | 1615 } else { |
1619 // Can't distinguish eval and script here, so always use Script. | 1616 // Can't distinguish eval and script here, so always use Script. |
1620 PROFILE(isolate_, CodeCreateEvent(Logger::ToNativeByScript( | 1617 PROFILE(isolate_, CodeCreateEvent(Logger::ToNativeByScript( |
1621 Logger::SCRIPT_TAG, *script), | 1618 Logger::SCRIPT_TAG, *script), |
1622 *code, *shared, *script_name)); | 1619 *code, *shared, *script_name)); |
1623 } | 1620 } |
1624 } else { | 1621 } else { |
1625 PROFILE(isolate_, | 1622 PROFILE(isolate_, |
1626 CodeCreateEvent( | 1623 CodeCreateEvent( |
1627 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1624 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
1628 *code, *shared, NULL, | 1625 *code, *shared, isolate_->heap()->empty_string(), line_num, |
1629 isolate_->heap()->empty_string(), line_num, column_num)); | 1626 column_num)); |
1630 } | 1627 } |
1631 } else if (shared->IsApiFunction()) { | 1628 } else if (shared->IsApiFunction()) { |
1632 // API function. | 1629 // API function. |
1633 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | 1630 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); |
1634 Object* raw_call_data = fun_data->call_code(); | 1631 Object* raw_call_data = fun_data->call_code(); |
1635 if (!raw_call_data->IsUndefined()) { | 1632 if (!raw_call_data->IsUndefined()) { |
1636 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1633 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
1637 Object* callback_obj = call_data->callback(); | 1634 Object* callback_obj = call_data->callback(); |
1638 Address entry_point = v8::ToCData<Address>(callback_obj); | 1635 Address entry_point = v8::ToCData<Address>(callback_obj); |
1639 #if USES_FUNCTION_DESCRIPTORS | 1636 #if USES_FUNCTION_DESCRIPTORS |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 removeCodeEventListener(jit_logger_); | 1848 removeCodeEventListener(jit_logger_); |
1852 delete jit_logger_; | 1849 delete jit_logger_; |
1853 jit_logger_ = NULL; | 1850 jit_logger_ = NULL; |
1854 } | 1851 } |
1855 | 1852 |
1856 return log_->Close(); | 1853 return log_->Close(); |
1857 } | 1854 } |
1858 | 1855 |
1859 } // namespace internal | 1856 } // namespace internal |
1860 } // namespace v8 | 1857 } // namespace v8 |
OLD | NEW |