| 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..5b801adc31823134b8d2a09965b8994e2b3b6a0c 100644
|
| --- a/test/unittests/interpreter/bytecodes-unittest.cc
|
| +++ b/test/unittests/interpreter/bytecodes-unittest.cc
|
| @@ -14,28 +14,27 @@ namespace internal {
|
| namespace interpreter {
|
|
|
| TEST(OperandConversion, Registers) {
|
| - int register_count = Register::MaxRegisterIndex() + 1;
|
| + int register_count = 128;
|
| int step = register_count / 7;
|
| for (int i = 0; i < register_count; i += step) {
|
| if (i <= kMaxInt8) {
|
| - uint8_t operand0 = Register(i).ToOperand();
|
| + uint32_t operand0 = Register(i).ToOperand();
|
| Register reg0 = Register::FromOperand(operand0);
|
| CHECK_EQ(i, reg0.index());
|
| }
|
|
|
| - uint16_t operand1 = Register(i).ToWideOperand();
|
| - Register reg1 = Register::FromWideOperand(operand1);
|
| + uint32_t operand1 = Register(i).ToOperand();
|
| + Register reg1 = Register::FromOperand(operand1);
|
| CHECK_EQ(i, reg1.index());
|
|
|
| - uint32_t operand2 = Register(i).ToRawOperand();
|
| - Register reg2 = Register::FromRawOperand(operand2);
|
| + uint32_t operand2 = Register(i).ToOperand();
|
| + Register reg2 = Register::FromOperand(operand2);
|
| CHECK_EQ(i, reg2.index());
|
| }
|
|
|
| for (int i = 0; i <= kMaxUInt8; i++) {
|
| - uint8_t operand = static_cast<uint8_t>(i);
|
| - Register reg = Register::FromOperand(operand);
|
| - if (i > 0 && i < -kMinInt8) {
|
| + Register reg = Register::FromOperand(i);
|
| + if (i > 0) {
|
| CHECK(reg.is_parameter());
|
| } else {
|
| CHECK(!reg.is_parameter());
|
| @@ -51,7 +50,7 @@ TEST(OperandConversion, Parameters) {
|
| int parameter_count = parameter_counts[p];
|
| for (int i = 0; i < parameter_count; i++) {
|
| Register r = Register::FromParameterIndex(i, parameter_count);
|
| - uint8_t operand_value = r.ToOperand();
|
| + uint32_t operand_value = r.ToOperand();
|
| Register s = Register::FromOperand(operand_value);
|
| CHECK_EQ(i, s.ToParameterIndex(parameter_count));
|
| }
|
| @@ -59,8 +58,8 @@ TEST(OperandConversion, Parameters) {
|
| }
|
|
|
| TEST(OperandConversion, RegistersParametersNoOverlap) {
|
| - int register_count = Register::MaxRegisterIndex() + 1;
|
| - int parameter_count = Register::MaxParameterIndex() + 1;
|
| + int register_count = 128;
|
| + int parameter_count = 100;
|
| int32_t register_space_size = base::bits::RoundUpToPowerOfTwo32(
|
| static_cast<uint32_t>(register_count + parameter_count));
|
| uint32_t range = static_cast<uint32_t>(register_space_size);
|
| @@ -68,18 +67,29 @@ TEST(OperandConversion, RegistersParametersNoOverlap) {
|
|
|
| for (int i = 0; i < register_count; i += 1) {
|
| Register r = Register(i);
|
| - uint32_t operand = r.ToWideOperand();
|
| - CHECK_LT(operand, operand_count.size());
|
| - operand_count[operand] += 1;
|
| - CHECK_EQ(operand_count[operand], 1);
|
| + int32_t operand = r.ToOperand();
|
| + uint8_t index = static_cast<uint8_t>(operand);
|
| + CHECK_LT(index, operand_count.size());
|
| + operand_count[index] += 1;
|
| + CHECK_EQ(operand_count[index], 1);
|
| }
|
|
|
| for (int i = 0; i < parameter_count; i += 1) {
|
| Register r = Register::FromParameterIndex(i, parameter_count);
|
| - uint32_t operand = r.ToWideOperand();
|
| - CHECK_LT(operand, operand_count.size());
|
| - operand_count[operand] += 1;
|
| - CHECK_EQ(operand_count[operand], 1);
|
| + uint32_t operand = r.ToOperand();
|
| + uint8_t index = static_cast<uint8_t>(operand);
|
| + CHECK_LT(index, operand_count.size());
|
| + operand_count[index] += 1;
|
| + CHECK_EQ(operand_count[index], 1);
|
| + }
|
| +}
|
| +
|
| +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);
|
| }
|
| }
|
|
|
| @@ -87,16 +97,11 @@ 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,11 +121,11 @@ 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, _) \
|
| CHECK(Bytecodes::IsRegisterOperandType(OperandType::k##Name));
|
| @@ -155,15 +160,17 @@ TEST(Bytecodes, RegisterOperands) {
|
| #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
|
| }
|
| }
|
|
|
|
|