| Index: test/unittests/interpreter/bytecode-array-builder-unittest.cc
|
| diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
|
| index 007b68c06517922872ec07602ae766837a17fb93..3b115897bdcad798758e3c1dc1b1762665cf0d01 100644
|
| --- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc
|
| +++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
|
| @@ -64,7 +64,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
| // Emit Ldar and Star taking care to foil the register optimizer.
|
| builder.StackCheck(0)
|
| .LoadAccumulatorWithRegister(other)
|
| - .BinaryOperation(Token::ADD, reg)
|
| + .BinaryOperation(Token::ADD, reg, 1)
|
| .StoreAccumulatorInRegister(reg)
|
| .LoadNull();
|
|
|
| @@ -123,38 +123,39 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
| .CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, wide, 1);
|
|
|
| // Emit binary operator invocations.
|
| - builder.BinaryOperation(Token::Value::ADD, reg)
|
| - .BinaryOperation(Token::Value::SUB, reg)
|
| - .BinaryOperation(Token::Value::MUL, reg)
|
| - .BinaryOperation(Token::Value::DIV, reg)
|
| - .BinaryOperation(Token::Value::MOD, reg);
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 1)
|
| + .BinaryOperation(Token::Value::SUB, reg, 2)
|
| + .BinaryOperation(Token::Value::MUL, reg, 3)
|
| + .BinaryOperation(Token::Value::DIV, reg, 4)
|
| + .BinaryOperation(Token::Value::MOD, reg, 5);
|
|
|
| // Emit bitwise operator invocations
|
| - builder.BinaryOperation(Token::Value::BIT_OR, reg)
|
| - .BinaryOperation(Token::Value::BIT_XOR, reg)
|
| - .BinaryOperation(Token::Value::BIT_AND, reg);
|
| + builder.BinaryOperation(Token::Value::BIT_OR, reg, 6)
|
| + .BinaryOperation(Token::Value::BIT_XOR, reg, 7)
|
| + .BinaryOperation(Token::Value::BIT_AND, reg, 8);
|
|
|
| // Emit shift operator invocations
|
| - builder.BinaryOperation(Token::Value::SHL, reg)
|
| - .BinaryOperation(Token::Value::SAR, reg)
|
| - .BinaryOperation(Token::Value::SHR, reg);
|
| + builder.BinaryOperation(Token::Value::SHL, reg, 9)
|
| + .BinaryOperation(Token::Value::SAR, reg, 10)
|
| + .BinaryOperation(Token::Value::SHR, reg, 11);
|
|
|
| // Emit peephole optimizations of LdaSmi followed by binary operation.
|
| builder.LoadLiteral(Smi::FromInt(1))
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 1)
|
| .LoadLiteral(Smi::FromInt(2))
|
| - .BinaryOperation(Token::Value::SUB, reg)
|
| + .BinaryOperation(Token::Value::SUB, reg, 2)
|
| .LoadLiteral(Smi::FromInt(3))
|
| - .BinaryOperation(Token::Value::BIT_AND, reg)
|
| + .BinaryOperation(Token::Value::BIT_AND, reg, 3)
|
| .LoadLiteral(Smi::FromInt(4))
|
| - .BinaryOperation(Token::Value::BIT_OR, reg)
|
| + .BinaryOperation(Token::Value::BIT_OR, reg, 4)
|
| .LoadLiteral(Smi::FromInt(5))
|
| - .BinaryOperation(Token::Value::SHL, reg)
|
| + .BinaryOperation(Token::Value::SHL, reg, 5)
|
| .LoadLiteral(Smi::FromInt(6))
|
| - .BinaryOperation(Token::Value::SAR, reg);
|
| + .BinaryOperation(Token::Value::SAR, reg, 6);
|
|
|
| // Emit count operatior invocations
|
| - builder.CountOperation(Token::Value::ADD).CountOperation(Token::Value::SUB);
|
| + builder.CountOperation(Token::Value::ADD, 1)
|
| + .CountOperation(Token::Value::SUB, 1);
|
|
|
| // Emit unary operator invocations.
|
| builder
|
| @@ -225,9 +226,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
| .JumpIfFalse(&start);
|
| // Perform an operation that returns a non-boolean operation to
|
| // generate JumpIfToBooleanTrue/False.
|
| - builder.BinaryOperation(Token::Value::ADD, reg)
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 1)
|
| .JumpIfTrue(&start)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 2)
|
| .JumpIfFalse(&start);
|
| // Insert dummy ops to force longer jumps
|
| for (int i = 0; i < 128; i++) {
|
| @@ -249,9 +250,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
| .JumpIfFalse(&start);
|
| // Perform an operation that returns a non-boolean operation to
|
| // generate JumpIfToBooleanTrue/False.
|
| - builder.BinaryOperation(Token::Value::ADD, reg)
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 1)
|
| .JumpIfTrue(&start)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 2)
|
| .JumpIfFalse(&start);
|
| }
|
|
|
| @@ -353,9 +354,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
|
|
| // Perform an operation that returns a non-boolean operation to
|
| // generate JumpIfToBooleanTrue/False.
|
| - builder.BinaryOperation(Token::Value::ADD, reg)
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 1)
|
| .JumpIfTrue(&start)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 2)
|
| .JumpIfFalse(&start);
|
|
|
| // Emit generator operations
|
| @@ -563,9 +564,9 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
| .JumpIfTrue(&near1)
|
| .CompareOperation(Token::Value::EQ, reg)
|
| .JumpIfFalse(&near2)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 1)
|
| .JumpIfTrue(&near3)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 2)
|
| .JumpIfFalse(&near4)
|
| .Bind(&near0)
|
| .Bind(&near1)
|
| @@ -578,22 +579,22 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
| .JumpIfTrue(&far1)
|
| .CompareOperation(Token::Value::EQ, reg)
|
| .JumpIfFalse(&far2)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 3)
|
| .JumpIfTrue(&far3)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 4)
|
| .JumpIfFalse(&far4);
|
| - for (int i = 0; i < kFarJumpDistance - 18; i++) {
|
| + for (int i = 0; i < kFarJumpDistance - 20; i++) {
|
| builder.Debugger();
|
| }
|
| builder.Bind(&far0).Bind(&far1).Bind(&far2).Bind(&far3).Bind(&far4);
|
| builder.Return();
|
|
|
| Handle<BytecodeArray> array = builder.ToBytecodeArray();
|
| - DCHECK_EQ(array->length(), 36 + kFarJumpDistance - 18 + 1);
|
| + DCHECK_EQ(array->length(), 40 + kFarJumpDistance - 20 + 1);
|
|
|
| BytecodeArrayIterator iterator(array);
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), 18);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), 20);
|
| iterator.Advance();
|
|
|
| // Ignore compare operation.
|
| @@ -601,7 +602,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
|
|
| CHECK_EQ(iterator.current_bytecode(),
|
| PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue));
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), 14);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), 16);
|
| iterator.Advance();
|
|
|
| // Ignore compare operation.
|
| @@ -609,14 +610,14 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
|
|
| CHECK_EQ(iterator.current_bytecode(),
|
| PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse));
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), 10);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), 12);
|
| iterator.Advance();
|
|
|
| // Ignore add operation.
|
| iterator.Advance();
|
|
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrue);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), 6);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), 7);
|
| iterator.Advance();
|
|
|
| // Ignore add operation.
|
| @@ -654,7 +655,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
|
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrueConstant);
|
| CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
|
| - Smi::FromInt(kFarJumpDistance - 12));
|
| + Smi::FromInt(kFarJumpDistance - 13));
|
| iterator.Advance();
|
|
|
| // Ignore add operation.
|
| @@ -663,7 +664,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
|
| CHECK_EQ(iterator.current_bytecode(),
|
| Bytecode::kJumpIfToBooleanFalseConstant);
|
| CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
|
| - Smi::FromInt(kFarJumpDistance - 16));
|
| + Smi::FromInt(kFarJumpDistance - 18));
|
| iterator.Advance();
|
| }
|
|
|
| @@ -684,12 +685,12 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) {
|
| .CompareOperation(Token::Value::EQ, reg)
|
| .JumpIfFalse(&label2)
|
| .Bind(&label3)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 1)
|
| .JumpIfTrue(&label3)
|
| .Bind(&label4)
|
| - .BinaryOperation(Token::Value::ADD, reg)
|
| + .BinaryOperation(Token::Value::ADD, reg, 2)
|
| .JumpIfFalse(&label4);
|
| - for (int i = 0; i < 63; i++) {
|
| + for (int i = 0; i < 62; i++) {
|
| BytecodeLabel after_jump;
|
| builder.Jump(&label4).Bind(&after_jump);
|
| }
|
| @@ -699,8 +700,8 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) {
|
| builder.Debugger();
|
| }
|
|
|
| - builder.BinaryOperation(Token::Value::ADD, reg).JumpIfFalse(&label4);
|
| - builder.BinaryOperation(Token::Value::ADD, reg).JumpIfTrue(&label3);
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 1).JumpIfFalse(&label4);
|
| + builder.BinaryOperation(Token::Value::ADD, reg, 2).JumpIfTrue(&label3);
|
| builder.CompareOperation(Token::Value::EQ, reg).JumpIfFalse(&label2);
|
| builder.CompareOperation(Token::Value::EQ, reg).JumpIfTrue(&label1);
|
| builder.Jump(&label0);
|
| @@ -731,18 +732,19 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) {
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrue);
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -2);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -3);
|
| iterator.Advance();
|
| // Ignore binary operation.
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanFalse);
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -2);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -3);
|
| iterator.Advance();
|
| - for (int i = 0; i < 63; i++) {
|
| + for (int i = 0; i < 62; i++) {
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump);
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -i * 2 - 4);
|
| + // offset of 5 (3 for binary operation and 2 for jump)
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -i * 2 - 5);
|
| iterator.Advance();
|
| }
|
| // Check padding to force wide backwards jumps.
|
| @@ -760,25 +762,25 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) {
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrue);
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -399);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -401);
|
| iterator.Advance();
|
| // Ignore compare operation.
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(),
|
| PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse));
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -409);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -411);
|
| iterator.Advance();
|
| // Ignore compare operation.
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(),
|
| PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue));
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -419);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -421);
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump);
|
| CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble);
|
| - CHECK_EQ(iterator.GetImmediateOperand(0), -425);
|
| + CHECK_EQ(iterator.GetImmediateOperand(0), -427);
|
| iterator.Advance();
|
| CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
|
| iterator.Advance();
|
|
|