Index: src/interpreter/bytecodes.h |
diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h |
index 42f68c9f92729fdb5f644a79999a31d26ee9a12f..75bce51bcc0aa713f9104d226c2c3bb789f008cd 100644 |
--- a/src/interpreter/bytecodes.h |
+++ b/src/interpreter/bytecodes.h |
@@ -11,6 +11,7 @@ |
#include "src/globals.h" |
#include "src/interpreter/bytecode-operands.h" |
+#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
|
// This interface and it's implementation are independent of the |
// libv8_base library as they are used by the interpreter and the |
@@ -834,8 +835,30 @@ class V8_EXPORT_PRIVATE Bytecodes final { |
UNREACHABLE(); |
} |
- // Returns the size of |operand| for |operand_scale|. |
- static OperandSize SizeOfOperand(OperandType operand, OperandScale scale); |
+ // Returns the size of |operand_type| for |operand_scale|. |
+ static OperandSize 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]; |
+ } |
// Returns true if |operand_type| is a runtime-id operand (kRuntimeId). |
static bool IsRuntimeIdOperandType(OperandType operand_type); |