| 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" | |
| 11 | 10 |
| 12 namespace v8 { | 11 namespace v8 { |
| 13 namespace internal { | 12 namespace internal { |
| 14 namespace interpreter { | 13 namespace interpreter { |
| 15 | 14 |
| 16 // clang-format off | 15 // clang-format off |
| 17 const OperandType* const Bytecodes::kOperandTypes[] = { | 16 const OperandType* const Bytecodes::kOperandTypes[] = { |
| 18 #define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kOperandTypes, | 17 #define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kOperandTypes, |
| 19 BYTECODE_LIST(ENTRY) | 18 BYTECODE_LIST(ENTRY) |
| 20 #undef ENTRY | 19 #undef ENTRY |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 #define CASE(Name, _) \ | 267 #define CASE(Name, _) \ |
| 269 case OperandType::k##Name: \ | 268 case OperandType::k##Name: \ |
| 270 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; | 269 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; |
| 271 OPERAND_TYPE_LIST(CASE) | 270 OPERAND_TYPE_LIST(CASE) |
| 272 #undef CASE | 271 #undef CASE |
| 273 } | 272 } |
| 274 UNREACHABLE(); | 273 UNREACHABLE(); |
| 275 } | 274 } |
| 276 | 275 |
| 277 // static | 276 // 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 | |
| 303 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, | 277 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, |
| 304 OperandScale operand_scale) { | 278 OperandScale operand_scale) { |
| 305 return operand_scale == OperandScale::kSingle || | 279 return operand_scale == OperandScale::kSingle || |
| 306 Bytecodes::IsBytecodeWithScalableOperands(bytecode); | 280 Bytecodes::IsBytecodeWithScalableOperands(bytecode); |
| 307 } | 281 } |
| 308 | 282 |
| 309 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 283 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
| 310 return os << Bytecodes::ToString(bytecode); | 284 return os << Bytecodes::ToString(bytecode); |
| 311 } | 285 } |
| 312 | 286 |
| 313 } // namespace interpreter | 287 } // namespace interpreter |
| 314 } // namespace internal | 288 } // namespace internal |
| 315 } // namespace v8 | 289 } // namespace v8 |
| OLD | NEW |