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

Side by Side Diff: src/compiler.cc

Issue 6771045: Never use classic code generator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments and fix testing Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/flag-definitions.h » ('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 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 319 }
320 320
321 321
322 static bool MakeCode(CompilationInfo* info) { 322 static bool MakeCode(CompilationInfo* info) {
323 // Precondition: code has been parsed. Postcondition: the code field in 323 // Precondition: code has been parsed. Postcondition: the code field in
324 // the compilation info is set if compilation succeeded. 324 // the compilation info is set if compilation succeeded.
325 ASSERT(info->function() != NULL); 325 ASSERT(info->function() != NULL);
326 326
327 if (Rewriter::Rewrite(info) && Scope::Analyze(info)) { 327 if (Rewriter::Rewrite(info) && Scope::Analyze(info)) {
328 if (V8::UseCrankshaft()) return MakeCrankshaftCode(info); 328 if (V8::UseCrankshaft()) return MakeCrankshaftCode(info);
329 329 // If crankshaft is not supported fall back to full code generator
330 // Generate code and return it. Code generator selection is governed by 330 // for all compilation.
331 // which backends are enabled and whether the function is considered 331 return FullCodeGenerator::MakeCode(info);
332 // run-once code or not.
333 //
334 // --full-compiler enables the dedicated backend for code we expect to
335 // be run once
336 //
337 // The normal choice of backend can be overridden with the flags
338 // --always-full-compiler.
339 if (Rewriter::Analyze(info)) {
340 Handle<SharedFunctionInfo> shared = info->shared_info();
341 bool is_run_once = (shared.is_null())
342 ? info->scope()->is_global_scope()
343 : (shared->is_toplevel() || shared->try_full_codegen());
344 bool can_use_full =
345 FLAG_full_compiler && !info->function()->contains_loops();
346 if (AlwaysFullCompiler() || (is_run_once && can_use_full)) {
347 return FullCodeGenerator::MakeCode(info);
348 } else {
349 return AssignedVariablesAnalyzer::Analyze(info) &&
350 CodeGenerator::MakeCode(info);
351 }
352 }
353 } 332 }
354 333
355 return false; 334 return false;
356 } 335 }
357 336
358 337
359 #ifdef ENABLE_DEBUGGER_SUPPORT 338 #ifdef ENABLE_DEBUGGER_SUPPORT
360 bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) { 339 bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) {
361 // Precondition: code has been parsed. Postcondition: the code field in 340 // Precondition: code has been parsed. Postcondition: the code field in
362 // the compilation info is set if compilation succeeded. 341 // the compilation info is set if compilation succeeded.
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // parser records. 693 // parser records.
715 bool allow_lazy = literal->AllowsLazyCompilation() && 694 bool allow_lazy = literal->AllowsLazyCompilation() &&
716 !LiveEditFunctionTracker::IsActive(info.isolate()); 695 !LiveEditFunctionTracker::IsActive(info.isolate());
717 696
718 Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty()); 697 Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty());
719 698
720 // Generate code 699 // Generate code
721 if (FLAG_lazy && allow_lazy) { 700 if (FLAG_lazy && allow_lazy) {
722 Handle<Code> code = info.isolate()->builtins()->LazyCompile(); 701 Handle<Code> code = info.isolate()->builtins()->LazyCompile();
723 info.SetCode(code); 702 info.SetCode(code);
703 } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) ||
704 (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) {
705 ASSERT(!info.code().is_null());
706 scope_info = SerializedScopeInfo::Create(info.scope());
724 } else { 707 } else {
725 if (V8::UseCrankshaft()) { 708 return Handle<SharedFunctionInfo>::null();
726 if (!MakeCrankshaftCode(&info)) {
727 return Handle<SharedFunctionInfo>::null();
728 }
729 } else {
730 // The bodies of function literals have not yet been visited by the
731 // AST optimizer/analyzer.
732 if (!Rewriter::Analyze(&info)) return Handle<SharedFunctionInfo>::null();
733
734 bool is_run_once = literal->try_full_codegen();
735 bool can_use_full = FLAG_full_compiler && !literal->contains_loops();
736
737 if (AlwaysFullCompiler() || (is_run_once && can_use_full)) {
738 if (!FullCodeGenerator::MakeCode(&info)) {
739 return Handle<SharedFunctionInfo>::null();
740 }
741 } else {
742 // We fall back to the classic V8 code generator.
743 if (!AssignedVariablesAnalyzer::Analyze(&info) ||
744 !CodeGenerator::MakeCode(&info)) {
745 return Handle<SharedFunctionInfo>::null();
746 }
747 }
748 }
749 ASSERT(!info.code().is_null());
750
751 // Function compilation complete.
752 scope_info = SerializedScopeInfo::Create(info.scope());
753 } 709 }
754 710
755 // Create a shared function info object. 711 // Create a shared function info object.
756 Handle<SharedFunctionInfo> result = 712 Handle<SharedFunctionInfo> result =
757 FACTORY->NewSharedFunctionInfo(literal->name(), 713 FACTORY->NewSharedFunctionInfo(literal->name(),
758 literal->materialized_literal_count(), 714 literal->materialized_literal_count(),
759 info.code(), 715 info.code(),
760 scope_info); 716 scope_info);
761 SetFunctionInfo(result, literal, false, script); 717 SetFunctionInfo(result, literal, false, script);
762 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 718 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
(...skipping 21 matching lines...) Expand all
784 function_info->set_script(*script); 740 function_info->set_script(*script);
785 function_info->set_function_token_position(lit->function_token_position()); 741 function_info->set_function_token_position(lit->function_token_position());
786 function_info->set_start_position(lit->start_position()); 742 function_info->set_start_position(lit->start_position());
787 function_info->set_end_position(lit->end_position()); 743 function_info->set_end_position(lit->end_position());
788 function_info->set_is_expression(lit->is_expression()); 744 function_info->set_is_expression(lit->is_expression());
789 function_info->set_is_toplevel(is_toplevel); 745 function_info->set_is_toplevel(is_toplevel);
790 function_info->set_inferred_name(*lit->inferred_name()); 746 function_info->set_inferred_name(*lit->inferred_name());
791 function_info->SetThisPropertyAssignmentsInfo( 747 function_info->SetThisPropertyAssignmentsInfo(
792 lit->has_only_simple_this_property_assignments(), 748 lit->has_only_simple_this_property_assignments(),
793 *lit->this_property_assignments()); 749 *lit->this_property_assignments());
794 function_info->set_try_full_codegen(lit->try_full_codegen());
795 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); 750 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
796 function_info->set_strict_mode(lit->strict_mode()); 751 function_info->set_strict_mode(lit->strict_mode());
797 } 752 }
798 753
799 754
800 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, 755 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
801 CompilationInfo* info, 756 CompilationInfo* info,
802 Handle<SharedFunctionInfo> shared) { 757 Handle<SharedFunctionInfo> shared) {
803 // SharedFunctionInfo is passed separately, because if CompilationInfo 758 // SharedFunctionInfo is passed separately, because if CompilationInfo
804 // was created using Script object, it will not have it. 759 // was created using Script object, it will not have it.
(...skipping 23 matching lines...) Expand all
828 shared->DebugName())); 783 shared->DebugName()));
829 } 784 }
830 } 785 }
831 786
832 GDBJIT(AddCode(name, 787 GDBJIT(AddCode(name,
833 Handle<Script>(info->script()), 788 Handle<Script>(info->script()),
834 Handle<Code>(info->code()))); 789 Handle<Code>(info->code())));
835 } 790 }
836 791
837 } } // namespace v8::internal 792 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698