Chromium Code Reviews| Index: src/interpreter/bytecodes.h |
| diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h |
| index dc125162fa4f6763b5203d2d2e0bc12595361a4f..920038b23f14bfca570315d7f87e1a164ee309f8 100644 |
| --- a/src/interpreter/bytecodes.h |
| +++ b/src/interpreter/bytecodes.h |
| @@ -15,38 +15,67 @@ namespace v8 { |
| namespace internal { |
| namespace interpreter { |
| +// The list of operands used by bytecodes. |
| +#define OPERAND_LIST(V) \ |
|
rmcilroy
2015/07/27 14:56:58
nit - OPERAND_TYPE_LIST
oth
2015/07/27 16:59:00
Done.
|
| + V(None) \ |
| + V(Imm8) \ |
| + V(Reg) |
| + |
| +enum class Operand : uint8_t { |
|
rmcilroy
2015/07/27 14:56:57
nit - OperandType
oth
2015/07/27 16:59:00
Done.
|
| +#define DECLARE_OPERAND(Name) k##Name, |
| + OPERAND_LIST(DECLARE_OPERAND) |
| +#undef DECLARE_OPERAND |
| +#define COUNT_OPERAND(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_LIST(COUNT_OPERAND) |
| +#undef COUNT_OPERAND |
| +}; |
| + |
| // The list of bytecodes which are interpreted by the interpreter. |
| -#define BYTECODE_LIST(V) \ |
| - V(LoadLiteral0, 1) \ |
| - V(Return, 0) |
| +#define BYTECODE_LIST(V) \ |
| + V(LoadSmi0, Operand::kReg) \ |
| + V(LoadSmi8, Operand::kReg, Operand::kImm8) \ |
| + V(Return, Operand::kNone) |
|
rmcilroy
2015/07/27 14:56:58
nit - can we move this up just below OPERAND_LIST
oth
2015/07/27 16:59:00
Done.
|
| + |
| enum class Bytecode : uint8_t { |
| -#define DECLARE_BYTECODE(Name, _) k##Name, |
| +#define DECLARE_BYTECODE(Name, ...) k##Name, |
| BYTECODE_LIST(DECLARE_BYTECODE) |
| #undef DECLARE_BYTECODE |
| -#define COUNT_BYTECODE(x, _) +1 |
| +#define COUNT_BYTECODE(x, ...) +1 |
| // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will |
| // evaluate to the same value as the last real bytecode. |
| kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
| #undef COUNT_BYTECODE |
| }; |
| + |
| class Bytecodes { |
| public: |
| // Returns string representation of |bytecode|. |
| static const char* ToString(Bytecode bytecode); |
| - // Returns the number of arguments expected by |bytecode|. |
| - static const int NumberOfArguments(Bytecode bytecode); |
| + // Returns byte value of bytecode. |
| + static uint8_t ToByte(Bytecode bytecode); |
| + |
| + // Returns bytecode for |value|,, checking validity in the process. |
|
rmcilroy
2015/07/27 14:56:58
remove extra ','
oth
2015/07/27 16:59:00
Done.
|
| + static Bytecode FromByte(uint8_t value); |
| + |
| + // Returns the number of operands expected by |bytecode|. |
| + static const int NumberOfOperands(Bytecode bytecode); |
| + |
| + // Return the i-th operand of |bytecode|. |
|
rmcilroy
2015/07/27 14:56:58
Return the type of the i-th operand of |bytecode|
oth
2015/07/27 16:59:00
Done.
|
| + static const Operand GetOperand(Bytecode bytecode, int i); |
|
rmcilroy
2015/07/27 14:56:58
GetOperandType
oth
2015/07/27 16:59:00
Done.
|
| // Returns the size of the bytecode including its arguments. |
| static const int Size(Bytecode bytecode); |
| - // The maximum number of arguments across all bytecodes. |
| - static const int kMaximumNumberOfArguments = 1; |
| + // The maximum number of operands across all bytecodes. |
| + static const int MaximumNumberOfOperands(); |
| // Maximum size of a bytecode and its arguments. |
| - static const int kMaximumSize = 1 + kMaximumNumberOfArguments; |
| + static const int MaximumSize(); |
| private: |
| DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); |