Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/compiler.cc

Issue 1728593002: [Interpreter] Add support for cpu profiler logging. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/compiler/code-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/ast/ast-numbering.h" 9 #include "src/ast/ast-numbering.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 Handle<SharedFunctionInfo> shared) { 710 Handle<SharedFunctionInfo> shared) {
711 // SharedFunctionInfo is passed separately, because if CompilationInfo 711 // SharedFunctionInfo is passed separately, because if CompilationInfo
712 // was created using Script object, it will not have it. 712 // was created using Script object, it will not have it.
713 713
714 // Log the code generation. If source information is available include 714 // Log the code generation. If source information is available include
715 // script name and line number. Check explicitly whether logging is 715 // script name and line number. Check explicitly whether logging is
716 // enabled as finding the line number is not free. 716 // enabled as finding the line number is not free.
717 if (info->isolate()->logger()->is_logging_code_events() || 717 if (info->isolate()->logger()->is_logging_code_events() ||
718 info->isolate()->cpu_profiler()->is_profiling()) { 718 info->isolate()->cpu_profiler()->is_profiling()) {
719 Handle<Script> script = info->parse_info()->script(); 719 Handle<Script> script = info->parse_info()->script();
720 Handle<Code> code = info->code(); 720 Handle<AbstractCode> abstract_code = info->abstract_code();
721 if (code.is_identical_to(info->isolate()->builtins()->CompileLazy())) { 721 if (abstract_code.is_identical_to(
722 info->isolate()->builtins()->CompileLazy())) {
722 return; 723 return;
723 } 724 }
724 int line_num = Script::GetLineNumber(script, shared->start_position()) + 1; 725 int line_num = Script::GetLineNumber(script, shared->start_position()) + 1;
725 int column_num = 726 int column_num =
726 Script::GetColumnNumber(script, shared->start_position()) + 1; 727 Script::GetColumnNumber(script, shared->start_position()) + 1;
727 String* script_name = script->name()->IsString() 728 String* script_name = script->name()->IsString()
728 ? String::cast(script->name()) 729 ? String::cast(script->name())
729 : info->isolate()->heap()->empty_string(); 730 : info->isolate()->heap()->empty_string();
730 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); 731 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script);
731 PROFILE(info->isolate(), 732 PROFILE(info->isolate(),
732 CodeCreateEvent(log_tag, *code, *shared, info, script_name, 733 CodeCreateEvent(log_tag, *abstract_code, *shared, info, script_name,
733 line_num, column_num)); 734 line_num, column_num));
734 } 735 }
735 } 736 }
736 737
737 static bool CompileUnoptimizedCode(CompilationInfo* info) { 738 static bool CompileUnoptimizedCode(CompilationInfo* info) {
738 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 739 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
739 if (!Compiler::Analyze(info->parse_info()) || 740 if (!Compiler::Analyze(info->parse_info()) ||
740 !FullCodeGenerator::MakeCode(info)) { 741 !FullCodeGenerator::MakeCode(info)) {
741 Isolate* isolate = info->isolate(); 742 Isolate* isolate = info->isolate();
742 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 743 if (!isolate->has_pending_exception()) isolate->StackOverflow();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // Parse and update CompilationInfo with the results. 818 // Parse and update CompilationInfo with the results.
818 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); 819 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>();
819 Handle<SharedFunctionInfo> shared = info->shared_info(); 820 Handle<SharedFunctionInfo> shared = info->shared_info();
820 FunctionLiteral* lit = info->literal(); 821 FunctionLiteral* lit = info->literal();
821 DCHECK_EQ(shared->language_mode(), lit->language_mode()); 822 DCHECK_EQ(shared->language_mode(), lit->language_mode());
822 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 823 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
823 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 824 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
824 825
825 // Compile either unoptimized code or bytecode for the interpreter. 826 // Compile either unoptimized code or bytecode for the interpreter.
826 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); 827 if (!CompileBaselineCode(info)) return MaybeHandle<Code>();
827 if (info->code()->kind() == Code::FUNCTION) { // Only for full code. 828 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
828 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
829 }
830 829
831 // Update the shared function info with the scope info. Allocating the 830 // Update the shared function info with the scope info. Allocating the
832 // ScopeInfo object may cause a GC. 831 // ScopeInfo object may cause a GC.
833 Handle<ScopeInfo> scope_info = 832 Handle<ScopeInfo> scope_info =
834 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); 833 ScopeInfo::Create(info->isolate(), info->zone(), info->scope());
835 shared->set_scope_info(*scope_info); 834 shared->set_scope_info(*scope_info);
836 835
837 // Update the code and feedback vector for the shared function info. 836 // Update the code and feedback vector for the shared function info.
838 shared->ReplaceCode(*info->code()); 837 shared->ReplaceCode(*info->code());
839 shared->set_feedback_vector(*info->feedback_vector()); 838 shared->set_feedback_vector(*info->feedback_vector());
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 } 1321 }
1323 1322
1324 Handle<String> script_name = 1323 Handle<String> script_name =
1325 script->name()->IsString() 1324 script->name()->IsString()
1326 ? Handle<String>(String::cast(script->name())) 1325 ? Handle<String>(String::cast(script->name()))
1327 : isolate->factory()->empty_string(); 1326 : isolate->factory()->empty_string();
1328 Logger::LogEventsAndTags log_tag = info->is_eval() 1327 Logger::LogEventsAndTags log_tag = info->is_eval()
1329 ? Logger::EVAL_TAG 1328 ? Logger::EVAL_TAG
1330 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); 1329 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);
1331 1330
1332 PROFILE(isolate, CodeCreateEvent( 1331 PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result,
1333 log_tag, *info->code(), *result, info, *script_name)); 1332 info, *script_name));
1334 1333
1335 // Hint to the runtime system used when allocating space for initial 1334 // Hint to the runtime system used when allocating space for initial
1336 // property space by setting the expected number of properties for 1335 // property space by setting the expected number of properties for
1337 // the instances of the function. 1336 // the instances of the function.
1338 SetExpectedNofPropertiesFromEstimate(result, 1337 SetExpectedNofPropertiesFromEstimate(result,
1339 lit->expected_property_count()); 1338 lit->expected_property_count());
1340 1339
1341 if (!script.is_null()) 1340 if (!script.is_null())
1342 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED); 1341 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
1343 1342
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 } 1887 }
1889 1888
1890 #if DEBUG 1889 #if DEBUG
1891 void CompilationInfo::PrintAstForTesting() { 1890 void CompilationInfo::PrintAstForTesting() {
1892 PrintF("--- Source from AST ---\n%s\n", 1891 PrintF("--- Source from AST ---\n%s\n",
1893 PrettyPrinter(isolate()).PrintProgram(literal())); 1892 PrettyPrinter(isolate()).PrintProgram(literal()));
1894 } 1893 }
1895 #endif 1894 #endif
1896 } // namespace internal 1895 } // namespace internal
1897 } // namespace v8 1896 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/code-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698