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 }; |
58 // clang-format on | 70 // clang-format on |
59 | 71 |
60 // static | 72 // static |
61 const char* Bytecodes::ToString(Bytecode bytecode) { | 73 const char* Bytecodes::ToString(Bytecode bytecode) { |
62 switch (bytecode) { | 74 switch (bytecode) { |
63 #define CASE(Name, ...) \ | 75 #define CASE(Name, ...) \ |
64 case Bytecode::k##Name: \ | 76 case Bytecode::k##Name: \ |
65 return #Name; | 77 return #Name; |
66 BYTECODE_LIST(CASE) | 78 BYTECODE_LIST(CASE) |
67 #undef CASE | 79 #undef CASE |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 #define CASE(Name, _) \ | 280 #define CASE(Name, _) \ |
269 case OperandType::k##Name: \ | 281 case OperandType::k##Name: \ |
270 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; | 282 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; |
271 OPERAND_TYPE_LIST(CASE) | 283 OPERAND_TYPE_LIST(CASE) |
272 #undef CASE | 284 #undef CASE |
273 } | 285 } |
274 UNREACHABLE(); | 286 UNREACHABLE(); |
275 } | 287 } |
276 | 288 |
277 // static | 289 // 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, | 290 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, |
304 OperandScale operand_scale) { | 291 OperandScale operand_scale) { |
305 return operand_scale == OperandScale::kSingle || | 292 return operand_scale == OperandScale::kSingle || |
306 Bytecodes::IsBytecodeWithScalableOperands(bytecode); | 293 Bytecodes::IsBytecodeWithScalableOperands(bytecode); |
307 } | 294 } |
308 | 295 |
309 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 296 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
310 return os << Bytecodes::ToString(bytecode); | 297 return os << Bytecodes::ToString(bytecode); |
311 } | 298 } |
312 | 299 |
313 } // namespace interpreter | 300 } // namespace interpreter |
314 } // namespace internal | 301 } // namespace internal |
315 } // namespace v8 | 302 } // namespace v8 |
OLD | NEW |