| Index: test/unittests/interpreter/bytecodes-unittest.cc
|
| diff --git a/test/unittests/interpreter/bytecodes-unittest.cc b/test/unittests/interpreter/bytecodes-unittest.cc
|
| index 212e02996b65c98a8674dbd453a60a0ef68fcd26..1d5cd8e7761d1d2b6a9cc0d33c9c0c26d487ba07 100644
|
| --- a/test/unittests/interpreter/bytecodes-unittest.cc
|
| +++ b/test/unittests/interpreter/bytecodes-unittest.cc
|
| @@ -83,20 +83,24 @@ TEST(OperandConversion, RegistersParametersNoOverlap) {
|
| }
|
| }
|
|
|
| +TEST(OperandScaling, ScalableAndNonScalable) {
|
| + for (int scale = 1; scale < 8; scale *= 2) {
|
| + CHECK_EQ(Bytecodes::Size(Bytecode::kCallRuntime, scale), 1 + 2 + 2 * scale);
|
| + CHECK_EQ(Bytecodes::Size(Bytecode::kCreateObjectLiteral, scale),
|
| + 1 + 2 * scale + 1);
|
| + CHECK_EQ(Bytecodes::Size(Bytecode::kTestIn, scale), 1 + scale);
|
| + }
|
| +}
|
| +
|
| TEST(Bytecodes, HasAnyRegisterOperands) {
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kAdd), 1);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCall), 2);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntime), 1);
|
| - CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntimeWide), 1);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntimeForPair),
|
| 2);
|
| - CHECK_EQ(
|
| - Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntimeForPairWide),
|
| - 2);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kDeletePropertyStrict),
|
| 1);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kForInPrepare), 1);
|
| - CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kForInPrepareWide), 1);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kInc), 0);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kJumpIfTrue), 0);
|
| CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kNew), 2);
|
| @@ -116,54 +120,56 @@ TEST(Bytecodes, RegisterOperandBitmaps) {
|
| }
|
|
|
| TEST(Bytecodes, RegisterOperands) {
|
| - CHECK(Bytecodes::IsRegisterOperandType(OperandType::kReg8));
|
| - CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::kReg8));
|
| - CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::kReg8));
|
| - CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::kRegOut8));
|
| - CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::kRegOut8));
|
| + CHECK(Bytecodes::IsRegisterOperandType(OperandType::kReg));
|
| + CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::kReg));
|
| + CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::kReg));
|
| + CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::kRegOut));
|
| + CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::kRegOut));
|
|
|
| -#define IS_REGISTER_OPERAND_TYPE(Name, _) \
|
| +#define IS_REGISTER_OPERAND_TYPE(Name, _, __) \
|
| CHECK(Bytecodes::IsRegisterOperandType(OperandType::k##Name));
|
| REGISTER_OPERAND_TYPE_LIST(IS_REGISTER_OPERAND_TYPE)
|
| #undef IS_REGISTER_OPERAND_TYPE
|
|
|
| -#define IS_NOT_REGISTER_OPERAND_TYPE(Name, _) \
|
| +#define IS_NOT_REGISTER_OPERAND_TYPE(Name, _, __) \
|
| CHECK(!Bytecodes::IsRegisterOperandType(OperandType::k##Name));
|
| NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OPERAND_TYPE)
|
| #undef IS_NOT_REGISTER_OPERAND_TYPE
|
|
|
| -#define IS_REGISTER_INPUT_OPERAND_TYPE(Name, _) \
|
| +#define IS_REGISTER_INPUT_OPERAND_TYPE(Name, _, __) \
|
| CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::k##Name));
|
| REGISTER_INPUT_OPERAND_TYPE_LIST(IS_REGISTER_INPUT_OPERAND_TYPE)
|
| #undef IS_REGISTER_INPUT_OPERAND_TYPE
|
|
|
| -#define IS_NOT_REGISTER_INPUT_OPERAND_TYPE(Name, _) \
|
| +#define IS_NOT_REGISTER_INPUT_OPERAND_TYPE(Name, _, __) \
|
| CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::k##Name));
|
| NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_INPUT_OPERAND_TYPE);
|
| REGISTER_OUTPUT_OPERAND_TYPE_LIST(IS_NOT_REGISTER_INPUT_OPERAND_TYPE)
|
| #undef IS_NOT_REGISTER_INPUT_OPERAND_TYPE
|
|
|
| -#define IS_REGISTER_OUTPUT_OPERAND_TYPE(Name, _) \
|
| +#define IS_REGISTER_OUTPUT_OPERAND_TYPE(Name, _, __) \
|
| CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::k##Name));
|
| REGISTER_OUTPUT_OPERAND_TYPE_LIST(IS_REGISTER_OUTPUT_OPERAND_TYPE)
|
| #undef IS_REGISTER_OUTPUT_OPERAND_TYPE
|
|
|
| -#define IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE(Name, _) \
|
| +#define IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE(Name, _, __) \
|
| CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::k##Name));
|
| NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE)
|
| REGISTER_INPUT_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE)
|
| #undef IS_NOT_REGISTER_INPUT_OPERAND_TYPE
|
| }
|
|
|
| -TEST(Bytecodes, DebugBreak) {
|
| - for (uint32_t i = 0; i < Bytecodes::ToByte(Bytecode::kLast); i++) {
|
| - Bytecode bytecode = Bytecodes::FromByte(i);
|
| - Bytecode debugbreak = Bytecodes::GetDebugBreak(bytecode);
|
| - if (!Bytecodes::IsDebugBreak(debugbreak)) {
|
| - PrintF("Bytecode %s has no matching debug break with length %d\n",
|
| - Bytecodes::ToString(bytecode), Bytecodes::Size(bytecode));
|
| - CHECK(false);
|
| - }
|
| +TEST(Bytecodes, DebugBreakExistForEachBytecode) {
|
| + for (int operand_scale = 1; operand_scale < 8; operand_scale *= 2) {
|
| +#define CHECK_DEBUG_BREAK_SIZE(Name, ...) \
|
| + { \
|
| + Bytecode debug_bytecode = \
|
| + Bytecodes::GetDebugBreak(Bytecode::k##Name, operand_scale); \
|
| + CHECK_EQ(Bytecodes::Size(Bytecode::k##Name, operand_scale), \
|
| + Bytecodes::Size(debug_bytecode, operand_scale)); \
|
| + }
|
| + BYTECODE_LIST(CHECK_DEBUG_BREAK_SIZE)
|
| +#undef CHECK_DEBUG_BREAK_SIZE
|
| }
|
| }
|
|
|
|
|