Index: src/interpreter/bytecodes.cc |
diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc |
index 9ee7c0a9e6ba03e12b32f6a8a93433b8af8cb048..c5311557fb2a5208c9d48c0e2e4723242a741300 100644 |
--- a/src/interpreter/bytecodes.cc |
+++ b/src/interpreter/bytecodes.cc |
@@ -53,18 +53,6 @@ |
BytecodeTraits<__VA_ARGS__>::kDoubleScaleOperandSizes, \ |
BytecodeTraits<__VA_ARGS__>::kQuadrupleScaleOperandSizes }, |
BYTECODE_LIST(ENTRY) |
-#undef ENTRY |
-}; |
- |
-const OperandSize Bytecodes::kOperandKindSizes[][3] = { |
-#define ENTRY(Name, ...) \ |
- { OperandScaler<OperandType::k##Name, \ |
- OperandScale::kSingle>::kOperandSize, \ |
- OperandScaler<OperandType::k##Name, \ |
- OperandScale::kDouble>::kOperandSize, \ |
- OperandScaler<OperandType::k##Name, \ |
- OperandScale::kQuadruple>::kOperandSize }, |
- OPERAND_TYPE_LIST(ENTRY) |
#undef ENTRY |
}; |
// clang-format on |
@@ -287,6 +275,31 @@ |
} |
// static |
+OperandSize Bytecodes::SizeOfOperand(OperandType operand_type, |
+ OperandScale operand_scale) { |
+ DCHECK_LE(operand_type, OperandType::kLast); |
+ DCHECK_GE(operand_scale, OperandScale::kSingle); |
+ DCHECK_LE(operand_scale, OperandScale::kLast); |
+ STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && |
+ OperandScale::kLast == OperandScale::kQuadruple); |
+ int scale_index = static_cast<int>(operand_scale) >> 1; |
+ // clang-format off |
+ static const OperandSize kOperandSizes[][3] = { |
+#define ENTRY(Name, ...) \ |
+ { OperandScaler<OperandType::k##Name, \ |
+ OperandScale::kSingle>::kOperandSize, \ |
+ OperandScaler<OperandType::k##Name, \ |
+ OperandScale::kDouble>::kOperandSize, \ |
+ OperandScaler<OperandType::k##Name, \ |
+ OperandScale::kQuadruple>::kOperandSize }, |
+ OPERAND_TYPE_LIST(ENTRY) |
+#undef ENTRY |
+ }; |
+ // clang-format on |
+ return kOperandSizes[static_cast<size_t>(operand_type)][scale_index]; |
+} |
+ |
+// static |
bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, |
OperandScale operand_scale) { |
return operand_scale == OperandScale::kSingle || |