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 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 RegisterAllocationScope register_scope(this); | 2291 RegisterAllocationScope register_scope(this); |
2292 | 2292 |
2293 // Update state to indicate that we have finished resuming. Loop headers | 2293 // Update state to indicate that we have finished resuming. Loop headers |
2294 // rely on this. | 2294 // rely on this. |
2295 builder() | 2295 builder() |
2296 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) | 2296 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) |
2297 .StoreAccumulatorInRegister(generator_state_); | 2297 .StoreAccumulatorInRegister(generator_state_); |
2298 | 2298 |
2299 Register input = register_allocator()->NewRegister(); | 2299 Register input = register_allocator()->NewRegister(); |
2300 builder() | 2300 builder() |
2301 ->CallRuntime(Runtime::kGeneratorGetInput, generator, 1) | 2301 ->CallRuntime(Runtime::kInlineGeneratorGetInput, generator, 1) |
2302 .StoreAccumulatorInRegister(input); | 2302 .StoreAccumulatorInRegister(input); |
2303 | 2303 |
2304 Register resume_mode = register_allocator()->NewRegister(); | 2304 Register resume_mode = register_allocator()->NewRegister(); |
2305 builder() | 2305 builder() |
2306 ->CallRuntime(Runtime::kGeneratorGetResumeMode, generator, 1) | 2306 ->CallRuntime(Runtime::kInlineGeneratorGetResumeMode, generator, 1) |
2307 .StoreAccumulatorInRegister(resume_mode); | 2307 .StoreAccumulatorInRegister(resume_mode); |
2308 | 2308 |
2309 // Now dispatch on resume mode. | 2309 // Now dispatch on resume mode. |
2310 | 2310 |
2311 BytecodeLabel resume_with_next; | 2311 BytecodeLabel resume_with_next; |
2312 BytecodeLabel resume_with_return; | 2312 BytecodeLabel resume_with_return; |
2313 BytecodeLabel resume_with_throw; | 2313 BytecodeLabel resume_with_throw; |
2314 | 2314 |
2315 builder() | 2315 builder() |
2316 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kNext)) | 2316 ->LoadLiteral(Smi::FromInt(JSGeneratorObject::kNext)) |
2317 .CompareOperation(Token::EQ_STRICT, resume_mode) | 2317 .CompareOperation(Token::EQ_STRICT, resume_mode) |
2318 .JumpIfTrue(&resume_with_next) | 2318 .JumpIfTrue(&resume_with_next) |
2319 .LoadLiteral(Smi::FromInt(JSGeneratorObject::kThrow)) | 2319 .LoadLiteral(Smi::FromInt(JSGeneratorObject::kThrow)) |
2320 .CompareOperation(Token::EQ_STRICT, resume_mode) | 2320 .CompareOperation(Token::EQ_STRICT, resume_mode) |
2321 .JumpIfTrue(&resume_with_throw) | 2321 .JumpIfTrue(&resume_with_throw) |
2322 .Jump(&resume_with_return); | 2322 .Jump(&resume_with_return); |
2323 | 2323 |
2324 builder()->Bind(&resume_with_return); | 2324 builder()->Bind(&resume_with_return); |
2325 { | 2325 { |
2326 register_allocator()->PrepareForConsecutiveAllocations(2); | 2326 register_allocator()->PrepareForConsecutiveAllocations(2); |
2327 Register value = register_allocator()->NextConsecutiveRegister(); | 2327 Register value = register_allocator()->NextConsecutiveRegister(); |
2328 Register done = register_allocator()->NextConsecutiveRegister(); | 2328 Register done = register_allocator()->NextConsecutiveRegister(); |
2329 builder() | 2329 builder() |
2330 ->MoveRegister(input, value) | 2330 ->MoveRegister(input, value) |
2331 .LoadTrue() | 2331 .LoadTrue() |
2332 .StoreAccumulatorInRegister(done) | 2332 .StoreAccumulatorInRegister(done) |
2333 .CallRuntime(Runtime::kCreateIterResultObject, value, 2); | 2333 .CallRuntime(Runtime::kInlineCreateIterResultObject, value, 2); |
2334 execution_control()->ReturnAccumulator(); | 2334 execution_control()->ReturnAccumulator(); |
2335 } | 2335 } |
2336 | 2336 |
2337 builder()->Bind(&resume_with_throw); | 2337 builder()->Bind(&resume_with_throw); |
2338 builder() | 2338 builder() |
2339 ->LoadAccumulatorWithRegister(input) | 2339 ->LoadAccumulatorWithRegister(input) |
2340 .Throw(); | 2340 .Throw(); |
2341 | 2341 |
2342 builder()->Bind(&resume_with_next); | 2342 builder()->Bind(&resume_with_next); |
2343 builder()->LoadAccumulatorWithRegister(input); | 2343 builder()->LoadAccumulatorWithRegister(input); |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3275 } | 3275 } |
3276 | 3276 |
3277 | 3277 |
3278 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3278 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3279 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3279 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
3280 } | 3280 } |
3281 | 3281 |
3282 } // namespace interpreter | 3282 } // namespace interpreter |
3283 } // namespace internal | 3283 } // namespace internal |
3284 } // namespace v8 | 3284 } // namespace v8 |
OLD | NEW |