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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 IncrementNodeCount(); | 213 IncrementNodeCount(); |
214 Visit(node->expression()); | 214 Visit(node->expression()); |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 void AstNumberingVisitor::VisitYield(Yield* node) { | 218 void AstNumberingVisitor::VisitYield(Yield* node) { |
219 node->set_yield_id(yield_count_); | 219 node->set_yield_id(yield_count_); |
220 yield_count_++; | 220 yield_count_++; |
221 IncrementNodeCount(); | 221 IncrementNodeCount(); |
222 node->set_base_id(ReserveIdRange(Yield::num_ids())); | 222 node->set_base_id(ReserveIdRange(Yield::num_ids())); |
223 Visit(node->generator_object()); | |
224 Visit(node->expression()); | 223 Visit(node->expression()); |
225 } | 224 } |
226 | 225 |
227 | 226 |
228 void AstNumberingVisitor::VisitThrow(Throw* node) { | 227 void AstNumberingVisitor::VisitThrow(Throw* node) { |
229 IncrementNodeCount(); | 228 IncrementNodeCount(); |
230 node->set_base_id(ReserveIdRange(Throw::num_ids())); | 229 node->set_base_id(ReserveIdRange(Throw::num_ids())); |
231 Visit(node->exception()); | 230 Visit(node->exception()); |
232 } | 231 } |
233 | 232 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 414 } |
416 | 415 |
417 void AstNumberingVisitor::VisitGetIterator(GetIterator* node) { | 416 void AstNumberingVisitor::VisitGetIterator(GetIterator* node) { |
418 IncrementNodeCount(); | 417 IncrementNodeCount(); |
419 DisableFullCodegenAndCrankshaft(kGetIterator); | 418 DisableFullCodegenAndCrankshaft(kGetIterator); |
420 node->set_base_id(ReserveIdRange(GetIterator::num_ids())); | 419 node->set_base_id(ReserveIdRange(GetIterator::num_ids())); |
421 Visit(node->iterable()); | 420 Visit(node->iterable()); |
422 ReserveFeedbackSlots(node); | 421 ReserveFeedbackSlots(node); |
423 } | 422 } |
424 | 423 |
| 424 void AstNumberingVisitor::VisitInternalVariable(InternalVariable* node) { |
| 425 IncrementNodeCount(); |
| 426 DisableFullCodegenAndCrankshaft(kNoReason); |
| 427 } |
| 428 |
425 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { | 429 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
426 IncrementNodeCount(); | 430 IncrementNodeCount(); |
427 DisableSelfOptimization(); | 431 DisableSelfOptimization(); |
428 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); | 432 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
429 Visit(node->enumerable()); // Not part of loop. | 433 Visit(node->enumerable()); // Not part of loop. |
430 node->set_first_yield_id(yield_count_); | 434 node->set_first_yield_id(yield_count_); |
431 Visit(node->each()); | 435 Visit(node->each()); |
432 Visit(node->body()); | 436 Visit(node->body()); |
433 node->set_yield_count(yield_count_ - node->first_yield_id()); | 437 node->set_yield_count(yield_count_ - node->first_yield_id()); |
434 ReserveFeedbackSlots(node); | 438 ReserveFeedbackSlots(node); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 638 } |
635 | 639 |
636 if (IsResumableFunction(node->kind())) { | 640 if (IsResumableFunction(node->kind())) { |
637 DisableFullCodegenAndCrankshaft(kGenerator); | 641 DisableFullCodegenAndCrankshaft(kGenerator); |
638 } | 642 } |
639 | 643 |
640 if (IsClassConstructor(node->kind())) { | 644 if (IsClassConstructor(node->kind())) { |
641 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); | 645 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); |
642 } | 646 } |
643 | 647 |
| 648 if (scope->is_function_scope()) { |
| 649 Variable* function_var = scope->function_var(); |
| 650 if (function_var != nullptr && !function_var->IsUnallocated()) { |
| 651 // Initialization of local function-named variable is no longer part of |
| 652 // the AST, and this initialization is not handled in full-codegen or |
| 653 // crankshaft. |
| 654 DisableFullCodegenAndCrankshaft(kNoReason); |
| 655 } |
| 656 } |
| 657 |
| 658 if (IsGeneratorFunction(node->kind()) || scope->is_module_scope()) { |
| 659 // Generator functions and Modules have an initial yield which is not |
| 660 // included in the AST. |
| 661 DCHECK_EQ(0, yield_count_); |
| 662 yield_count_ = 1; |
| 663 } |
| 664 |
644 VisitDeclarations(scope->declarations()); | 665 VisitDeclarations(scope->declarations()); |
| 666 if (node->parameter_init_block() != nullptr) { |
| 667 DisableFullCodegenAndCrankshaft(kNonSimpleParameters); |
| 668 VisitBlock(node->parameter_init_block()); |
| 669 } |
645 VisitStatements(node->body()); | 670 VisitStatements(node->body()); |
646 | 671 |
647 node->set_ast_properties(&properties_); | 672 node->set_ast_properties(&properties_); |
648 node->set_dont_optimize_reason(dont_optimize_reason()); | 673 node->set_dont_optimize_reason(dont_optimize_reason()); |
649 node->set_yield_count(yield_count_); | 674 node->set_yield_count(yield_count_); |
650 | 675 |
651 if (FLAG_trace_opt) { | 676 if (FLAG_trace_opt) { |
652 if (disable_crankshaft_reason_ != kNoReason) { | 677 if (disable_crankshaft_reason_ != kNoReason) { |
653 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of | 678 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of |
654 // the function to be accessed in the below print. This DCHECK will fail | 679 // the function to be accessed in the below print. This DCHECK will fail |
(...skipping 16 matching lines...) Expand all Loading... |
671 Compiler::EagerInnerFunctionLiterals* eager_literals) { | 696 Compiler::EagerInnerFunctionLiterals* eager_literals) { |
672 DisallowHeapAllocation no_allocation; | 697 DisallowHeapAllocation no_allocation; |
673 DisallowHandleAllocation no_handles; | 698 DisallowHandleAllocation no_handles; |
674 DisallowHandleDereference no_deref; | 699 DisallowHandleDereference no_deref; |
675 | 700 |
676 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); | 701 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); |
677 return visitor.Renumber(function); | 702 return visitor.Renumber(function); |
678 } | 703 } |
679 } // namespace internal | 704 } // namespace internal |
680 } // namespace v8 | 705 } // namespace v8 |
OLD | NEW |