| 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/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
| 10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 builder() | 637 builder() |
| 638 ->LoadAccumulatorWithRegister(Register::new_target()) | 638 ->LoadAccumulatorWithRegister(Register::new_target()) |
| 639 .JumpIfUndefined(®ular_call); | 639 .JumpIfUndefined(®ular_call); |
| 640 | 640 |
| 641 // This is a resume call. Restore registers and perform state dispatch. | 641 // This is a resume call. Restore registers and perform state dispatch. |
| 642 // (The current context has already been restored by the trampoline.) | 642 // (The current context has already been restored by the trampoline.) |
| 643 { | 643 { |
| 644 RegisterAllocationScope register_scope(this); | 644 RegisterAllocationScope register_scope(this); |
| 645 Register state = register_allocator()->NewRegister(); | 645 Register state = register_allocator()->NewRegister(); |
| 646 builder() | 646 builder() |
| 647 ->CallRuntime(Runtime::kResumeIgnitionGenerator, Register::new_target(), | 647 ->ResumeGenerator(Register::new_target()) |
| 648 1) | |
| 649 .StoreAccumulatorInRegister(state); | 648 .StoreAccumulatorInRegister(state); |
| 650 | 649 |
| 651 // TODO(neis): Optimize this by using a proper jump table. | 650 // TODO(neis): Optimize this by using a proper jump table. |
| 652 for (size_t i = 0; i < generator_resume_points_.size(); ++i) { | 651 for (size_t i = 0; i < generator_resume_points_.size(); ++i) { |
| 653 builder() | 652 builder() |
| 654 ->LoadLiteral(Smi::FromInt(static_cast<int>(i))) | 653 ->LoadLiteral(Smi::FromInt(static_cast<int>(i))) |
| 655 .CompareOperation(Token::Value::EQ_STRICT, state) | 654 .CompareOperation(Token::Value::EQ_STRICT, state) |
| 656 .JumpIfTrue(&(generator_resume_points_[i])); | 655 .JumpIfTrue(&(generator_resume_points_[i])); |
| 657 } | 656 } |
| 658 builder()->Illegal(); // Should never get here. | 657 builder()->Illegal(); // Should never get here. |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 } | 2210 } |
| 2212 execution_result()->SetResultInAccumulator(); | 2211 execution_result()->SetResultInAccumulator(); |
| 2213 } | 2212 } |
| 2214 | 2213 |
| 2215 void BytecodeGenerator::VisitYield(Yield* expr) { | 2214 void BytecodeGenerator::VisitYield(Yield* expr) { |
| 2216 int id = generator_yields_seen_++; | 2215 int id = generator_yields_seen_++; |
| 2217 | 2216 |
| 2218 builder()->SetExpressionPosition(expr); | 2217 builder()->SetExpressionPosition(expr); |
| 2219 Register value = VisitForRegisterValue(expr->expression()); | 2218 Register value = VisitForRegisterValue(expr->expression()); |
| 2220 | 2219 |
| 2221 register_allocator()->PrepareForConsecutiveAllocations(2); | 2220 Register generator = VisitForRegisterValue(expr->generator_object()); |
| 2222 Register generator = register_allocator()->NextConsecutiveRegister(); | |
| 2223 Register state = register_allocator()->NextConsecutiveRegister(); | |
| 2224 | 2221 |
| 2225 // Save context, registers, and state. Then return. | 2222 // Save context, registers, and state. Then return. |
| 2226 VisitForRegisterValue(expr->generator_object(), generator); | |
| 2227 builder() | 2223 builder() |
| 2228 ->LoadLiteral(Smi::FromInt(id)) | 2224 ->LoadLiteral(Smi::FromInt(id)) |
| 2229 .StoreAccumulatorInRegister(state) | 2225 .SuspendGenerator(generator) |
| 2230 .CallRuntime(Runtime::kSuspendIgnitionGenerator, generator, 2) | |
| 2231 .LoadAccumulatorWithRegister(value) | 2226 .LoadAccumulatorWithRegister(value) |
| 2232 .Return(); // Hard return (ignore any finally blocks). | 2227 .Return(); // Hard return (ignore any finally blocks). |
| 2233 | 2228 |
| 2234 builder()->Bind(&(generator_resume_points_[id])); | 2229 builder()->Bind(&(generator_resume_points_[id])); |
| 2235 // Upon resume, we continue here. | 2230 // Upon resume, we continue here. |
| 2236 | 2231 |
| 2237 { | 2232 { |
| 2238 RegisterAllocationScope register_scope(this); | 2233 RegisterAllocationScope register_scope(this); |
| 2239 | 2234 |
| 2240 Register input = register_allocator()->NewRegister(); | 2235 Register input = register_allocator()->NewRegister(); |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 } | 3212 } |
| 3218 | 3213 |
| 3219 | 3214 |
| 3220 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3215 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3221 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3216 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
| 3222 } | 3217 } |
| 3223 | 3218 |
| 3224 } // namespace interpreter | 3219 } // namespace interpreter |
| 3225 } // namespace internal | 3220 } // namespace internal |
| 3226 } // namespace v8 | 3221 } // namespace v8 |
| OLD | NEW |