Index: src/interpreter/bytecodes.h |
diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h |
index 70be2f58177b5fd94daa6924bb9dadde950197de..e85966bdb7c2494b35ea4dabef1e2cee8cee7d23 100644 |
--- a/src/interpreter/bytecodes.h |
+++ b/src/interpreter/bytecodes.h |
@@ -16,12 +16,19 @@ namespace internal { |
namespace interpreter { |
// The list of operand types used by bytecodes. |
-#define OPERAND_TYPE_LIST(V) \ |
- V(None) \ |
- V(Count) \ |
- V(Imm8) \ |
- V(Idx) \ |
- V(Reg) |
+#define OPERAND_TYPE_LIST(V) \ |
+ \ |
+ /* None operand. */ \ |
+ V(None, OperandSize::kNone) \ |
+ \ |
+ /* Byte operands. */ \ |
+ V(Count, OperandSize::kByte) \ |
+ V(Imm8, OperandSize::kByte) \ |
+ V(Idx, OperandSize::kByte) \ |
+ V(Reg, OperandSize::kByte) \ |
+ \ |
+ /* Wide operands. */ \ |
+ V(WideIdx, OperandSize::kWide) |
oth
2015/09/28 09:21:25
Wide is a loose term. It's currently a 16-bit oper
rmcilroy
2015/10/01 14:09:14
Renamed OperandSize::kWide to OperandSize::kShort,
|
// The list of bytecodes which are interpreted by the interpreter. |
#define BYTECODE_LIST(V) \ |
@@ -86,12 +93,20 @@ namespace interpreter { |
V(Return, OperandType::kNone) |
+// Enumeration of the size classes of operand types used by bytecodes. |
+enum class OperandSize : uint8_t { |
+ kNone = 0, |
+ kByte = 1, |
+ kWide = 2, |
oth
2015/09/28 09:21:25
More descriptive names to avoid wide? kOneByte kTw
rmcilroy
2015/10/01 14:09:14
Made it kByte, kShort and will be kLong for 32.
|
+}; |
+ |
+ |
// Enumeration of operand types used by bytecodes. |
enum class OperandType : uint8_t { |
-#define DECLARE_OPERAND_TYPE(Name) k##Name, |
+#define DECLARE_OPERAND_TYPE(Name, _) k##Name, |
OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) |
#undef DECLARE_OPERAND_TYPE |
-#define COUNT_OPERAND_TYPES(x) +1 |
+#define COUNT_OPERAND_TYPES(x, _) +1 |
// The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will |
// evaluate to the same value as the last operand. |
kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES) |
@@ -169,14 +184,21 @@ class Bytecodes { |
// Return the i-th operand of |bytecode|. |
static OperandType GetOperandType(Bytecode bytecode, int i); |
+ // Returns the offset of the i-th operand of |bytecode| relative to the start |
+ // of the bytecode. |
+ static int GetOperandOffset(Bytecode bytecode, int i); |
+ |
// Returns the size of the bytecode including its operands. |
static int Size(Bytecode bytecode); |
- // The maximum number of operands across all bytecodes. |
- static int MaximumNumberOfOperands(); |
+ // Returns the size of operand. |
+ static OperandSize SizeOfOperand(OperandType operand); |
+ |
+ // Converts bytes[0] and bytes[1] to a 16 bit wide operand value. |
+ static uint16_t WideOperandFromBytes(const uint8_t* bytes); |
- // Maximum size of a bytecode and its operands. |
- static int MaximumSize(); |
+ // Converts 16 bit wide |operand| into bytes_out[0] and bytes_out[1]. |
+ static void WideOperandToBytes(uint16_t operand, uint8_t* bytes_out); |
// Decode a single bytecode and operands to |os|. |
static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, |