| 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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 | 1228 |
| 1229 // Although, it is possible to extract source and line from | 1229 // Although, it is possible to extract source and line from |
| 1230 // the SharedFunctionInfo object, we left it to caller | 1230 // the SharedFunctionInfo object, we left it to caller |
| 1231 // to leave logging functions free from heap allocations. | 1231 // to leave logging functions free from heap allocations. |
| 1232 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1232 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1233 Code* code, | 1233 Code* code, |
| 1234 SharedFunctionInfo* shared, | 1234 SharedFunctionInfo* shared, |
| 1235 CompilationInfo* info, | 1235 CompilationInfo* info, |
| 1236 Name* source, int line) { | 1236 Name* source, int line, int column) { |
| 1237 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); | 1237 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| 1238 | 1238 |
| 1239 if (!is_logging_code_events()) return; | 1239 if (!is_logging_code_events()) return; |
| 1240 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line)); | 1240 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line)); |
| 1241 | 1241 |
| 1242 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1242 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1243 Log::MessageBuilder msg(log_); | 1243 Log::MessageBuilder msg(log_); |
| 1244 AppendCodeCreateHeader(&msg, tag, code); | 1244 AppendCodeCreateHeader(&msg, tag, code); |
| 1245 SmartArrayPointer<char> name = | 1245 SmartArrayPointer<char> name = |
| 1246 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1246 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1247 msg.Append("\"%s ", *name); | 1247 msg.Append("\"%s ", *name); |
| 1248 if (source->IsString()) { | 1248 if (source->IsString()) { |
| 1249 SmartArrayPointer<char> sourcestr = | 1249 SmartArrayPointer<char> sourcestr = |
| 1250 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1250 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1251 msg.Append("%s", *sourcestr); | 1251 msg.Append("%s", *sourcestr); |
| 1252 } else { | 1252 } else { |
| 1253 msg.AppendSymbolName(Symbol::cast(source)); | 1253 msg.AppendSymbolName(Symbol::cast(source)); |
| 1254 } | 1254 } |
| 1255 msg.Append(":%d\",", line); | 1255 msg.Append(":%d:%d\",", line, column); |
| 1256 msg.AppendAddress(shared->address()); | 1256 msg.AppendAddress(shared->address()); |
| 1257 msg.Append(",%s", ComputeMarker(code)); | 1257 msg.Append(",%s", ComputeMarker(code)); |
| 1258 msg.Append('\n'); | 1258 msg.Append('\n'); |
| 1259 msg.WriteToLogFile(); | 1259 msg.WriteToLogFile(); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 | 1262 |
| 1263 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1263 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1264 Code* code, | 1264 Code* code, |
| 1265 int args_count) { | 1265 int args_count) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 } | 1705 } |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 | 1708 |
| 1709 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, | 1709 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, |
| 1710 Handle<Code> code) { | 1710 Handle<Code> code) { |
| 1711 Handle<String> func_name(shared->DebugName()); | 1711 Handle<String> func_name(shared->DebugName()); |
| 1712 if (shared->script()->IsScript()) { | 1712 if (shared->script()->IsScript()) { |
| 1713 Handle<Script> script(Script::cast(shared->script())); | 1713 Handle<Script> script(Script::cast(shared->script())); |
| 1714 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; | 1714 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; |
| 1715 int column_num = |
| 1716 GetScriptColumnNumber(script, shared->start_position()) + 1; |
| 1715 if (script->name()->IsString()) { | 1717 if (script->name()->IsString()) { |
| 1716 Handle<String> script_name(String::cast(script->name())); | 1718 Handle<String> script_name(String::cast(script->name())); |
| 1717 if (line_num > 0) { | 1719 if (line_num > 0) { |
| 1718 PROFILE(isolate_, | 1720 PROFILE(isolate_, |
| 1719 CodeCreateEvent( | 1721 CodeCreateEvent( |
| 1720 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1722 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
| 1721 *code, *shared, NULL, | 1723 *code, *shared, NULL, |
| 1722 *script_name, line_num)); | 1724 *script_name, line_num, column_num)); |
| 1723 } else { | 1725 } else { |
| 1724 // Can't distinguish eval and script here, so always use Script. | 1726 // Can't distinguish eval and script here, so always use Script. |
| 1725 PROFILE(isolate_, | 1727 PROFILE(isolate_, |
| 1726 CodeCreateEvent( | 1728 CodeCreateEvent( |
| 1727 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 1729 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 1728 *code, *shared, NULL, *script_name)); | 1730 *code, *shared, NULL, *script_name)); |
| 1729 } | 1731 } |
| 1730 } else { | 1732 } else { |
| 1731 PROFILE(isolate_, | 1733 PROFILE(isolate_, |
| 1732 CodeCreateEvent( | 1734 CodeCreateEvent( |
| 1733 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1735 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
| 1734 *code, *shared, NULL, | 1736 *code, *shared, NULL, |
| 1735 isolate_->heap()->empty_string(), line_num)); | 1737 isolate_->heap()->empty_string(), line_num, column_num)); |
| 1736 } | 1738 } |
| 1737 } else if (shared->IsApiFunction()) { | 1739 } else if (shared->IsApiFunction()) { |
| 1738 // API function. | 1740 // API function. |
| 1739 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | 1741 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); |
| 1740 Object* raw_call_data = fun_data->call_code(); | 1742 Object* raw_call_data = fun_data->call_code(); |
| 1741 if (!raw_call_data->IsUndefined()) { | 1743 if (!raw_call_data->IsUndefined()) { |
| 1742 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1744 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
| 1743 Object* callback_obj = call_data->callback(); | 1745 Object* callback_obj = call_data->callback(); |
| 1744 Address entry_point = v8::ToCData<Address>(callback_obj); | 1746 Address entry_point = v8::ToCData<Address>(callback_obj); |
| 1745 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); | 1747 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 if (jit_logger_) { | 1949 if (jit_logger_) { |
| 1948 removeCodeEventListener(jit_logger_); | 1950 removeCodeEventListener(jit_logger_); |
| 1949 delete jit_logger_; | 1951 delete jit_logger_; |
| 1950 jit_logger_ = NULL; | 1952 jit_logger_ = NULL; |
| 1951 } | 1953 } |
| 1952 | 1954 |
| 1953 return log_->Close(); | 1955 return log_->Close(); |
| 1954 } | 1956 } |
| 1955 | 1957 |
| 1956 } } // namespace v8::internal | 1958 } } // namespace v8::internal |
| OLD | NEW |