| 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/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/interpreter/bytecode-traits.h" | 10 #include "src/interpreter/bytecode-traits.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 const OperandSize* const Bytecodes::kOperandSizes[][3] = { | 50 const OperandSize* const Bytecodes::kOperandSizes[][3] = { |
| 51 #define ENTRY(Name, ...) \ | 51 #define ENTRY(Name, ...) \ |
| 52 { BytecodeTraits<__VA_ARGS__>::kSingleScaleOperandSizes, \ | 52 { BytecodeTraits<__VA_ARGS__>::kSingleScaleOperandSizes, \ |
| 53 BytecodeTraits<__VA_ARGS__>::kDoubleScaleOperandSizes, \ | 53 BytecodeTraits<__VA_ARGS__>::kDoubleScaleOperandSizes, \ |
| 54 BytecodeTraits<__VA_ARGS__>::kQuadrupleScaleOperandSizes }, | 54 BytecodeTraits<__VA_ARGS__>::kQuadrupleScaleOperandSizes }, |
| 55 BYTECODE_LIST(ENTRY) | 55 BYTECODE_LIST(ENTRY) |
| 56 #undef ENTRY | 56 #undef ENTRY |
| 57 }; | 57 }; |
| 58 | |
| 59 const OperandSize Bytecodes::kOperandKindSizes[][3] = { | |
| 60 #define ENTRY(Name, ...) \ | |
| 61 { OperandScaler<OperandType::k##Name, \ | |
| 62 OperandScale::kSingle>::kOperandSize, \ | |
| 63 OperandScaler<OperandType::k##Name, \ | |
| 64 OperandScale::kDouble>::kOperandSize, \ | |
| 65 OperandScaler<OperandType::k##Name, \ | |
| 66 OperandScale::kQuadruple>::kOperandSize }, | |
| 67 OPERAND_TYPE_LIST(ENTRY) | |
| 68 #undef ENTRY | |
| 69 }; | |
| 70 // clang-format on | 58 // clang-format on |
| 71 | 59 |
| 72 // static | 60 // static |
| 73 const char* Bytecodes::ToString(Bytecode bytecode) { | 61 const char* Bytecodes::ToString(Bytecode bytecode) { |
| 74 switch (bytecode) { | 62 switch (bytecode) { |
| 75 #define CASE(Name, ...) \ | 63 #define CASE(Name, ...) \ |
| 76 case Bytecode::k##Name: \ | 64 case Bytecode::k##Name: \ |
| 77 return #Name; | 65 return #Name; |
| 78 BYTECODE_LIST(CASE) | 66 BYTECODE_LIST(CASE) |
| 79 #undef CASE | 67 #undef CASE |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 #define CASE(Name, _) \ | 268 #define CASE(Name, _) \ |
| 281 case OperandType::k##Name: \ | 269 case OperandType::k##Name: \ |
| 282 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; | 270 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; |
| 283 OPERAND_TYPE_LIST(CASE) | 271 OPERAND_TYPE_LIST(CASE) |
| 284 #undef CASE | 272 #undef CASE |
| 285 } | 273 } |
| 286 UNREACHABLE(); | 274 UNREACHABLE(); |
| 287 } | 275 } |
| 288 | 276 |
| 289 // static | 277 // static |
| 278 OperandSize Bytecodes::SizeOfOperand(OperandType operand_type, |
| 279 OperandScale operand_scale) { |
| 280 DCHECK_LE(operand_type, OperandType::kLast); |
| 281 DCHECK_GE(operand_scale, OperandScale::kSingle); |
| 282 DCHECK_LE(operand_scale, OperandScale::kLast); |
| 283 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && |
| 284 OperandScale::kLast == OperandScale::kQuadruple); |
| 285 int scale_index = static_cast<int>(operand_scale) >> 1; |
| 286 // clang-format off |
| 287 static const OperandSize kOperandSizes[][3] = { |
| 288 #define ENTRY(Name, ...) \ |
| 289 { OperandScaler<OperandType::k##Name, \ |
| 290 OperandScale::kSingle>::kOperandSize, \ |
| 291 OperandScaler<OperandType::k##Name, \ |
| 292 OperandScale::kDouble>::kOperandSize, \ |
| 293 OperandScaler<OperandType::k##Name, \ |
| 294 OperandScale::kQuadruple>::kOperandSize }, |
| 295 OPERAND_TYPE_LIST(ENTRY) |
| 296 #undef ENTRY |
| 297 }; |
| 298 // clang-format on |
| 299 return kOperandSizes[static_cast<size_t>(operand_type)][scale_index]; |
| 300 } |
| 301 |
| 302 // static |
| 290 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, | 303 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, |
| 291 OperandScale operand_scale) { | 304 OperandScale operand_scale) { |
| 292 return operand_scale == OperandScale::kSingle || | 305 return operand_scale == OperandScale::kSingle || |
| 293 Bytecodes::IsBytecodeWithScalableOperands(bytecode); | 306 Bytecodes::IsBytecodeWithScalableOperands(bytecode); |
| 294 } | 307 } |
| 295 | 308 |
| 296 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 309 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
| 297 return os << Bytecodes::ToString(bytecode); | 310 return os << Bytecodes::ToString(bytecode); |
| 298 } | 311 } |
| 299 | 312 |
| 300 } // namespace interpreter | 313 } // namespace interpreter |
| 301 } // namespace internal | 314 } // namespace internal |
| 302 } // namespace v8 | 315 } // namespace v8 |
| OLD | NEW |