| Index: src/interpreter/bytecodes.h
|
| diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h
|
| index 0e9c728781fe56701ff18cac97768e8d8d8e0dd3..08af5081866f94c7d82227db247af53aac78a0e0 100644
|
| --- a/src/interpreter/bytecodes.h
|
| +++ b/src/interpreter/bytecodes.h
|
| @@ -16,82 +16,97 @@ 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(Count8, OperandSize::kByte) \
|
| + V(Imm8, OperandSize::kByte) \
|
| + V(Idx8, OperandSize::kByte) \
|
| + V(Reg8, OperandSize::kByte) \
|
| + \
|
| + /* Short operands. */ \
|
| + V(Idx16, OperandSize::kShort)
|
|
|
| // The list of bytecodes which are interpreted by the interpreter.
|
| -#define BYTECODE_LIST(V) \
|
| - \
|
| - /* Loading the accumulator */ \
|
| - V(LdaZero, OperandType::kNone) \
|
| - V(LdaSmi8, OperandType::kImm8) \
|
| - V(LdaConstant, OperandType::kIdx) \
|
| - V(LdaUndefined, OperandType::kNone) \
|
| - V(LdaNull, OperandType::kNone) \
|
| - V(LdaTheHole, OperandType::kNone) \
|
| - V(LdaTrue, OperandType::kNone) \
|
| - V(LdaFalse, OperandType::kNone) \
|
| - \
|
| - /* Load globals */ \
|
| - V(LdaGlobal, OperandType::kIdx) \
|
| - \
|
| - /* Register-accumulator transfers */ \
|
| - V(Ldar, OperandType::kReg) \
|
| - V(Star, OperandType::kReg) \
|
| - \
|
| - /* LoadIC operations */ \
|
| - V(LoadIC, OperandType::kReg, OperandType::kIdx) \
|
| - V(KeyedLoadIC, OperandType::kReg, OperandType::kIdx) \
|
| - \
|
| - /* StoreIC operations */ \
|
| - V(StoreIC, OperandType::kReg, OperandType::kReg, OperandType::kIdx) \
|
| - V(KeyedStoreIC, OperandType::kReg, OperandType::kReg, OperandType::kIdx) \
|
| - \
|
| - /* Binary Operators */ \
|
| - V(Add, OperandType::kReg) \
|
| - V(Sub, OperandType::kReg) \
|
| - V(Mul, OperandType::kReg) \
|
| - V(Div, OperandType::kReg) \
|
| - V(Mod, OperandType::kReg) \
|
| - \
|
| - /* Call operations. */ \
|
| - V(Call, OperandType::kReg, OperandType::kReg, OperandType::kCount) \
|
| - \
|
| - /* Test Operators */ \
|
| - V(TestEqual, OperandType::kReg) \
|
| - V(TestNotEqual, OperandType::kReg) \
|
| - V(TestEqualStrict, OperandType::kReg) \
|
| - V(TestNotEqualStrict, OperandType::kReg) \
|
| - V(TestLessThan, OperandType::kReg) \
|
| - V(TestGreaterThan, OperandType::kReg) \
|
| - V(TestLessThanOrEqual, OperandType::kReg) \
|
| - V(TestGreaterThanOrEqual, OperandType::kReg) \
|
| - V(TestInstanceOf, OperandType::kReg) \
|
| - V(TestIn, OperandType::kReg) \
|
| - \
|
| - /* Cast operators */ \
|
| - V(ToBoolean, OperandType::kNone) \
|
| - \
|
| - /* Control Flow */ \
|
| - V(Jump, OperandType::kImm8) \
|
| - V(JumpConstant, OperandType::kIdx) \
|
| - V(JumpIfTrue, OperandType::kImm8) \
|
| - V(JumpIfTrueConstant, OperandType::kIdx) \
|
| - V(JumpIfFalse, OperandType::kImm8) \
|
| - V(JumpIfFalseConstant, OperandType::kIdx) \
|
| +#define BYTECODE_LIST(V) \
|
| + \
|
| + /* Loading the accumulator */ \
|
| + V(LdaZero, OperandType::kNone) \
|
| + V(LdaSmi8, OperandType::kImm8) \
|
| + V(LdaConstant, OperandType::kIdx8) \
|
| + V(LdaUndefined, OperandType::kNone) \
|
| + V(LdaNull, OperandType::kNone) \
|
| + V(LdaTheHole, OperandType::kNone) \
|
| + V(LdaTrue, OperandType::kNone) \
|
| + V(LdaFalse, OperandType::kNone) \
|
| + \
|
| + /* Load globals */ \
|
| + V(LdaGlobal, OperandType::kIdx8) \
|
| + \
|
| + /* Reg8ister-accumulator transfers */ \
|
| + V(Ldar, OperandType::kReg8) \
|
| + V(Star, OperandType::kReg8) \
|
| + \
|
| + /* LoadIC operations */ \
|
| + V(LoadIC, OperandType::kReg8, OperandType::kIdx8) \
|
| + V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \
|
| + \
|
| + /* StoreIC operations */ \
|
| + V(StoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \
|
| + V(KeyedStoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \
|
| + \
|
| + /* Binary Operators */ \
|
| + V(Add, OperandType::kReg8) \
|
| + V(Sub, OperandType::kReg8) \
|
| + V(Mul, OperandType::kReg8) \
|
| + V(Div, OperandType::kReg8) \
|
| + V(Mod, OperandType::kReg8) \
|
| + \
|
| + /* Call operations. */ \
|
| + V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kCount8) \
|
| + \
|
| + /* Test Operators */ \
|
| + V(TestEqual, OperandType::kReg8) \
|
| + V(TestNotEqual, OperandType::kReg8) \
|
| + V(TestEqualStrict, OperandType::kReg8) \
|
| + V(TestNotEqualStrict, OperandType::kReg8) \
|
| + V(TestLessThan, OperandType::kReg8) \
|
| + V(TestGreaterThan, OperandType::kReg8) \
|
| + V(TestLessThanOrEqual, OperandType::kReg8) \
|
| + V(TestGreaterThanOrEqual, OperandType::kReg8) \
|
| + V(TestInstanceOf, OperandType::kReg8) \
|
| + V(TestIn, OperandType::kReg8) \
|
| + \
|
| + /* Cast operators */ \
|
| + V(ToBoolean, OperandType::kNone) \
|
| + \
|
| + /* Control Flow */ \
|
| + V(Jump, OperandType::kImm8) \
|
| + V(JumpConstant, OperandType::kIdx8) \
|
| + V(JumpIfTrue, OperandType::kImm8) \
|
| + V(JumpIfTrueConstant, OperandType::kIdx8) \
|
| + V(JumpIfFalse, OperandType::kImm8) \
|
| + V(JumpIfFalseConstant, OperandType::kIdx8) \
|
| V(Return, OperandType::kNone)
|
|
|
|
|
| +// Enumeration of the size classes of operand types used by bytecodes.
|
| +enum class OperandSize : uint8_t {
|
| + kNone = 0,
|
| + kByte = 1,
|
| + kShort = 2,
|
| +};
|
| +
|
| +
|
| // 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)
|
| @@ -112,8 +127,8 @@ enum class Bytecode : uint8_t {
|
| };
|
|
|
|
|
| -// An interpreter register which is located in the function's register file
|
| -// in its stack-frame. Register hold parameters, this, and expression values.
|
| +// An interpreter Reg8ister which is located in the function's Reg8ister file
|
| +// in its stack-frame. Reg8ister hold parameters, this, and expression values.
|
| class Register {
|
| public:
|
| static const int kMaxRegisterIndex = 127;
|
| @@ -157,6 +172,9 @@ class Bytecodes {
|
| // Returns string representation of |operand_type|.
|
| static const char* OperandTypeToString(OperandType operand_type);
|
|
|
| + // Returns string representation of |operand_size|.
|
| + static const char* OperandSizeToString(OperandSize operand_size);
|
| +
|
| // Returns byte value of bytecode.
|
| static uint8_t ToByte(Bytecode bytecode);
|
|
|
| @@ -169,14 +187,18 @@ class Bytecodes {
|
| // Return the i-th operand of |bytecode|.
|
| static OperandType GetOperandType(Bytecode bytecode, int i);
|
|
|
| + // Return the size of the i-th operand of |bytecode|.
|
| + static OperandSize GetOperandSize(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();
|
| -
|
| - // Maximum size of a bytecode and its operands.
|
| - static int MaximumSize();
|
| + // Returns the size of |operand|.
|
| + static OperandSize SizeOfOperand(OperandType operand);
|
|
|
| // Return true if the bytecode is a jump or a conditional jump taking
|
| // an immediate byte operand (OperandType::kImm8).
|
| @@ -186,6 +208,12 @@ class Bytecodes {
|
| // constant pool entry (OperandType::kIdx).
|
| static bool IsJumpConstant(Bytecode bytecode);
|
|
|
| + // Converts bytes[0] and bytes[1] to a 16 bit 'short' operand value.
|
| + static uint16_t ShortOperandFromBytes(const uint8_t* bytes);
|
| +
|
| + // Converts 16 bit 'short' |operand| into bytes_out[0] and bytes_out[1].
|
| + static void ShortOperandToBytes(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,
|
| int number_of_parameters);
|
| @@ -196,6 +224,7 @@ class Bytecodes {
|
|
|
| std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
|
| std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
|
| +std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
|
|
|
| } // namespace interpreter
|
| } // namespace internal
|
|
|