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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 case Code::FUNCTION: return code->optimizable() ? "~" : ""; | 1009 case Code::FUNCTION: return code->optimizable() ? "~" : ""; |
1010 case Code::OPTIMIZED_FUNCTION: return "*"; | 1010 case Code::OPTIMIZED_FUNCTION: return "*"; |
1011 default: return ""; | 1011 default: return ""; |
1012 } | 1012 } |
1013 } | 1013 } |
1014 | 1014 |
1015 | 1015 |
1016 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1016 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
1017 Code* code, | 1017 Code* code, |
1018 SharedFunctionInfo* shared, | 1018 SharedFunctionInfo* shared, |
| 1019 CompilationInfo* info, |
1019 Name* name) { | 1020 Name* name) { |
1020 if (!is_logging_code_events()) return; | 1021 if (!is_logging_code_events()) return; |
1021 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 1022 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
1022 name_buffer_->Reset(); | 1023 name_buffer_->Reset(); |
1023 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1024 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
1024 name_buffer_->AppendByte(':'); | 1025 name_buffer_->AppendByte(':'); |
1025 name_buffer_->AppendBytes(ComputeMarker(code)); | 1026 name_buffer_->AppendBytes(ComputeMarker(code)); |
1026 if (name->IsString()) { | 1027 if (name->IsString()) { |
1027 name_buffer_->AppendString(String::cast(name)); | 1028 name_buffer_->AppendString(String::cast(name)); |
1028 } else { | 1029 } else { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 msg.WriteToLogFile(); | 1087 msg.WriteToLogFile(); |
1087 } | 1088 } |
1088 | 1089 |
1089 | 1090 |
1090 // Although, it is possible to extract source and line from | 1091 // Although, it is possible to extract source and line from |
1091 // the SharedFunctionInfo object, we left it to caller | 1092 // the SharedFunctionInfo object, we left it to caller |
1092 // to leave logging functions free from heap allocations. | 1093 // to leave logging functions free from heap allocations. |
1093 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1094 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
1094 Code* code, | 1095 Code* code, |
1095 SharedFunctionInfo* shared, | 1096 SharedFunctionInfo* shared, |
| 1097 CompilationInfo* info, |
1096 Name* source, int line) { | 1098 Name* source, int line) { |
1097 if (!is_logging_code_events()) return; | 1099 if (!is_logging_code_events()) return; |
1098 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { | 1100 if (FLAG_ll_prof || Serializer::enabled() || code_event_handler_ != NULL) { |
1099 name_buffer_->Reset(); | 1101 name_buffer_->Reset(); |
1100 name_buffer_->AppendBytes(kLogEventsNames[tag]); | 1102 name_buffer_->AppendBytes(kLogEventsNames[tag]); |
1101 name_buffer_->AppendByte(':'); | 1103 name_buffer_->AppendByte(':'); |
1102 name_buffer_->AppendBytes(ComputeMarker(code)); | 1104 name_buffer_->AppendBytes(ComputeMarker(code)); |
1103 name_buffer_->AppendString(shared->DebugName()); | 1105 name_buffer_->AppendString(shared->DebugName()); |
1104 name_buffer_->AppendByte(' '); | 1106 name_buffer_->AppendByte(' '); |
1105 if (source->IsString()) { | 1107 if (source->IsString()) { |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 Handle<String> func_name(shared->DebugName()); | 1730 Handle<String> func_name(shared->DebugName()); |
1729 if (shared->script()->IsScript()) { | 1731 if (shared->script()->IsScript()) { |
1730 Handle<Script> script(Script::cast(shared->script())); | 1732 Handle<Script> script(Script::cast(shared->script())); |
1731 if (script->name()->IsString()) { | 1733 if (script->name()->IsString()) { |
1732 Handle<String> script_name(String::cast(script->name())); | 1734 Handle<String> script_name(String::cast(script->name())); |
1733 int line_num = GetScriptLineNumber(script, shared->start_position()); | 1735 int line_num = GetScriptLineNumber(script, shared->start_position()); |
1734 if (line_num > 0) { | 1736 if (line_num > 0) { |
1735 PROFILE(isolate_, | 1737 PROFILE(isolate_, |
1736 CodeCreateEvent( | 1738 CodeCreateEvent( |
1737 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1739 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
1738 *code, *shared, | 1740 *code, *shared, NULL, |
1739 *script_name, line_num + 1)); | 1741 *script_name, line_num + 1)); |
1740 } else { | 1742 } else { |
1741 // Can't distinguish eval and script here, so always use Script. | 1743 // Can't distinguish eval and script here, so always use Script. |
1742 PROFILE(isolate_, | 1744 PROFILE(isolate_, |
1743 CodeCreateEvent( | 1745 CodeCreateEvent( |
1744 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 1746 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
1745 *code, *shared, *script_name)); | 1747 *code, *shared, NULL, *script_name)); |
1746 } | 1748 } |
1747 } else { | 1749 } else { |
1748 PROFILE(isolate_, | 1750 PROFILE(isolate_, |
1749 CodeCreateEvent( | 1751 CodeCreateEvent( |
1750 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1752 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
1751 *code, *shared, *func_name)); | 1753 *code, *shared, NULL, *func_name)); |
1752 } | 1754 } |
1753 } else if (shared->IsApiFunction()) { | 1755 } else if (shared->IsApiFunction()) { |
1754 // API function. | 1756 // API function. |
1755 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | 1757 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); |
1756 Object* raw_call_data = fun_data->call_code(); | 1758 Object* raw_call_data = fun_data->call_code(); |
1757 if (!raw_call_data->IsUndefined()) { | 1759 if (!raw_call_data->IsUndefined()) { |
1758 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1760 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
1759 Object* callback_obj = call_data->callback(); | 1761 Object* callback_obj = call_data->callback(); |
1760 Address entry_point = v8::ToCData<Address>(callback_obj); | 1762 Address entry_point = v8::ToCData<Address>(callback_obj); |
1761 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); | 1763 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); |
1762 } | 1764 } |
1763 } else { | 1765 } else { |
1764 PROFILE(isolate_, | 1766 PROFILE(isolate_, |
1765 CodeCreateEvent( | 1767 CodeCreateEvent( |
1766 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); | 1768 Logger::LAZY_COMPILE_TAG, *code, *shared, NULL, *func_name)); |
1767 } | 1769 } |
1768 } | 1770 } |
1769 | 1771 |
1770 | 1772 |
1771 void Logger::LogCompiledFunctions() { | 1773 void Logger::LogCompiledFunctions() { |
1772 Heap* heap = isolate_->heap(); | 1774 Heap* heap = isolate_->heap(); |
1773 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1775 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1774 "Logger::LogCompiledFunctions"); | 1776 "Logger::LogCompiledFunctions"); |
1775 HandleScope scope(isolate_); | 1777 HandleScope scope(isolate_); |
1776 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); | 1778 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 profiler_ = NULL; | 1886 profiler_ = NULL; |
1885 } | 1887 } |
1886 | 1888 |
1887 delete ticker_; | 1889 delete ticker_; |
1888 ticker_ = NULL; | 1890 ticker_ = NULL; |
1889 | 1891 |
1890 return log_->Close(); | 1892 return log_->Close(); |
1891 } | 1893 } |
1892 | 1894 |
1893 } } // namespace v8::internal | 1895 } } // namespace v8::internal |
OLD | NEW |