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-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 } else { | 775 } else { |
776 UNIMPLEMENTED(); | 776 UNIMPLEMENTED(); |
777 } | 777 } |
778 return *this; | 778 return *this; |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, | 782 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, |
783 Register first_arg, | 783 Register first_arg, |
784 size_t arg_count) { | 784 size_t arg_count) { |
| 785 if (!first_arg.is_valid()) { |
| 786 DCHECK_EQ(0, arg_count); |
| 787 first_arg = Register(0); |
| 788 } |
785 DCHECK(FitsInIdx8Operand(arg_count)); | 789 DCHECK(FitsInIdx8Operand(arg_count)); |
786 Output(Bytecode::kNew, constructor.ToOperand(), first_arg.ToOperand(), | 790 Output(Bytecode::kNew, constructor.ToOperand(), first_arg.ToOperand(), |
787 static_cast<uint8_t>(arg_count)); | 791 static_cast<uint8_t>(arg_count)); |
788 return *this; | 792 return *this; |
789 } | 793 } |
790 | 794 |
791 | 795 |
792 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 796 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
793 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 797 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
794 DCHECK(FitsInIdx16Operand(function_id)); | 798 DCHECK(FitsInIdx16Operand(function_id)); |
795 DCHECK(FitsInIdx8Operand(arg_count)); | 799 DCHECK(FitsInIdx8Operand(arg_count)); |
| 800 if (!first_arg.is_valid()) { |
| 801 DCHECK_EQ(0, arg_count); |
| 802 first_arg = Register(0); |
| 803 } |
796 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), | 804 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), |
797 first_arg.ToOperand(), static_cast<uint8_t>(arg_count)); | 805 first_arg.ToOperand(), static_cast<uint8_t>(arg_count)); |
798 return *this; | 806 return *this; |
799 } | 807 } |
800 | 808 |
801 | 809 |
| 810 BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index, |
| 811 Register receiver, |
| 812 size_t arg_count) { |
| 813 DCHECK(FitsInIdx16Operand(context_index)); |
| 814 DCHECK(FitsInIdx8Operand(arg_count)); |
| 815 Output(Bytecode::kCallJSRuntime, static_cast<uint16_t>(context_index), |
| 816 receiver.ToOperand(), static_cast<uint8_t>(arg_count)); |
| 817 return *this; |
| 818 } |
| 819 |
| 820 |
802 BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object, | 821 BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object, |
803 LanguageMode language_mode) { | 822 LanguageMode language_mode) { |
804 Output(BytecodeForDelete(language_mode), object.ToOperand()); | 823 Output(BytecodeForDelete(language_mode), object.ToOperand()); |
805 return *this; | 824 return *this; |
806 } | 825 } |
807 | 826 |
808 | 827 |
809 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 828 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
810 // These constants shouldn't be added to the constant pool, the should use | 829 // These constants shouldn't be added to the constant pool, the should use |
811 // specialzed bytecodes instead. | 830 // specialzed bytecodes instead. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); | 922 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); |
904 switch (operand_type) { | 923 switch (operand_type) { |
905 case OperandType::kNone: | 924 case OperandType::kNone: |
906 return false; | 925 return false; |
907 case OperandType::kIdx16: | 926 case OperandType::kIdx16: |
908 return static_cast<uint16_t>(operand_value) == operand_value; | 927 return static_cast<uint16_t>(operand_value) == operand_value; |
909 case OperandType::kCount8: | 928 case OperandType::kCount8: |
910 case OperandType::kImm8: | 929 case OperandType::kImm8: |
911 case OperandType::kIdx8: | 930 case OperandType::kIdx8: |
912 return static_cast<uint8_t>(operand_value) == operand_value; | 931 return static_cast<uint8_t>(operand_value) == operand_value; |
| 932 case OperandType::kMaybeReg8: |
| 933 if (operand_value == 0) { |
| 934 return true; |
| 935 } |
| 936 // Fall-through to kReg8 case. |
913 case OperandType::kReg8: { | 937 case OperandType::kReg8: { |
914 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value)); | 938 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value)); |
915 if (reg.is_function_context() || reg.is_function_closure()) { | 939 if (reg.is_function_context() || reg.is_function_closure()) { |
916 return true; | 940 return true; |
917 } else if (reg.is_parameter()) { | 941 } else if (reg.is_parameter()) { |
918 int parameter_index = reg.ToParameterIndex(parameter_count_); | 942 int parameter_index = reg.ToParameterIndex(parameter_count_); |
919 return parameter_index >= 0 && parameter_index < parameter_count_; | 943 return parameter_index >= 0 && parameter_index < parameter_count_; |
920 } else if (reg.index() < fixed_register_count()) { | 944 } else if (reg.index() < fixed_register_count()) { |
921 return true; | 945 return true; |
922 } else { | 946 } else { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 DCHECK_GT(next_consecutive_count_, 0); | 1282 DCHECK_GT(next_consecutive_count_, 0); |
1259 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1283 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
1260 allocated_.push_back(next_consecutive_register_); | 1284 allocated_.push_back(next_consecutive_register_); |
1261 next_consecutive_count_--; | 1285 next_consecutive_count_--; |
1262 return Register(next_consecutive_register_++); | 1286 return Register(next_consecutive_register_++); |
1263 } | 1287 } |
1264 | 1288 |
1265 } // namespace interpreter | 1289 } // namespace interpreter |
1266 } // namespace internal | 1290 } // namespace internal |
1267 } // namespace v8 | 1291 } // namespace v8 |
OLD | NEW |