OLD | NEW |
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/ast/ast-numbering.h" | 5 #include "src/ast/ast-numbering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 !scope->arguments()->IsStackAllocated()) { | 657 !scope->arguments()->IsStackAllocated()) { |
658 DisableFullCodegenAndCrankshaft(kContextAllocatedArguments); | 658 DisableFullCodegenAndCrankshaft(kContextAllocatedArguments); |
659 } | 659 } |
660 | 660 |
661 if (scope->rest_parameter() != nullptr) { | 661 if (scope->rest_parameter() != nullptr) { |
662 DisableFullCodegenAndCrankshaft(kRestParameter); | 662 DisableFullCodegenAndCrankshaft(kRestParameter); |
663 } | 663 } |
664 | 664 |
665 if (IsResumableFunction(node->kind())) { | 665 if (IsResumableFunction(node->kind())) { |
666 DisableFullCodegenAndCrankshaft(kGenerator); | 666 DisableFullCodegenAndCrankshaft(kGenerator); |
| 667 |
| 668 if (IsAsyncFunction(node->kind())) { |
| 669 // Set initial catch_prediction to HandlerTable::ASYNC_AWAIT for the |
| 670 // wrapper try/catch block not present in the AST. |
| 671 catch_prediction_ = HandlerTable::ASYNC_AWAIT; |
| 672 } |
667 } | 673 } |
668 | 674 |
669 if (IsClassConstructor(node->kind())) { | 675 if (IsClassConstructor(node->kind())) { |
670 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); | 676 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); |
671 } | 677 } |
672 | 678 |
| 679 if (scope->is_function_scope()) { |
| 680 Variable* function_var = scope->function_var(); |
| 681 if (function_var != nullptr && !function_var->IsUnallocated()) { |
| 682 // Initialization of local function-named variable is no longer part of |
| 683 // the AST, and this initialization is not handled in full-codegen or |
| 684 // crankshaft. |
| 685 DisableFullCodegenAndCrankshaft(kNoReason); |
| 686 } |
| 687 } |
| 688 |
| 689 if (IsGeneratorFunction(node->kind()) || scope->is_module_scope()) { |
| 690 // Generator functions and Modules have an initial yield which is not |
| 691 // included in the AST. |
| 692 DCHECK_EQ(0, yield_count_); |
| 693 yield_count_ = 1; |
| 694 } |
| 695 |
673 LanguageModeScope language_mode_scope(this, node->language_mode()); | 696 LanguageModeScope language_mode_scope(this, node->language_mode()); |
674 | 697 |
675 VisitDeclarations(scope->declarations()); | 698 VisitDeclarations(scope->declarations()); |
| 699 if (node->parameter_init_block() != nullptr) { |
| 700 DisableFullCodegenAndCrankshaft(kNonSimpleParameters); |
| 701 VisitBlock(node->parameter_init_block()); |
| 702 } |
676 VisitStatements(node->body()); | 703 VisitStatements(node->body()); |
677 | 704 |
678 node->set_ast_properties(&properties_); | 705 node->set_ast_properties(&properties_); |
679 node->set_dont_optimize_reason(dont_optimize_reason()); | 706 node->set_dont_optimize_reason(dont_optimize_reason()); |
680 node->set_yield_count(yield_count_); | 707 node->set_yield_count(yield_count_); |
681 | 708 |
682 if (FLAG_trace_opt) { | 709 if (FLAG_trace_opt) { |
683 if (disable_crankshaft_reason_ != kNoReason) { | 710 if (disable_crankshaft_reason_ != kNoReason) { |
684 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of | 711 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of |
685 // the function to be accessed in the below print. This DCHECK will fail | 712 // the function to be accessed in the below print. This DCHECK will fail |
(...skipping 16 matching lines...) Expand all Loading... |
702 Compiler::EagerInnerFunctionLiterals* eager_literals) { | 729 Compiler::EagerInnerFunctionLiterals* eager_literals) { |
703 DisallowHeapAllocation no_allocation; | 730 DisallowHeapAllocation no_allocation; |
704 DisallowHandleAllocation no_handles; | 731 DisallowHandleAllocation no_handles; |
705 DisallowHandleDereference no_deref; | 732 DisallowHandleDereference no_deref; |
706 | 733 |
707 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); | 734 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); |
708 return visitor.Renumber(function); | 735 return visitor.Renumber(function); |
709 } | 736 } |
710 } // namespace internal | 737 } // namespace internal |
711 } // namespace v8 | 738 } // namespace v8 |
OLD | NEW |