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

Side by Side Diff: src/compiler.cc

Issue 668143003: Move BailoutReason and flags computation to post-pass (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase on trunk, use DisableOptimization() Created 6 years, 1 month 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
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // so we can afford to adjust the estimate generously. 571 // so we can afford to adjust the estimate generously.
572 estimate += 8; 572 estimate += 8;
573 } else { 573 } else {
574 estimate += 3; 574 estimate += 3;
575 } 575 }
576 576
577 shared->set_expected_nof_properties(estimate); 577 shared->set_expected_nof_properties(estimate);
578 } 578 }
579 579
580 580
581 static void MaybeDisableOptimization(Handle<SharedFunctionInfo> shared_info,
Sven Panne 2014/10/29 09:12:55 I think this should be folded into DisableOptimiza
wingo 2014/11/12 08:50:51 So, I did the renames to {set_,}disable_optimizati
582 BailoutReason bailout_reason) {
583 if (bailout_reason != kNoReason) {
584 shared_info->DisableOptimization(bailout_reason);
585 }
586 }
587
588
581 // Sets the function info on a function. 589 // Sets the function info on a function.
582 // The start_position points to the first '(' character after the function name 590 // The start_position points to the first '(' character after the function name
583 // in the full script source. When counting characters in the script source the 591 // in the full script source. When counting characters in the script source the
584 // the first character is number 0 (not 1). 592 // the first character is number 0 (not 1).
585 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, 593 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
586 FunctionLiteral* lit, 594 FunctionLiteral* lit,
587 bool is_toplevel, 595 bool is_toplevel,
588 Handle<Script> script) { 596 Handle<Script> script) {
589 function_info->set_length(lit->parameter_count()); 597 function_info->set_length(lit->parameter_count());
590 function_info->set_formal_parameter_count(lit->parameter_count()); 598 function_info->set_formal_parameter_count(lit->parameter_count());
591 function_info->set_script(*script); 599 function_info->set_script(*script);
592 function_info->set_function_token_position(lit->function_token_position()); 600 function_info->set_function_token_position(lit->function_token_position());
593 function_info->set_start_position(lit->start_position()); 601 function_info->set_start_position(lit->start_position());
594 function_info->set_end_position(lit->end_position()); 602 function_info->set_end_position(lit->end_position());
595 function_info->set_is_expression(lit->is_expression()); 603 function_info->set_is_expression(lit->is_expression());
596 function_info->set_is_anonymous(lit->is_anonymous()); 604 function_info->set_is_anonymous(lit->is_anonymous());
597 function_info->set_is_toplevel(is_toplevel); 605 function_info->set_is_toplevel(is_toplevel);
598 function_info->set_inferred_name(*lit->inferred_name()); 606 function_info->set_inferred_name(*lit->inferred_name());
599 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); 607 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
600 function_info->set_allows_lazy_compilation_without_context( 608 function_info->set_allows_lazy_compilation_without_context(
601 lit->AllowsLazyCompilationWithoutContext()); 609 lit->AllowsLazyCompilationWithoutContext());
602 function_info->set_strict_mode(lit->strict_mode()); 610 function_info->set_strict_mode(lit->strict_mode());
603 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); 611 function_info->set_uses_arguments(lit->scope()->arguments() != NULL);
604 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); 612 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
605 function_info->set_ast_node_count(lit->ast_node_count()); 613 function_info->set_ast_node_count(lit->ast_node_count());
606 function_info->set_is_function(lit->is_function()); 614 function_info->set_is_function(lit->is_function());
607 function_info->set_bailout_reason(lit->dont_optimize_reason()); 615 MaybeDisableOptimization(function_info, lit->dont_optimize_reason());
608 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); 616 function_info->set_dont_cache(lit->flags()->Contains(kDontCache));
609 function_info->set_kind(lit->kind()); 617 function_info->set_kind(lit->kind());
610 function_info->set_asm_function(lit->scope()->asm_function()); 618 function_info->set_asm_function(lit->scope()->asm_function());
611 } 619 }
612 620
613 621
614 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 622 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
615 CompilationInfo* info, 623 CompilationInfo* info,
616 Handle<SharedFunctionInfo> shared) { 624 Handle<SharedFunctionInfo> shared) {
617 // SharedFunctionInfo is passed separately, because if CompilationInfo 625 // SharedFunctionInfo is passed separately, because if CompilationInfo
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 CompilationInfo* info) { 669 CompilationInfo* info) {
662 VMState<COMPILER> state(info->isolate()); 670 VMState<COMPILER> state(info->isolate());
663 PostponeInterruptsScope postpone(info->isolate()); 671 PostponeInterruptsScope postpone(info->isolate());
664 672
665 // Parse and update CompilationInfo with the results. 673 // Parse and update CompilationInfo with the results.
666 if (!Parser::Parse(info)) return MaybeHandle<Code>(); 674 if (!Parser::Parse(info)) return MaybeHandle<Code>();
667 Handle<SharedFunctionInfo> shared = info->shared_info(); 675 Handle<SharedFunctionInfo> shared = info->shared_info();
668 FunctionLiteral* lit = info->function(); 676 FunctionLiteral* lit = info->function();
669 shared->set_strict_mode(lit->strict_mode()); 677 shared->set_strict_mode(lit->strict_mode());
670 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 678 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
671 shared->set_bailout_reason(lit->dont_optimize_reason()); 679 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
672 680
673 // Compile unoptimized code. 681 // Compile unoptimized code.
674 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 682 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
675 683
676 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 684 CHECK_EQ(Code::FUNCTION, info->code()->kind());
677 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 685 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
678 686
679 // Update the shared function info with the scope info. Allocating the 687 // Update the shared function info with the scope info. Allocating the
680 // ScopeInfo object may cause a GC. 688 // ScopeInfo object may cause a GC.
681 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone()); 689 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 Handle<Context> native_context(function->context()->native_context()); 742 Handle<Context> native_context(function->context()->native_context());
735 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 743 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
736 literals, info->osr_ast_id()); 744 literals, info->osr_ast_id());
737 } 745 }
738 } 746 }
739 747
740 748
741 static bool Renumber(CompilationInfo* info) { 749 static bool Renumber(CompilationInfo* info) {
742 if (!AstNumbering::Renumber(info->function(), info->zone())) return false; 750 if (!AstNumbering::Renumber(info->function(), info->zone())) return false;
743 if (!info->shared_info().is_null()) { 751 if (!info->shared_info().is_null()) {
744 info->shared_info()->set_ast_node_count(info->function()->ast_node_count()); 752 FunctionLiteral* lit = info->function();
753 info->shared_info()->set_ast_node_count(lit->ast_node_count());
754 MaybeDisableOptimization(info->shared_info(), lit->dont_optimize_reason());
755 info->shared_info()->set_dont_cache(lit->flags()->Contains(kDontCache));
745 } 756 }
746 return true; 757 return true;
747 } 758 }
748 759
749 760
750 bool Compiler::Analyze(CompilationInfo* info) { 761 bool Compiler::Analyze(CompilationInfo* info) {
751 DCHECK(info->function() != NULL); 762 DCHECK(info->function() != NULL);
752 if (!Rewriter::Rewrite(info)) return false; 763 if (!Rewriter::Rewrite(info)) return false;
753 if (!Scope::Analyze(info)) return false; 764 if (!Scope::Analyze(info)) return false;
754 if (!Renumber(info)) return false; 765 if (!Renumber(info)) return false;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 AllowHandleDereference allow_deref; 1480 AllowHandleDereference allow_deref;
1470 bool tracing_on = info()->IsStub() 1481 bool tracing_on = info()->IsStub()
1471 ? FLAG_trace_hydrogen_stubs 1482 ? FLAG_trace_hydrogen_stubs
1472 : (FLAG_trace_hydrogen && 1483 : (FLAG_trace_hydrogen &&
1473 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1484 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1474 return (tracing_on && 1485 return (tracing_on &&
1475 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1486 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1476 } 1487 }
1477 1488
1478 } } // namespace v8::internal 1489 } } // namespace v8::internal
OLDNEW
« src/ast-numbering.cc ('K') | « src/ast-numbering.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698