Chromium Code Reviews

Side by Side Diff: src/log.cc

Issue 18058008: CPUProfiler: Improve line numbers support in profiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 1636 matching lines...)
1647 if (obj->IsCode()) LogCodeObject(obj); 1647 if (obj->IsCode()) LogCodeObject(obj);
1648 } 1648 }
1649 } 1649 }
1650 1650
1651 1651
1652 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, 1652 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
1653 Handle<Code> code) { 1653 Handle<Code> code) {
1654 Handle<String> func_name(shared->DebugName()); 1654 Handle<String> func_name(shared->DebugName());
1655 if (shared->script()->IsScript()) { 1655 if (shared->script()->IsScript()) {
1656 Handle<Script> script(Script::cast(shared->script())); 1656 Handle<Script> script(Script::cast(shared->script()));
1657 int line_num = GetScriptLineNumber(script, shared->start_position());
1657 if (script->name()->IsString()) { 1658 if (script->name()->IsString()) {
1658 Handle<String> script_name(String::cast(script->name())); 1659 Handle<String> script_name(String::cast(script->name()));
1659 int line_num = GetScriptLineNumber(script, shared->start_position()); 1660 if (line_num >= 0) {
1660 if (line_num > 0) {
1661 PROFILE(isolate_, 1661 PROFILE(isolate_,
1662 CodeCreateEvent( 1662 CodeCreateEvent(
1663 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), 1663 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
1664 *code, *shared, NULL, 1664 *code, *shared, NULL,
1665 *script_name, line_num + 1)); 1665 *script_name, line_num + 1));
1666 } else { 1666 } else {
1667 // Can't distinguish eval and script here, so always use Script.
yurys 2013/07/05 13:10:00 Revert this line?
loislo 2013/07/05 13:15:37 Done.
1668 PROFILE(isolate_, 1667 PROFILE(isolate_,
1669 CodeCreateEvent( 1668 CodeCreateEvent(
1670 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 1669 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
1671 *code, *shared, NULL, *script_name)); 1670 *code, *shared, NULL, *script_name));
1672 } 1671 }
1673 } else { 1672 } else {
1674 PROFILE(isolate_, 1673 PROFILE(isolate_,
1675 CodeCreateEvent( 1674 CodeCreateEvent(
1676 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), 1675 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
1677 *code, *shared, NULL, *func_name)); 1676 *code, *shared, NULL,
1677 isolate_->heap()->empty_string(), line_num + 1));
yurys 2013/07/05 13:10:00 You can do line_num = line_num + 1 once outside if
loislo 2013/07/05 13:15:37 Done.
1678 } 1678 }
1679 } else if (shared->IsApiFunction()) { 1679 } else if (shared->IsApiFunction()) {
1680 // API function. 1680 // API function.
1681 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); 1681 FunctionTemplateInfo* fun_data = shared->get_api_func_data();
1682 Object* raw_call_data = fun_data->call_code(); 1682 Object* raw_call_data = fun_data->call_code();
1683 if (!raw_call_data->IsUndefined()) { 1683 if (!raw_call_data->IsUndefined()) {
1684 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); 1684 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
1685 Object* callback_obj = call_data->callback(); 1685 Object* callback_obj = call_data->callback();
1686 Address entry_point = v8::ToCData<Address>(callback_obj); 1686 Address entry_point = v8::ToCData<Address>(callback_obj);
1687 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); 1687 PROFILE(isolate_, CallbackEvent(*func_name, entry_point));
(...skipping 122 matching lines...)
1810 profiler_ = NULL; 1810 profiler_ = NULL;
1811 } 1811 }
1812 1812
1813 delete ticker_; 1813 delete ticker_;
1814 ticker_ = NULL; 1814 ticker_ = NULL;
1815 1815
1816 return log_->Close(); 1816 return log_->Close();
1817 } 1817 }
1818 1818
1819 } } // namespace v8::internal 1819 } } // namespace v8::internal
OLDNEW
« src/cpu-profiler.cc ('K') | « src/cpu-profiler-inl.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine