Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/interpreter-generator.h" | 5 #include "src/interpreter/interpreter-generator.h" |
| 6 | 6 |
| 7 #include <array> | 7 #include <array> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "src/builtins/builtins-arguments-gen.h" | 10 #include "src/builtins/builtins-arguments-gen.h" |
| (...skipping 3594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3605 // Illegal | 3605 // Illegal |
| 3606 // | 3606 // |
| 3607 // An invalid bytecode aborting execution if dispatched. | 3607 // An invalid bytecode aborting execution if dispatched. |
| 3608 IGNITION_HANDLER(Illegal, InterpreterAssembler) { Abort(kInvalidBytecode); } | 3608 IGNITION_HANDLER(Illegal, InterpreterAssembler) { Abort(kInvalidBytecode); } |
| 3609 | 3609 |
| 3610 // Nop | 3610 // Nop |
| 3611 // | 3611 // |
| 3612 // No operation. | 3612 // No operation. |
| 3613 IGNITION_HANDLER(Nop, InterpreterAssembler) { Dispatch(); } | 3613 IGNITION_HANDLER(Nop, InterpreterAssembler) { Dispatch(); } |
| 3614 | 3614 |
| 3615 // SuspendGenerator <generator> | 3615 // SuspendGenerator <generator> <input-register-list> <flags> |
|
rmcilroy
2017/06/01 10:44:44
nit - <input-register-list> -> <first input regist
Jarin
2017/06/01 12:48:22
Done.
| |
| 3616 // | 3616 // |
| 3617 // Exports the register file and stores it into the generator. Also stores the | 3617 // Exports the register file and stores it into the generator. Also stores the |
| 3618 // current context, the state given in the accumulator, and the current bytecode | 3618 // current context, the state given in the accumulator, and the current bytecode |
| 3619 // offset (for debugging purposes) into the generator. | 3619 // offset (for debugging purposes) into the generator. |
| 3620 IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) { | 3620 IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) { |
| 3621 Node* generator_reg = BytecodeOperandReg(0); | 3621 Node* generator_reg = BytecodeOperandReg(0); |
| 3622 Node* flags = BytecodeOperandFlag(1); | 3622 Node* flags = BytecodeOperandFlag(3); |
| 3623 | |
| 3623 Node* generator = LoadRegister(generator_reg); | 3624 Node* generator = LoadRegister(generator_reg); |
| 3624 | 3625 |
| 3625 Label if_stepping(this, Label::kDeferred), ok(this); | 3626 Label if_stepping(this, Label::kDeferred), ok(this); |
| 3626 Node* step_action_address = ExternalConstant( | 3627 Node* step_action_address = ExternalConstant( |
| 3627 ExternalReference::debug_last_step_action_address(isolate())); | 3628 ExternalReference::debug_last_step_action_address(isolate())); |
| 3628 Node* step_action = Load(MachineType::Int8(), step_action_address); | 3629 Node* step_action = Load(MachineType::Int8(), step_action_address); |
| 3629 STATIC_ASSERT(StepIn > StepNext); | 3630 STATIC_ASSERT(StepIn > StepNext); |
| 3630 STATIC_ASSERT(LastStepAction == StepIn); | 3631 STATIC_ASSERT(LastStepAction == StepIn); |
| 3631 Node* step_next = Int32Constant(StepNext); | 3632 Node* step_next = Int32Constant(StepNext); |
| 3632 Branch(Int32LessThanOrEqual(step_next, step_action), &if_stepping, &ok); | 3633 Branch(Int32LessThanOrEqual(step_next, step_action), &if_stepping, &ok); |
| 3633 BIND(&ok); | 3634 BIND(&ok); |
| 3634 | 3635 |
| 3635 Node* array = | 3636 Node* array = |
| 3636 LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset); | 3637 LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset); |
| 3637 Node* context = GetContext(); | 3638 Node* context = GetContext(); |
| 3638 Node* state = GetAccumulator(); | 3639 Node* state = GetAccumulator(); |
| 3639 | 3640 |
| 3640 ExportRegisterFile(array); | 3641 // Bytecode operand 2 is the number of registers to store to the generator. |
|
rmcilroy
2017/06/01 10:44:44
You don't ever check operand 1 - could you add a C
Jarin
2017/06/01 12:48:22
Done.
| |
| 3642 Node* register_count = ChangeUint32ToWord(BytecodeOperandCount(2)); | |
| 3643 ExportRegisterFile(array, register_count); | |
| 3641 StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); | 3644 StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); |
| 3642 StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); | 3645 StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); |
| 3643 | 3646 |
| 3644 Label if_asyncgeneratorawait(this), if_notasyncgeneratorawait(this), | 3647 Label if_asyncgeneratorawait(this), if_notasyncgeneratorawait(this), |
| 3645 merge(this); | 3648 merge(this); |
| 3646 | 3649 |
| 3647 // Calculate bytecode offset to store in the [input_or_debug_pos] or | 3650 // Calculate bytecode offset to store in the [input_or_debug_pos] or |
| 3648 // [await_input_or_debug_pos] fields, to be used by the inspector. | 3651 // [await_input_or_debug_pos] fields, to be used by the inspector. |
| 3649 Node* offset = SmiTag(BytecodeOffset()); | 3652 Node* offset = SmiTag(BytecodeOffset()); |
| 3650 | 3653 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3681 BIND(&if_stepping); | 3684 BIND(&if_stepping); |
| 3682 { | 3685 { |
| 3683 Node* context = GetContext(); | 3686 Node* context = GetContext(); |
| 3684 CallRuntime(Runtime::kDebugRecordGenerator, context, generator); | 3687 CallRuntime(Runtime::kDebugRecordGenerator, context, generator); |
| 3685 Goto(&ok); | 3688 Goto(&ok); |
| 3686 } | 3689 } |
| 3687 } | 3690 } |
| 3688 | 3691 |
| 3689 // ResumeGenerator <generator> | 3692 // ResumeGenerator <generator> |
| 3690 // | 3693 // |
| 3691 // Imports the register file stored in the generator. Also loads the | 3694 // Loads the generator's state and stores it in the accumulator, |
| 3692 // generator's state and stores it in the accumulator, before overwriting it | 3695 // before overwriting it with kGeneratorExecuting. |
| 3693 // with kGeneratorExecuting. | |
| 3694 IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) { | 3696 IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) { |
| 3695 Node* generator_reg = BytecodeOperandReg(0); | 3697 Node* generator_reg = BytecodeOperandReg(0); |
| 3696 Node* generator = LoadRegister(generator_reg); | 3698 Node* generator = LoadRegister(generator_reg); |
| 3697 | 3699 |
| 3698 ImportRegisterFile( | |
| 3699 LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset)); | |
| 3700 | |
| 3701 Node* old_state = | 3700 Node* old_state = |
| 3702 LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); | 3701 LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); |
| 3703 Node* new_state = Int32Constant(JSGeneratorObject::kGeneratorExecuting); | 3702 Node* new_state = Int32Constant(JSGeneratorObject::kGeneratorExecuting); |
| 3704 StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 3703 StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 3705 SmiTag(new_state)); | 3704 SmiTag(new_state)); |
| 3706 SetAccumulator(old_state); | 3705 SetAccumulator(old_state); |
| 3707 | 3706 |
| 3708 Dispatch(); | 3707 Dispatch(); |
| 3709 } | 3708 } |
| 3710 | 3709 |
| 3710 // RestoreGeneratorRegisters <generator> <output-register-list> | |
|
rmcilroy
2017/06/01 10:44:44
nit - <output-register-list> -> <first output regi
Jarin
2017/06/01 12:48:22
Done.
| |
| 3711 // | |
| 3712 // Imports the register file stored in the generator. | |
| 3713 IGNITION_HANDLER(RestoreGeneratorRegisters, InterpreterAssembler) { | |
| 3714 Node* generator_reg = BytecodeOperandReg(0); | |
| 3715 // Bytecode operand 1 is the start register. It should always be 0, so let's | |
| 3716 // ignore it. | |
|
rmcilroy
2017/06/01 10:44:44
Please add a CSA assert
Jarin
2017/06/01 12:48:22
Done.
| |
| 3717 // Bytecode operand 2 is the number of registers to store to the generator. | |
| 3718 Node* register_count = ChangeUint32ToWord(BytecodeOperandCount(2)); | |
| 3719 | |
| 3720 Node* generator = LoadRegister(generator_reg); | |
| 3721 | |
| 3722 ImportRegisterFile( | |
| 3723 LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset), | |
| 3724 register_count); | |
| 3725 SetAccumulator(generator); | |
| 3726 | |
| 3727 Dispatch(); | |
| 3728 } | |
| 3729 | |
| 3711 } // namespace | 3730 } // namespace |
| 3712 | 3731 |
| 3713 Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode, | 3732 Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode, |
| 3714 OperandScale operand_scale) { | 3733 OperandScale operand_scale) { |
| 3715 Zone zone(isolate->allocator(), ZONE_NAME); | 3734 Zone zone(isolate->allocator(), ZONE_NAME); |
| 3716 InterpreterDispatchDescriptor descriptor(isolate); | 3735 InterpreterDispatchDescriptor descriptor(isolate); |
| 3717 compiler::CodeAssemblerState state( | 3736 compiler::CodeAssemblerState state( |
| 3718 isolate, &zone, descriptor, Code::ComputeFlags(Code::BYTECODE_HANDLER), | 3737 isolate, &zone, descriptor, Code::ComputeFlags(Code::BYTECODE_HANDLER), |
| 3719 Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode)); | 3738 Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode)); |
| 3720 | 3739 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3738 code->Disassemble(Bytecodes::ToString(bytecode), os); | 3757 code->Disassemble(Bytecodes::ToString(bytecode), os); |
| 3739 os << std::flush; | 3758 os << std::flush; |
| 3740 } | 3759 } |
| 3741 #endif // ENABLE_DISASSEMBLER | 3760 #endif // ENABLE_DISASSEMBLER |
| 3742 return code; | 3761 return code; |
| 3743 } | 3762 } |
| 3744 | 3763 |
| 3745 } // namespace interpreter | 3764 } // namespace interpreter |
| 3746 } // namespace internal | 3765 } // namespace internal |
| 3747 } // namespace v8 | 3766 } // namespace v8 |
| OLD | NEW |