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 #ifndef V8_INTERPRETER_BYTECODES_H_ | 5 #ifndef V8_INTERPRETER_BYTECODES_H_ |
6 #define V8_INTERPRETER_BYTECODES_H_ | 6 #define V8_INTERPRETER_BYTECODES_H_ |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <string> | 10 #include <string> |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return 3; | 827 return 3; |
828 case OperandType::kRegList: | 828 case OperandType::kRegList: |
829 case OperandType::kRegOutList: | 829 case OperandType::kRegOutList: |
830 UNREACHABLE(); | 830 UNREACHABLE(); |
831 default: | 831 default: |
832 return 0; | 832 return 0; |
833 } | 833 } |
834 UNREACHABLE(); | 834 UNREACHABLE(); |
835 } | 835 } |
836 | 836 |
837 // Returns the size of |operand| for |operand_scale|. | 837 // Returns the size of |operand_type| for |operand_scale|. |
838 static OperandSize SizeOfOperand(OperandType operand, OperandScale scale); | 838 static OperandSize SizeOfOperand(OperandType operand_type, |
| 839 OperandScale operand_scale) { |
| 840 DCHECK_LE(operand_type, OperandType::kLast); |
| 841 DCHECK_GE(operand_scale, OperandScale::kSingle); |
| 842 DCHECK_LE(operand_scale, OperandScale::kLast); |
| 843 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && |
| 844 OperandScale::kLast == OperandScale::kQuadruple); |
| 845 int scale_index = static_cast<int>(operand_scale) >> 1; |
| 846 return kOperandKindSizes[static_cast<size_t>(operand_type)][scale_index]; |
| 847 } |
839 | 848 |
840 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId). | 849 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId). |
841 static bool IsRuntimeIdOperandType(OperandType operand_type); | 850 static bool IsRuntimeIdOperandType(OperandType operand_type); |
842 | 851 |
843 // Returns true if |operand_type| is unsigned, false if signed. | 852 // Returns true if |operand_type| is unsigned, false if signed. |
844 static bool IsUnsignedOperandType(OperandType operand_type); | 853 static bool IsUnsignedOperandType(OperandType operand_type); |
845 | 854 |
846 // Returns true if a handler is generated for a bytecode at a given | 855 // Returns true if a handler is generated for a bytecode at a given |
847 // operand scale. All bytecodes have handlers at OperandScale::kSingle, | 856 // operand scale. All bytecodes have handlers at OperandScale::kSingle, |
848 // but only bytecodes with scalable operands have handlers with larger | 857 // but only bytecodes with scalable operands have handlers with larger |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 893 |
885 private: | 894 private: |
886 static const OperandType* const kOperandTypes[]; | 895 static const OperandType* const kOperandTypes[]; |
887 static const OperandTypeInfo* const kOperandTypeInfos[]; | 896 static const OperandTypeInfo* const kOperandTypeInfos[]; |
888 static const int kOperandCount[]; | 897 static const int kOperandCount[]; |
889 static const int kNumberOfRegisterOperands[]; | 898 static const int kNumberOfRegisterOperands[]; |
890 static const AccumulatorUse kAccumulatorUse[]; | 899 static const AccumulatorUse kAccumulatorUse[]; |
891 static const bool kIsScalable[]; | 900 static const bool kIsScalable[]; |
892 static const int kBytecodeSizes[][3]; | 901 static const int kBytecodeSizes[][3]; |
893 static const OperandSize* const kOperandSizes[][3]; | 902 static const OperandSize* const kOperandSizes[][3]; |
| 903 static OperandSize const kOperandKindSizes[][3]; |
894 }; | 904 }; |
895 | 905 |
896 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 906 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
897 const Bytecode& bytecode); | 907 const Bytecode& bytecode); |
898 | 908 |
899 } // namespace interpreter | 909 } // namespace interpreter |
900 } // namespace internal | 910 } // namespace internal |
901 } // namespace v8 | 911 } // namespace v8 |
902 | 912 |
903 #endif // V8_INTERPRETER_BYTECODES_H_ | 913 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |