| 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-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 size_t first_yield = stmt->first_yield_id(); | 707 size_t first_yield = stmt->first_yield_id(); |
| 708 DCHECK_LE(first_yield + stmt->yield_count(), generator_resume_points_.size()); | 708 DCHECK_LE(first_yield + stmt->yield_count(), generator_resume_points_.size()); |
| 709 for (size_t id = first_yield; id < first_yield + stmt->yield_count(); id++) { | 709 for (size_t id = first_yield; id < first_yield + stmt->yield_count(); id++) { |
| 710 auto& label = generator_resume_points_[id]; | 710 auto& label = generator_resume_points_[id]; |
| 711 resume_points_in_loop.push_back(label); | 711 resume_points_in_loop.push_back(label); |
| 712 generator_resume_points_[id] = BytecodeLabel(); | 712 generator_resume_points_[id] = BytecodeLabel(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 loop_builder->LoopHeader(&resume_points_in_loop); | 715 loop_builder->LoopHeader(&resume_points_in_loop); |
| 716 | 716 |
| 717 // Insert an explicit {OsrPoll} right after the loop header, to trigger | |
| 718 // on-stack replacement when armed for the given loop nesting depth. | |
| 719 if (FLAG_ignition_osr) { | |
| 720 // TODO(4764): Merge this with another bytecode (e.g. {Jump} back edge). | |
| 721 // TODO(4764): Investigate interaction with generators. | |
| 722 // TODO(4764): Track and pass correct loop depth. | |
| 723 DCHECK_EQ(0, stmt->yield_count()); | |
| 724 builder()->OsrPoll(0); | |
| 725 } | |
| 726 | |
| 727 if (stmt->yield_count() > 0) { | 717 if (stmt->yield_count() > 0) { |
| 728 // If we are not resuming, fall through to loop body. | 718 // If we are not resuming, fall through to loop body. |
| 729 // If we are resuming, perform state dispatch. | 719 // If we are resuming, perform state dispatch. |
| 730 BytecodeLabel not_resuming; | 720 BytecodeLabel not_resuming; |
| 731 builder() | 721 builder() |
| 732 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) | 722 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) |
| 733 .CompareOperation(Token::Value::EQ, generator_state_) | 723 .CompareOperation(Token::Value::EQ, generator_state_) |
| 734 .JumpIfTrue(¬_resuming); | 724 .JumpIfTrue(¬_resuming); |
| 735 BuildIndexedJump(generator_state_, first_yield, | 725 BuildIndexedJump(generator_state_, first_yield, |
| 736 stmt->yield_count(), generator_resume_points_); | 726 stmt->yield_count(), generator_resume_points_); |
| (...skipping 2500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3237 return execution_context()->scope()->language_mode(); | 3227 return execution_context()->scope()->language_mode(); |
| 3238 } | 3228 } |
| 3239 | 3229 |
| 3240 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3230 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3241 return TypeFeedbackVector::GetIndex(slot); | 3231 return TypeFeedbackVector::GetIndex(slot); |
| 3242 } | 3232 } |
| 3243 | 3233 |
| 3244 } // namespace interpreter | 3234 } // namespace interpreter |
| 3245 } // namespace internal | 3235 } // namespace internal |
| 3246 } // namespace v8 | 3236 } // namespace v8 |
| OLD | NEW |