| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 564 |
| 565 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() { | 565 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() { |
| 566 // Initialize the incoming context. | 566 // Initialize the incoming context. |
| 567 ContextScope incoming_context(this, scope(), false); | 567 ContextScope incoming_context(this, scope(), false); |
| 568 | 568 |
| 569 // Initialize control scope. | 569 // Initialize control scope. |
| 570 ControlScopeForTopLevel control(this); | 570 ControlScopeForTopLevel control(this); |
| 571 | 571 |
| 572 RegisterAllocationScope register_scope(this); | 572 RegisterAllocationScope register_scope(this); |
| 573 | 573 |
| 574 if (IsGeneratorFunction(info()->literal()->kind())) { | 574 if (IsResumableFunction(info()->literal()->kind())) { |
| 575 generator_state_ = register_allocator()->NewRegister(); | 575 generator_state_ = register_allocator()->NewRegister(); |
| 576 VisitGeneratorPrologue(); | 576 VisitGeneratorPrologue(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // Build function context only if there are context allocated variables. | 579 // Build function context only if there are context allocated variables. |
| 580 if (scope()->NeedsContext()) { | 580 if (scope()->NeedsContext()) { |
| 581 // Push a new inner context scope for the function. | 581 // Push a new inner context scope for the function. |
| 582 VisitNewLocalFunctionContext(); | 582 VisitNewLocalFunctionContext(); |
| 583 ContextScope local_function_context(this, scope(), false); | 583 ContextScope local_function_context(this, scope(), false); |
| 584 VisitBuildLocalActivationContext(); | 584 VisitBuildLocalActivationContext(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 // This is a resume call. Restore registers and perform state dispatch. | 691 // This is a resume call. Restore registers and perform state dispatch. |
| 692 // (The current context has already been restored by the trampoline.) | 692 // (The current context has already been restored by the trampoline.) |
| 693 builder() | 693 builder() |
| 694 ->ResumeGenerator(generator_object) | 694 ->ResumeGenerator(generator_object) |
| 695 .StoreAccumulatorInRegister(generator_state_); | 695 .StoreAccumulatorInRegister(generator_state_); |
| 696 BuildIndexedJump(generator_state_, 0, generator_resume_points_.size(), | 696 BuildIndexedJump(generator_state_, 0, generator_resume_points_.size(), |
| 697 generator_resume_points_); | 697 generator_resume_points_); |
| 698 | 698 |
| 699 builder()->Bind(®ular_call); | 699 builder()->Bind(®ular_call); |
| 700 // This is a regular call. Fall through to the ordinary function prologue, | 700 // This is a regular call. Fall through to the ordinary function prologue, |
| 701 // after which we will run into the generator object creation and the initial | 701 // after which we will run into the generator object creation and other extra |
| 702 // yield (both inserted by the parser). | 702 // code inserted by the parser. |
| 703 } | 703 } |
| 704 | 704 |
| 705 void BytecodeGenerator::VisitBlock(Block* stmt) { | 705 void BytecodeGenerator::VisitBlock(Block* stmt) { |
| 706 // Visit declarations and statements. | 706 // Visit declarations and statements. |
| 707 if (stmt->scope() != nullptr && stmt->scope()->NeedsContext()) { | 707 if (stmt->scope() != nullptr && stmt->scope()->NeedsContext()) { |
| 708 VisitNewLocalBlockContext(stmt->scope()); | 708 VisitNewLocalBlockContext(stmt->scope()); |
| 709 ContextScope scope(this, stmt->scope()); | 709 ContextScope scope(this, stmt->scope()); |
| 710 VisitBlockDeclarationsAndStatements(stmt); | 710 VisitBlockDeclarationsAndStatements(stmt); |
| 711 } else { | 711 } else { |
| 712 VisitBlockDeclarationsAndStatements(stmt); | 712 VisitBlockDeclarationsAndStatements(stmt); |
| (...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 return execution_context()->scope()->language_mode(); | 3190 return execution_context()->scope()->language_mode(); |
| 3191 } | 3191 } |
| 3192 | 3192 |
| 3193 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3193 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3194 return TypeFeedbackVector::GetIndex(slot); | 3194 return TypeFeedbackVector::GetIndex(slot); |
| 3195 } | 3195 } |
| 3196 | 3196 |
| 3197 } // namespace interpreter | 3197 } // namespace interpreter |
| 3198 } // namespace internal | 3198 } // namespace internal |
| 3199 } // namespace v8 | 3199 } // namespace v8 |
| OLD | NEW |