| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 174 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 175 AbstractCode* code, Name* name) { | 175 AbstractCode* code, Name* name) { |
| 176 name_buffer_->Init(tag); | 176 name_buffer_->Init(tag); |
| 177 name_buffer_->AppendName(name); | 177 name_buffer_->AppendName(name); |
| 178 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); | 178 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 181 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 182 AbstractCode* code, | 182 AbstractCode* code, |
| 183 SharedFunctionInfo* shared, | 183 SharedFunctionInfo* shared, Name* name) { |
| 184 CompilationInfo* info, Name* name) { | |
| 185 name_buffer_->Init(tag); | 184 name_buffer_->Init(tag); |
| 186 name_buffer_->AppendBytes(ComputeMarker(shared, code)); | 185 name_buffer_->AppendBytes(ComputeMarker(shared, code)); |
| 187 name_buffer_->AppendName(name); | 186 name_buffer_->AppendName(name); |
| 188 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); | 187 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); |
| 189 } | 188 } |
| 190 | 189 |
| 191 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 190 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 192 AbstractCode* code, | 191 AbstractCode* code, |
| 193 SharedFunctionInfo* shared, | 192 SharedFunctionInfo* shared, |
| 194 CompilationInfo* info, Name* source, | 193 CompilationInfo* info, Name* source, |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 msg.Append('"'); | 1110 msg.Append('"'); |
| 1112 msg.AppendDetailed(String::cast(name), false); | 1111 msg.AppendDetailed(String::cast(name), false); |
| 1113 msg.Append('"'); | 1112 msg.Append('"'); |
| 1114 } else { | 1113 } else { |
| 1115 msg.AppendSymbolName(Symbol::cast(name)); | 1114 msg.AppendSymbolName(Symbol::cast(name)); |
| 1116 } | 1115 } |
| 1117 msg.WriteToLogFile(); | 1116 msg.WriteToLogFile(); |
| 1118 } | 1117 } |
| 1119 | 1118 |
| 1120 void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, | 1119 void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
| 1121 SharedFunctionInfo* shared, CompilationInfo* info, | 1120 SharedFunctionInfo* shared, Name* name) { |
| 1122 Name* name) { | 1121 PROFILER_LOG(CodeCreateEvent(tag, code, shared, name)); |
| 1123 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); | |
| 1124 | 1122 |
| 1125 if (!is_logging_code_events()) return; | 1123 if (!is_logging_code_events()) return; |
| 1126 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name)); | 1124 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, name)); |
| 1127 | 1125 |
| 1128 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1126 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1129 if (code == AbstractCode::cast( | 1127 if (code == AbstractCode::cast( |
| 1130 isolate_->builtins()->builtin(Builtins::kCompileLazy))) { | 1128 isolate_->builtins()->builtin(Builtins::kCompileLazy))) { |
| 1131 return; | 1129 return; |
| 1132 } | 1130 } |
| 1133 | 1131 |
| 1134 Log::MessageBuilder msg(log_); | 1132 Log::MessageBuilder msg(log_); |
| 1135 AppendCodeCreateHeader(&msg, tag, code); | 1133 AppendCodeCreateHeader(&msg, tag, code); |
| 1136 if (name->IsString()) { | 1134 if (name->IsString()) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 if (script->name()->IsString()) { | 1609 if (script->name()->IsString()) { |
| 1612 Handle<String> script_name(String::cast(script->name())); | 1610 Handle<String> script_name(String::cast(script->name())); |
| 1613 if (line_num > 0) { | 1611 if (line_num > 0) { |
| 1614 PROFILE(isolate_, | 1612 PROFILE(isolate_, |
| 1615 CodeCreateEvent( | 1613 CodeCreateEvent( |
| 1616 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1614 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
| 1617 *code, *shared, NULL, | 1615 *code, *shared, NULL, |
| 1618 *script_name, line_num, column_num)); | 1616 *script_name, line_num, column_num)); |
| 1619 } else { | 1617 } else { |
| 1620 // Can't distinguish eval and script here, so always use Script. | 1618 // Can't distinguish eval and script here, so always use Script. |
| 1621 PROFILE(isolate_, | 1619 PROFILE(isolate_, CodeCreateEvent(Logger::ToNativeByScript( |
| 1622 CodeCreateEvent( | 1620 Logger::SCRIPT_TAG, *script), |
| 1623 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 1621 *code, *shared, *script_name)); |
| 1624 *code, *shared, NULL, *script_name)); | |
| 1625 } | 1622 } |
| 1626 } else { | 1623 } else { |
| 1627 PROFILE(isolate_, | 1624 PROFILE(isolate_, |
| 1628 CodeCreateEvent( | 1625 CodeCreateEvent( |
| 1629 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1626 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
| 1630 *code, *shared, NULL, | 1627 *code, *shared, NULL, |
| 1631 isolate_->heap()->empty_string(), line_num, column_num)); | 1628 isolate_->heap()->empty_string(), line_num, column_num)); |
| 1632 } | 1629 } |
| 1633 } else if (shared->IsApiFunction()) { | 1630 } else if (shared->IsApiFunction()) { |
| 1634 // API function. | 1631 // API function. |
| 1635 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | 1632 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); |
| 1636 Object* raw_call_data = fun_data->call_code(); | 1633 Object* raw_call_data = fun_data->call_code(); |
| 1637 if (!raw_call_data->IsUndefined()) { | 1634 if (!raw_call_data->IsUndefined()) { |
| 1638 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1635 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
| 1639 Object* callback_obj = call_data->callback(); | 1636 Object* callback_obj = call_data->callback(); |
| 1640 Address entry_point = v8::ToCData<Address>(callback_obj); | 1637 Address entry_point = v8::ToCData<Address>(callback_obj); |
| 1641 #if USES_FUNCTION_DESCRIPTORS | 1638 #if USES_FUNCTION_DESCRIPTORS |
| 1642 entry_point = *FUNCTION_ENTRYPOINT_ADDRESS(entry_point); | 1639 entry_point = *FUNCTION_ENTRYPOINT_ADDRESS(entry_point); |
| 1643 #endif | 1640 #endif |
| 1644 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); | 1641 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); |
| 1645 } | 1642 } |
| 1646 } else { | 1643 } else { |
| 1647 PROFILE(isolate_, | 1644 PROFILE(isolate_, CodeCreateEvent(Logger::LAZY_COMPILE_TAG, *code, *shared, |
| 1648 CodeCreateEvent( | 1645 *func_name)); |
| 1649 Logger::LAZY_COMPILE_TAG, *code, *shared, NULL, *func_name)); | |
| 1650 } | 1646 } |
| 1651 } | 1647 } |
| 1652 | 1648 |
| 1653 | 1649 |
| 1654 void Logger::LogCompiledFunctions() { | 1650 void Logger::LogCompiledFunctions() { |
| 1655 Heap* heap = isolate_->heap(); | 1651 Heap* heap = isolate_->heap(); |
| 1656 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1652 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 1657 "Logger::LogCompiledFunctions"); | 1653 "Logger::LogCompiledFunctions"); |
| 1658 HandleScope scope(isolate_); | 1654 HandleScope scope(isolate_); |
| 1659 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); | 1655 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 removeCodeEventListener(jit_logger_); | 1850 removeCodeEventListener(jit_logger_); |
| 1855 delete jit_logger_; | 1851 delete jit_logger_; |
| 1856 jit_logger_ = NULL; | 1852 jit_logger_ = NULL; |
| 1857 } | 1853 } |
| 1858 | 1854 |
| 1859 return log_->Close(); | 1855 return log_->Close(); |
| 1860 } | 1856 } |
| 1861 | 1857 |
| 1862 } // namespace internal | 1858 } // namespace internal |
| 1863 } // namespace v8 | 1859 } // namespace v8 |
| OLD | NEW |