Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 1200cacd0707baeb4b9dbaf7ffbb079fc94479ad..c325a8a0c807ddd545aca6b92e8a13b41cbc3196 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -722,22 +722,26 @@ void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, |
| LoopBuilder* loop_builder) { |
| // Recall that stmt->yield_count() is always zero inside ordinary |
| // (i.e. non-generator) functions. |
| + if (stmt->yield_count() == 0) { |
| + loop_builder->LoopHeader(); |
| + } else { |
| + // Collect all labels for generator resume points within the loop (if any) |
| + // so |
| + // that they can be bound to the loop header below. Also create fresh labels |
| + // for these resume points, to be used inside the loop. |
| + ZoneVector<BytecodeLabel> resume_points_in_loop(zone()); |
| + size_t first_yield = stmt->first_yield_id(); |
| + DCHECK_LE(first_yield + stmt->yield_count(), |
| + generator_resume_points_.size()); |
| + for (size_t id = first_yield; id < first_yield + stmt->yield_count(); |
| + id++) { |
| + auto& label = generator_resume_points_[id]; |
| + resume_points_in_loop.push_back(label); |
| + generator_resume_points_[id] = BytecodeLabel(); |
| + } |
| + |
| + loop_builder->LoopHeader(&resume_points_in_loop); |
|
rmcilroy
2016/11/28 10:00:31
Why did you need to change this code here?
Leszek Swirski
2016/11/28 11:07:22
Oh, this was a drive-by fix -- I had changed LoopB
|
| - // Collect all labels for generator resume points within the loop (if any) so |
| - // that they can be bound to the loop header below. Also create fresh labels |
| - // for these resume points, to be used inside the loop. |
| - ZoneVector<BytecodeLabel> resume_points_in_loop(zone()); |
| - size_t first_yield = stmt->first_yield_id(); |
| - DCHECK_LE(first_yield + stmt->yield_count(), generator_resume_points_.size()); |
| - for (size_t id = first_yield; id < first_yield + stmt->yield_count(); id++) { |
| - auto& label = generator_resume_points_[id]; |
| - resume_points_in_loop.push_back(label); |
| - generator_resume_points_[id] = BytecodeLabel(); |
| - } |
| - |
| - loop_builder->LoopHeader(&resume_points_in_loop); |
| - |
| - if (stmt->yield_count() > 0) { |
| // If we are not resuming, fall through to loop body. |
| // If we are resuming, perform state dispatch. |
| BytecodeLabel not_resuming; |