| 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/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 .CompareOperation(Token::Value::EQ_STRICT, index) | 715 .CompareOperation(Token::Value::EQ_STRICT, index) |
| 716 .JumpIfTrue(&(targets[i])); | 716 .JumpIfTrue(&(targets[i])); |
| 717 } | 717 } |
| 718 BuildAbort(BailoutReason::kInvalidJumpTableIndex); | 718 BuildAbort(BailoutReason::kInvalidJumpTableIndex); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, | 721 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, |
| 722 LoopBuilder* loop_builder) { | 722 LoopBuilder* loop_builder) { |
| 723 // Recall that stmt->yield_count() is always zero inside ordinary | 723 // Recall that stmt->yield_count() is always zero inside ordinary |
| 724 // (i.e. non-generator) functions. | 724 // (i.e. non-generator) functions. |
| 725 if (stmt->yield_count() == 0) { |
| 726 loop_builder->LoopHeader(); |
| 727 } else { |
| 728 // Collect all labels for generator resume points within the loop (if any) |
| 729 // so that they can be bound to the loop header below. Also create fresh |
| 730 // labels for these resume points, to be used inside the loop. |
| 731 ZoneVector<BytecodeLabel> resume_points_in_loop(zone()); |
| 732 size_t first_yield = stmt->first_yield_id(); |
| 733 DCHECK_LE(first_yield + stmt->yield_count(), |
| 734 generator_resume_points_.size()); |
| 735 for (size_t id = first_yield; id < first_yield + stmt->yield_count(); |
| 736 id++) { |
| 737 auto& label = generator_resume_points_[id]; |
| 738 resume_points_in_loop.push_back(label); |
| 739 generator_resume_points_[id] = BytecodeLabel(); |
| 740 } |
| 725 | 741 |
| 726 // Collect all labels for generator resume points within the loop (if any) so | 742 loop_builder->LoopHeader(&resume_points_in_loop); |
| 727 // that they can be bound to the loop header below. Also create fresh labels | |
| 728 // for these resume points, to be used inside the loop. | |
| 729 ZoneVector<BytecodeLabel> resume_points_in_loop(zone()); | |
| 730 size_t first_yield = stmt->first_yield_id(); | |
| 731 DCHECK_LE(first_yield + stmt->yield_count(), generator_resume_points_.size()); | |
| 732 for (size_t id = first_yield; id < first_yield + stmt->yield_count(); id++) { | |
| 733 auto& label = generator_resume_points_[id]; | |
| 734 resume_points_in_loop.push_back(label); | |
| 735 generator_resume_points_[id] = BytecodeLabel(); | |
| 736 } | |
| 737 | 743 |
| 738 loop_builder->LoopHeader(&resume_points_in_loop); | |
| 739 | |
| 740 if (stmt->yield_count() > 0) { | |
| 741 // If we are not resuming, fall through to loop body. | 744 // If we are not resuming, fall through to loop body. |
| 742 // If we are resuming, perform state dispatch. | 745 // If we are resuming, perform state dispatch. |
| 743 BytecodeLabel not_resuming; | 746 BytecodeLabel not_resuming; |
| 744 builder() | 747 builder() |
| 745 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) | 748 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) |
| 746 .CompareOperation(Token::Value::EQ, generator_state_) | 749 .CompareOperation(Token::Value::EQ, generator_state_) |
| 747 .JumpIfTrue(¬_resuming); | 750 .JumpIfTrue(¬_resuming); |
| 748 BuildIndexedJump(generator_state_, first_yield, | 751 BuildIndexedJump(generator_state_, first_yield, |
| 749 stmt->yield_count(), generator_resume_points_); | 752 stmt->yield_count(), generator_resume_points_); |
| 750 builder()->Bind(¬_resuming); | 753 builder()->Bind(¬_resuming); |
| (...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 } | 3199 } |
| 3197 | 3200 |
| 3198 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3201 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3199 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3202 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3200 : Runtime::kStoreKeyedToSuper_Sloppy; | 3203 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3201 } | 3204 } |
| 3202 | 3205 |
| 3203 } // namespace interpreter | 3206 } // namespace interpreter |
| 3204 } // namespace internal | 3207 } // namespace internal |
| 3205 } // namespace v8 | 3208 } // namespace v8 |
| OLD | NEW |