Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "src/globals.h" | 12 #include "src/globals.h" |
| 13 #include "src/interpreter/bytecode-operands.h" | 13 #include "src/interpreter/bytecode-operands.h" |
| 14 #include "src/interpreter/bytecode-traits.h" | |
|
rmcilroy
2017/06/20 23:20:32
I'd prefer not to expose bytecode-traits in byteco
hans
2017/06/20 23:49:08
Sounds good to me. There already is a kOperandSize
| |
| 14 | 15 |
| 15 // This interface and it's implementation are independent of the | 16 // This interface and it's implementation are independent of the |
| 16 // libv8_base library as they are used by the interpreter and the | 17 // libv8_base library as they are used by the interpreter and the |
| 17 // standalone mkpeephole table generator program. | 18 // standalone mkpeephole table generator program. |
| 18 | 19 |
| 19 namespace v8 { | 20 namespace v8 { |
| 20 namespace internal { | 21 namespace internal { |
| 21 namespace interpreter { | 22 namespace interpreter { |
| 22 | 23 |
| 23 // The list of bytecodes which are interpreted by the interpreter. | 24 // The list of bytecodes which are interpreted by the interpreter. |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 return 3; | 828 return 3; |
| 828 case OperandType::kRegList: | 829 case OperandType::kRegList: |
| 829 case OperandType::kRegOutList: | 830 case OperandType::kRegOutList: |
| 830 UNREACHABLE(); | 831 UNREACHABLE(); |
| 831 default: | 832 default: |
| 832 return 0; | 833 return 0; |
| 833 } | 834 } |
| 834 UNREACHABLE(); | 835 UNREACHABLE(); |
| 835 } | 836 } |
| 836 | 837 |
| 837 // Returns the size of |operand| for |operand_scale|. | 838 // Returns the size of |operand_type| for |operand_scale|. |
| 838 static OperandSize SizeOfOperand(OperandType operand, OperandScale scale); | 839 static OperandSize SizeOfOperand(OperandType operand_type, |
| 840 OperandScale operand_scale) { | |
| 841 DCHECK_LE(operand_type, OperandType::kLast); | |
| 842 DCHECK_GE(operand_scale, OperandScale::kSingle); | |
| 843 DCHECK_LE(operand_scale, OperandScale::kLast); | |
| 844 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && | |
| 845 OperandScale::kLast == OperandScale::kQuadruple); | |
| 846 int scale_index = static_cast<int>(operand_scale) >> 1; | |
| 847 // clang-format off | |
| 848 static const OperandSize kOperandSizes[][3] = { | |
| 849 #define ENTRY(Name, ...) \ | |
| 850 { OperandScaler<OperandType::k##Name, \ | |
| 851 OperandScale::kSingle>::kOperandSize, \ | |
| 852 OperandScaler<OperandType::k##Name, \ | |
| 853 OperandScale::kDouble>::kOperandSize, \ | |
| 854 OperandScaler<OperandType::k##Name, \ | |
| 855 OperandScale::kQuadruple>::kOperandSize }, | |
| 856 OPERAND_TYPE_LIST(ENTRY) | |
| 857 #undef ENTRY | |
| 858 }; | |
| 859 // clang-format on | |
| 860 return kOperandSizes[static_cast<size_t>(operand_type)][scale_index]; | |
| 861 } | |
| 839 | 862 |
| 840 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId). | 863 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId). |
| 841 static bool IsRuntimeIdOperandType(OperandType operand_type); | 864 static bool IsRuntimeIdOperandType(OperandType operand_type); |
| 842 | 865 |
| 843 // Returns true if |operand_type| is unsigned, false if signed. | 866 // Returns true if |operand_type| is unsigned, false if signed. |
| 844 static bool IsUnsignedOperandType(OperandType operand_type); | 867 static bool IsUnsignedOperandType(OperandType operand_type); |
| 845 | 868 |
| 846 // Returns true if a handler is generated for a bytecode at a given | 869 // Returns true if a handler is generated for a bytecode at a given |
| 847 // operand scale. All bytecodes have handlers at OperandScale::kSingle, | 870 // operand scale. All bytecodes have handlers at OperandScale::kSingle, |
| 848 // but only bytecodes with scalable operands have handlers with larger | 871 // but only bytecodes with scalable operands have handlers with larger |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 }; | 917 }; |
| 895 | 918 |
| 896 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 919 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 897 const Bytecode& bytecode); | 920 const Bytecode& bytecode); |
| 898 | 921 |
| 899 } // namespace interpreter | 922 } // namespace interpreter |
| 900 } // namespace internal | 923 } // namespace internal |
| 901 } // namespace v8 | 924 } // namespace v8 |
| 902 | 925 |
| 903 #endif // V8_INTERPRETER_BYTECODES_H_ | 926 #endif // V8_INTERPRETER_BYTECODES_H_ |
| OLD | NEW |